-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTAThemeDistributionTable.js
More file actions
164 lines (146 loc) · 5.03 KB
/
TAThemeDistributionTable.js
File metadata and controls
164 lines (146 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
* @class TAThemeDistributionTable
* @classdesc Class to work with ThemeDistribution table
*
* @constructs TAThemeDistributionTable
* @param {Object} globals - object of global report variables {pageContext: this.pageContext, report: report, user: user, state: state, confirmit: confirmit, log: log}
* @param {TAFoldee} folder - Text Analytics folder to build table from
* @param {Table} table
* @param {String} sentiment - "emptyv", "neg", "neu", "pos"
*/
class TAThemeDistributionTable{
private var _globals;
private var _folder: TAFolder;
private var _taTableUtils: TATableUtils;
private var _taMasks: TAMasks;
private var _table: Table;
private var _sentiment;
private var _percents;
private var _period;
private var _config;
function TAThemeDistributionTable(globals, folder, table, sentiment,config){
_globals = globals;
_folder = folder;
_taMasks = new TAMasks(globals, folder);
_table = table;
_taTableUtils = new TATableUtils(globals, folder, table);
_sentiment = sentiment == "emptyv" ? "all" : sentiment;
_period = {
Unit: "m",
From: -11,
To: 0
};
_config = config;
_render();
}
/**
* @memberof TAThemeDistributionTable
* @instance
* @function GetTATableUtils
* @returns {TATAbleUtils}
*/
function GetTATableUtils(){
return _taTableUtils;
}
/**
* @memberof TAThemeDistributionTable
* @private
* @instance
* @function _render
*/
private function _render(){
var qType = "categorysentiment";
var rowexpr = _taTableUtils.GetTAQuestionExpression(qType);
_taTableUtils.CreateTableFromExpression(rowexpr);
_addTimeSeriesColumn();
_setupConditionalFormatting();
}
/**
* @memberof TAThemeDistributionTable
* @private
* @instance
* @function _addTimeSeriesColum
*/
private function _addTimeSeriesColumn(){
var headerTimeSeries = _taTableUtils.GetTimePeriodHeader(_period.Unit, _period.From, _period.To);
var columnsCollection: HeaderCollection = new HeaderCollection();
columnsCollection.AddRange(_getCountsColumn());
columnsCollection.Add(_getHeaderStatistics());
headerTimeSeries.SubHeaders.AddRange(columnsCollection);
_table.ColumnHeaders.Add(headerTimeSeries);
}
/**
* @memberof TAThemeDistributionTable
* @private
* @instance
* @function _getCountsColumn
* @returns {HeaderCollection}
*/
private function _getCountsColumn(){
var columnsCollection: HeaderCollection = _taTableUtils.GetCategoriesHeader(_sentiment, false, true, false, Config.SentimentRange);
return columnsCollection
}
/**
* @memberof TAThemeDistributionTable
* @private
* @instance
* @function _getHeaderStatistics
* @returns {Header}
*/
private function _getHeaderStatistics(){
var headerStatistics;
if( _sentiment == "all"){
headerStatistics = new HeaderStatistics();
headerStatistics.Statistics.Avg = true;
}else{
headerStatistics = new HeaderFormula();
headerStatistics.Type = FormulaType.Expression;
headerStatistics.Decimals = 0;
headerStatistics.Priority = 0;
switch (_sentiment) {
case "neg":
headerStatistics.Expression = "-6";
break;
case "neu":
headerStatistics.Expression = "0";
break;
case "pos":
headerStatistics.Expression = "6";
break;
}
}
headerStatistics.HideHeader = true;
headerStatistics.HideData = true;
return headerStatistics
}
/**
* @memberof TAThemeDistributionTable
* @private
* @instance
* @function _setupConditionalFormatting}
*/
private function _setupConditionalFormatting(){
_taTableUtils.SetupConditionalFormatting(
[
{
expression: 'cellv(col+1, row)<('+(_config.SentimentRange.Neutral[0] - 6)+') AND cellv(col,row)<>EMPTYV() ',
style: 'negative'
},
{
expression: '(cellv(col+1, row)>=('+(_config.SentimentRange.Neutral[0] - 6)+')) AND (cellv(col+1, row)<='+(_config.SentimentRange.Neutral[_config.SentimentRange.Neutral.length - 1] - 6)+') AND cellv(col,row)<>EMPTYV()',
style: 'neutral'
},
{
expression: 'cellv(col+1, row)>'+(_config.SentimentRange.Neutral[_config.SentimentRange.Neutral.length - 1] - 6)+' AND cellv(col,row)<>EMPTYV()',
style: 'positive'
}
],
"NegNeuPos",
{
axis: Area.Columns,
direction: Area.Left,
indexes: "1-1000"
}
)
}
}