-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTATopSentimentTable.js
More file actions
90 lines (85 loc) · 2.84 KB
/
TATopSentimentTable.js
File metadata and controls
90 lines (85 loc) · 2.84 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
/**
* @class TATopSentimentTable
* @classdesc Class to work with Most positive and most negative tables on the dashboard page
*
* @constructs TATopSentimentTable
* @param {Object} globals - object of global report variables {pageContext: this.pageContext, report: report, user: user, state: state, confirmit: confirmit, log: log}
* @param {TAFolder} folder - Text Analytics folder to build table from
* @param {Table} table
* @param {String} sentiment - "neg", "pos"
* @param {String} level - 1, 2 or 3
* @param {Number} topN
*/
class TATopSentimentTable{
private var _globals;
private var _folder: TAFolder;
private var _taTableUtils: TATableUtils;
private var _taMasks: TAMasks;
private var _table: Table;
private var _level;
private var _topN;
private var _sentiment;
private var _distribution;
function TATopSentimentTable(globals, folder, table, sentiment, level, topN, distribution){
_globals = globals;
_folder = folder;
_taMasks = new TAMasks(globals, folder);
_table = table;
_taTableUtils = new TATableUtils(globals, folder, table);
_sentiment = sentiment ? true : false;
_level = parseInt(level);
_topN = topN ? topN : 5;
_distribution = distribution ? distribution : "0";
_render();
}
/**
* @memberof TATopSentimentTable
* @instance
* @function GetTATableUtils
* @returns {TATAbleUtils}
*/
function GetTATableUtils(){
return _taTableUtils;
}
/**
* @memberof TATopSentimentTable
* @private
* @instance
* @function _render
*/
private function _render(){
var qType = "categorysentiment";
var mask = _taMasks.GetCategoriesMask(_level);
var rowexpr = _taTableUtils.GetTAQuestionExpression(qType, mask);
var sentiment = _sentiment ? "pos" : "neg";
var columnexpr = _taTableUtils.GetCategoriesExpression( sentiment, false, false, _distribution, Config.SentimentRange );
_taTableUtils.CreateTableFromExpression(rowexpr, columnexpr);
_addChartColumn();
_setupSorting();
}
/**
* @memberof TATopSentimentTable
* @private
* @instance
* @function _addChartColum
*/
private function _addChartColumn(){
var chartHeader = _taTableUtils.GetChartHeader(
ChartComboType.Bar,
[{
Formula: "cellv(col-1,row)",
Color: ( _sentiment ? Config.Colors.NegNeuPosPalette.Positive : Config.Colors.NegNeuPosPalette.Negative )
}],
"Count");
_table.ColumnHeaders.Add(chartHeader);
}
/**
* @memberof TATopSentimentTable
* @private
* @instance
* @function _setupSorting
*/
private function _setupSorting(){
_taTableUtils.SetupRowsTableSorting( false, 2, _topN, true);
}
}