@datarailsshared/dr_renderer 1.2.234-rocket → 1.2.236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +6 -0
- package/babel.config.js +3 -0
- package/jest.config.js +27 -0
- package/package.json +24 -3
- package/src/highcharts_renderer.js +62 -134
- package/tests/highcharts_renderer.test.js +48 -0
package/.circleci/config.yml
CHANGED
|
@@ -31,6 +31,12 @@ jobs:
|
|
|
31
31
|
- run:
|
|
32
32
|
name: Authenticate with registry
|
|
33
33
|
command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/.npmrc
|
|
34
|
+
- run:
|
|
35
|
+
name: Install dependencies
|
|
36
|
+
command: npm install
|
|
37
|
+
- run:
|
|
38
|
+
name: Run npm test
|
|
39
|
+
command: npm test
|
|
34
40
|
- run:
|
|
35
41
|
name: Publish package
|
|
36
42
|
command: npm publish . --access=public
|
package/babel.config.js
ADDED
package/jest.config.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
clearMocks: true,
|
|
3
|
+
setupFilesAfterEnv: ['regenerator-runtime/runtime'],
|
|
4
|
+
testPathIgnorePatterns: [
|
|
5
|
+
"/node_modules/",
|
|
6
|
+
],
|
|
7
|
+
transformIgnorePatterns: [
|
|
8
|
+
"<rootDir>/node_modules/(?!jquery|lodash|moment/)",
|
|
9
|
+
],
|
|
10
|
+
collectCoverage: true,
|
|
11
|
+
collectCoverageFrom: [
|
|
12
|
+
'**/*.js',
|
|
13
|
+
'!**/*.config.js',
|
|
14
|
+
'!**/build/**',
|
|
15
|
+
'!**/coverage/**',
|
|
16
|
+
'!**/node_modules/**',
|
|
17
|
+
'!**/vendor/**'
|
|
18
|
+
],
|
|
19
|
+
// coverageThreshold: {
|
|
20
|
+
// "global": {
|
|
21
|
+
// "branches": 100,
|
|
22
|
+
// "functions": 100,
|
|
23
|
+
// "lines": 100,
|
|
24
|
+
// "statements": 100
|
|
25
|
+
// }
|
|
26
|
+
// },
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datarailsshared/dr_renderer",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.236",
|
|
4
4
|
"description": "DataRails charts and tables renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datarails",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"tables"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"login": "npm login"
|
|
12
|
+
"login": "npm login",
|
|
13
|
+
"test": "jest --coverage"
|
|
13
14
|
},
|
|
14
15
|
"author": "Sergey Spivakov",
|
|
15
16
|
"repository": {
|
|
@@ -17,6 +18,21 @@
|
|
|
17
18
|
"url": "git+https://bitbucket.org/datarails/dr_renderer.git"
|
|
18
19
|
},
|
|
19
20
|
"license": "",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"jquery": "^3.6.0",
|
|
23
|
+
"lodash": "^4.17.20",
|
|
24
|
+
"regenerator-runtime": "^0.13.5"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@babel/core": "^7.20.12",
|
|
28
|
+
"@babel/preset-env": "^7.20.2",
|
|
29
|
+
"@testing-library/dom": "^7.2.1",
|
|
30
|
+
"@testing-library/jest-dom": "^5.5.0",
|
|
31
|
+
"babel-jest": "^25.5.1",
|
|
32
|
+
"jest": "^25.3.0",
|
|
33
|
+
"moment": "^2.29.1",
|
|
34
|
+
"serve": "^11.3.0"
|
|
35
|
+
},
|
|
20
36
|
"bugs": {
|
|
21
37
|
"url": ""
|
|
22
38
|
},
|
|
@@ -24,5 +40,10 @@
|
|
|
24
40
|
"whitelistedNonPeerDependencies": [],
|
|
25
41
|
"main": "src/index.js",
|
|
26
42
|
"module": "src/index.js",
|
|
27
|
-
"sideEffects": false
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"jest": {
|
|
45
|
+
"setupFiles": [
|
|
46
|
+
"./setup-jest.js"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
28
49
|
}
|
|
@@ -466,7 +466,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
466
466
|
highchartsRenderer.getOthersName(opts) :
|
|
467
467
|
undefined;
|
|
468
468
|
var drOthersInColumn = lodash.find(
|
|
469
|
-
pivotData.getColKeys(),
|
|
469
|
+
pivotData.getColKeys(),
|
|
470
470
|
keys => keys.length && (lodash.includes(keys, 'DR_Others') || lodash.includes(keys, othersName))
|
|
471
471
|
);
|
|
472
472
|
|
|
@@ -494,7 +494,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
494
494
|
if (!cols && is_drill_down_pie) {
|
|
495
495
|
cols = this.point.name;
|
|
496
496
|
}
|
|
497
|
-
|
|
497
|
+
|
|
498
498
|
if (drOthersInColumn) {
|
|
499
499
|
if (!lodash.isArray(cols) && othersName === cols) {
|
|
500
500
|
cols = ['DR_Others'];
|
|
@@ -619,6 +619,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
619
619
|
|
|
620
620
|
var func = function () {
|
|
621
621
|
const isWaterfallBreakdown = this.series.options.className === SERIES_CLASSNAMES.WATERFALL_BREAKDOWN;
|
|
622
|
+
const isTrendSeries = this.series.options.className === SERIES_CLASSNAMES.TREND_SERIES;
|
|
622
623
|
|
|
623
624
|
var y = parseFloat(this.y);
|
|
624
625
|
if (pivotData) {
|
|
@@ -629,7 +630,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
629
630
|
}
|
|
630
631
|
if (pivotData.rowAttrs.length == 0
|
|
631
632
|
|| this.series.options.className === 'totalSeries'
|
|
632
|
-
||
|
|
633
|
+
|| isTrendSeries) {
|
|
633
634
|
rows = [];
|
|
634
635
|
}
|
|
635
636
|
var cols = this.key;
|
|
@@ -664,7 +665,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
664
665
|
series_text += ': '
|
|
665
666
|
}
|
|
666
667
|
|
|
667
|
-
if (pivotData.rowAttrs.length == 0) {
|
|
668
|
+
if (pivotData.rowAttrs.length == 0 && !isTrendSeries) {
|
|
668
669
|
series_text = ': ';
|
|
669
670
|
}
|
|
670
671
|
|
|
@@ -672,13 +673,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
672
673
|
const modifiedRowsAndCols = highchartsRenderer.transformRowsAndColsForBreakdown(rows, cols, this.point, opts);
|
|
673
674
|
rows = modifiedRowsAndCols.rows;
|
|
674
675
|
cols = modifiedRowsAndCols.cols;
|
|
675
|
-
}
|
|
676
|
+
}
|
|
676
677
|
|
|
677
678
|
var aggr = pivotData.getAggregator(rows, cols);
|
|
678
679
|
|
|
679
680
|
let formatted_value_to_return = $.pivotUtilities.getFormattedNumber(y, null, opts);
|
|
680
681
|
if (aggr.value() || isWaterfallBreakdown) {
|
|
681
|
-
formatted_value_to_return = $.pivotUtilities.getFormattedNumber(
|
|
682
|
+
formatted_value_to_return = $.pivotUtilities.getFormattedNumber(
|
|
683
|
+
isWaterfallBreakdown || isTrendSeries ? y : aggr.value(), aggr, opts
|
|
684
|
+
);
|
|
682
685
|
}
|
|
683
686
|
|
|
684
687
|
let wrappedFormattedValue = highchartsRenderer.getSpanWrapper(formatted_value_to_return);
|
|
@@ -1034,7 +1037,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1034
1037
|
if (row_n_value && row_n_value.length > 0) {
|
|
1035
1038
|
ob.name = row_n_value.join(highchartsRenderer.delimer).replace('DR_Others', othersName);
|
|
1036
1039
|
}
|
|
1037
|
-
|
|
1038
1040
|
lodash.forEach(col_n_keys, function (col_n_value, index) {
|
|
1039
1041
|
var agg = pivotData.getAggregator(row_n_value, col_n_value);
|
|
1040
1042
|
var val = agg.value();
|
|
@@ -1085,7 +1087,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1085
1087
|
|
|
1086
1088
|
const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
|
|
1087
1089
|
trendSeries.className = 'trendSeries';
|
|
1088
|
-
trendSeries.name =
|
|
1090
|
+
trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
|
|
1089
1091
|
trendSeries.dashStyle = 'shortdot';
|
|
1090
1092
|
trendSeries.type = 'line';
|
|
1091
1093
|
trendSeries.data = trendSeries.data.map((el, index) => a + b * (index + 1));
|
|
@@ -1251,10 +1253,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1251
1253
|
if (opts.trendLine) {
|
|
1252
1254
|
const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
1253
1255
|
const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
1254
|
-
|
|
1255
1256
|
const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
|
|
1256
1257
|
trendSeries.className = 'trendSeries';
|
|
1257
|
-
trendSeries.name =
|
|
1258
|
+
trendSeries.name = highchartsRenderer.getTrendSeriesName(trendSeries);
|
|
1258
1259
|
trendSeries.dashStyle = 'shortdot';
|
|
1259
1260
|
trendSeries.type = 'line';
|
|
1260
1261
|
trendSeries.data = trendSeries.data.map((data, index) => ({name: data.name, y: a + b * (index + 1)}));
|
|
@@ -1262,7 +1263,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1262
1263
|
if (colors && colors[i]) {
|
|
1263
1264
|
trendSeries.color = colors[i];
|
|
1264
1265
|
}
|
|
1265
|
-
|
|
1266
1266
|
trendSerieses.push(trendSeries);
|
|
1267
1267
|
}
|
|
1268
1268
|
i++;
|
|
@@ -1279,7 +1279,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1279
1279
|
}
|
|
1280
1280
|
|
|
1281
1281
|
let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
|
|
1282
|
-
|
|
1283
1282
|
if (opts.comboOptions && lodash.includes(chartType,'combo') && !lodash.isEqual(row_n_keys, EMPTY_ROW_N_KEYS)) {
|
|
1284
1283
|
chart_series.forEach((series, seriesIndex) => {
|
|
1285
1284
|
const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
|
|
@@ -1617,7 +1616,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1617
1616
|
highchartsRenderer.getDataLabelsStylesForDrillDown = function(additionOptions) {
|
|
1618
1617
|
let result = highchartsRenderer.getDataLabelsOptions(additionOptions, { dataLabels: {} });
|
|
1619
1618
|
|
|
1620
|
-
if (!result.dataLabels) return {};
|
|
1619
|
+
if (!result.dataLabels) return {};
|
|
1621
1620
|
return {
|
|
1622
1621
|
activeDataLabelStyle: {
|
|
1623
1622
|
color: result.dataLabels.color,
|
|
@@ -3173,7 +3172,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
3173
3172
|
|
|
3174
3173
|
highchartsRenderer.ptRenderWaterfallBreakdown = function (pivotData, opts, drilldownFunc, chartType) {
|
|
3175
3174
|
let chartOptions = {};
|
|
3176
|
-
const additionOptions = opts.chartOptions
|
|
3175
|
+
const additionOptions = opts.chartOptions
|
|
3177
3176
|
? opts.chartOptions
|
|
3178
3177
|
: highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN);
|
|
3179
3178
|
|
|
@@ -5101,102 +5100,34 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5101
5100
|
|
|
5102
5101
|
highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions) {
|
|
5103
5102
|
highchartsRenderer.setWidgetFieldsToTemplate(selectedTemplate);
|
|
5103
|
+
|
|
5104
|
+
const scenarioName = 'scenario';
|
|
5104
5105
|
const fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.fields);
|
|
5106
|
+
const fieldScenarioAlias = _.find(fields, field => (field.alias || '').toLowerCase() === scenarioName)
|
|
5107
|
+
const fieldScenario = _.find(fields, field => (field.name || '').toLowerCase() === scenarioName)
|
|
5108
|
+
const filters = calcModelOptions.config && calcModelOptions.config.filters;
|
|
5109
|
+
|
|
5110
|
+
const filterFields = [];
|
|
5111
|
+
const valueFields = [];
|
|
5112
|
+
const dateFields = [];
|
|
5113
|
+
const dataTypeFields = [];
|
|
5114
|
+
const dataSeriesFields = [];
|
|
5115
|
+
|
|
5116
|
+
let scenarioField = lodash.get(calcModelOptions, 'config.scenario', undefined) || fieldScenarioAlias || fieldScenario;
|
|
5117
|
+
let fieldOb;
|
|
5105
5118
|
|
|
5106
|
-
const fillData = (fieldsArr,
|
|
5107
|
-
const destinationArr = [];
|
|
5119
|
+
const fillData = (fieldsArr, destinationArr) => {
|
|
5108
5120
|
lodash.forEach(fieldsArr, function (valObj) {
|
|
5109
|
-
|
|
5121
|
+
fieldOb = lodash.find(fields, { id: valObj.id });
|
|
5110
5122
|
if (fieldOb) {
|
|
5111
5123
|
destinationArr.push(fieldOb);
|
|
5112
|
-
|
|
5124
|
+
lodash.remove(fields, { id: fieldOb.id });
|
|
5113
5125
|
}
|
|
5114
5126
|
});
|
|
5115
|
-
|
|
5116
|
-
return destinationArr;
|
|
5117
5127
|
}
|
|
5118
5128
|
|
|
5119
|
-
const canAssignPredefinedField = (() => {
|
|
5120
|
-
const assignedFields = {};
|
|
5121
|
-
|
|
5122
|
-
return function (predefinedData, type, field, bindValue, oppositeValue) {
|
|
5123
|
-
if (!assignedFields[type]) {
|
|
5124
|
-
assignedFields[type] = [];
|
|
5125
|
-
}
|
|
5126
|
-
|
|
5127
|
-
const isFieldMatch = predefinedData.regex.test((field[bindValue] || ''));
|
|
5128
|
-
|
|
5129
|
-
const isFieldTypeCorrect = predefinedData.allowedFieldTypes
|
|
5130
|
-
? predefinedData.allowedFieldTypes.includes(field.type) : true;
|
|
5131
|
-
|
|
5132
|
-
const isFieldAssigned = assignedFields[type].includes(field[bindValue].toLowerCase())
|
|
5133
|
-
|| assignedFields[type].includes(field[oppositeValue].toLowerCase());
|
|
5134
|
-
|
|
5135
|
-
if (!(isFieldMatch && isFieldTypeCorrect)) return false;
|
|
5136
|
-
|
|
5137
|
-
const loweredFieldValue = field[bindValue].toLowerCase();
|
|
5138
|
-
assignedFields[type].push(loweredFieldValue, loweredFieldValue.replaceAll('_', ' '));
|
|
5139
|
-
|
|
5140
|
-
return !isFieldAssigned;
|
|
5141
|
-
}
|
|
5142
|
-
})();
|
|
5143
|
-
|
|
5144
|
-
const predefinedField = {
|
|
5145
|
-
value: {
|
|
5146
|
-
regex: /posting[_\s]amount/i,
|
|
5147
|
-
allowedFieldTypes: ['Float', 'Integer'],
|
|
5148
|
-
fields: [],
|
|
5149
|
-
},
|
|
5150
|
-
dataType: {
|
|
5151
|
-
regex: /data[_\s]type/i,
|
|
5152
|
-
allowedFieldTypes: ['Text'],
|
|
5153
|
-
fields: [],
|
|
5154
|
-
},
|
|
5155
|
-
date: {
|
|
5156
|
-
regex: /reporting[_\s]month/i,
|
|
5157
|
-
allowedFieldTypes: ['Date'],
|
|
5158
|
-
fields: [],
|
|
5159
|
-
},
|
|
5160
|
-
filters: {
|
|
5161
|
-
isMultipleFields: true,
|
|
5162
|
-
regex: /^(scenario|DR_ACC_L0)$/i,
|
|
5163
|
-
fields: [],
|
|
5164
|
-
},
|
|
5165
|
-
dataSeries: {
|
|
5166
|
-
isMultipleFields: true,
|
|
5167
|
-
regex: /^(scenario|account[_\s]full|entity|intercompany|posting[_\s]currency|reporting[_\s]currency|report[_\s]field|USER_TO_DR_ACC_KEY|USER_TO_DR_KPI_KEY)$/i,
|
|
5168
|
-
fields: [],
|
|
5169
|
-
},
|
|
5170
|
-
};
|
|
5171
|
-
|
|
5172
|
-
if (!lodash.get(calcModelOptions, 'config', false)) {
|
|
5173
|
-
/**
|
|
5174
|
-
* alias stronger than name (order in array is important)
|
|
5175
|
-
* Firstly we try to get predefined field by aliases and then fill in by names
|
|
5176
|
-
* */
|
|
5177
|
-
const fieldsDataQueueConfig = [
|
|
5178
|
-
{ value: 'alias', opposite: 'name' },
|
|
5179
|
-
{ value: 'name', opposite: 'alias' }
|
|
5180
|
-
];
|
|
5181
|
-
|
|
5182
|
-
for (const key in predefinedField) {
|
|
5183
|
-
lodash.forEach(fieldsDataQueueConfig, ({value, opposite}) => {
|
|
5184
|
-
const ignoredFields = predefinedField[key].ignoreAssignedFields;
|
|
5185
|
-
const result = predefinedField[key].isMultipleFields
|
|
5186
|
-
? lodash.filter(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))
|
|
5187
|
-
: [lodash.find(fields, field => canAssignPredefinedField(predefinedField[key], key, field, value, opposite, ignoredFields))].filter(f => !!f);
|
|
5188
|
-
|
|
5189
|
-
if (result && result.length) {
|
|
5190
|
-
predefinedField[key].fields.push(...result);
|
|
5191
|
-
}
|
|
5192
|
-
});
|
|
5193
|
-
}
|
|
5194
|
-
}
|
|
5195
|
-
|
|
5196
|
-
const filters = lodash.get(calcModelOptions, 'config.filters', predefinedField.filters.fields);
|
|
5197
|
-
|
|
5198
5129
|
lodash.forEach(filters, function (filterObj) {
|
|
5199
|
-
|
|
5130
|
+
fieldOb = lodash.find(fields, { id: filterObj.id });
|
|
5200
5131
|
if (!fieldOb) return;
|
|
5201
5132
|
|
|
5202
5133
|
filterObj.values = filterObj.values && lodash.map(filterObj.values, highchartsRenderer.decodeFunc);
|
|
@@ -5214,23 +5145,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5214
5145
|
}
|
|
5215
5146
|
});
|
|
5216
5147
|
|
|
5217
|
-
const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by',
|
|
5218
|
-
const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field',
|
|
5219
|
-
const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field',
|
|
5220
|
-
const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field',
|
|
5221
|
-
const scenarioField = lodash.get(calcModelOptions, 'config.scenario', lodash.find(predefinedField.filters.fields, filter => [filter.name, filter.alias].includes('scenario')));
|
|
5222
|
-
|
|
5223
|
-
/**
|
|
5224
|
-
* We can have several common fields, so we should ignore deleting during fillData
|
|
5225
|
-
* */
|
|
5226
|
-
const commonFieldsId = [scenarioField.id];
|
|
5227
|
-
const filterFields = fillData(filters, commonFieldsId);
|
|
5228
|
-
const valueFields = fillData(storedAggFields, commonFieldsId);
|
|
5229
|
-
const dateFields = fillData(storedDateFields, commonFieldsId);
|
|
5230
|
-
const dataTypeFields = fillData(storedDataTypeFields, commonFieldsId);
|
|
5231
|
-
const dataSeriesFields = fillData(storedGroupByFields, commonFieldsId);
|
|
5148
|
+
const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', []);
|
|
5149
|
+
const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', undefined)].filter(f => !!f);
|
|
5150
|
+
const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', undefined)].filter(f => !!f);
|
|
5151
|
+
const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', undefined)].filter(f => !!f);
|
|
5232
5152
|
|
|
5233
|
-
|
|
5153
|
+
fillData(storedGroupByFields, dataSeriesFields);
|
|
5154
|
+
fillData(storedDateFields, dateFields);
|
|
5155
|
+
fillData(storedAggFields, valueFields);
|
|
5156
|
+
fillData(storedDataTypeFields, dataTypeFields);
|
|
5157
|
+
fillData(filters, filterFields);
|
|
5234
5158
|
|
|
5235
5159
|
calcModelOptions.pivot = {
|
|
5236
5160
|
fieldsArray: fields,
|
|
@@ -5738,7 +5662,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5738
5662
|
return valToReturn;
|
|
5739
5663
|
};
|
|
5740
5664
|
|
|
5741
|
-
|
|
5665
|
+
|
|
5742
5666
|
highchartsRenderer.getChartAxisLabel = function(type) {
|
|
5743
5667
|
return highchartsRenderer.chartsTypesInfo[type] ? highchartsRenderer.chartsTypesInfo[type].axisName : CHART_AXIS_DEFAULT_LABEL;
|
|
5744
5668
|
};
|
|
@@ -6573,7 +6497,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6573
6497
|
value_name: 'show',
|
|
6574
6498
|
default_value: true,
|
|
6575
6499
|
disabled_str: '!{var}.show_out_of_x_axis && !{var}.show_out_of_data_series && !{var}.show_value && !{var}.show_x_axis && !{var}.show_data_series',
|
|
6576
|
-
disabled_fn: (value) => !value.show_out_of_x_axis
|
|
6500
|
+
disabled_fn: (value) => !value.show_out_of_x_axis
|
|
6577
6501
|
&& !value.show_out_of_data_series
|
|
6578
6502
|
&& !value.show_value
|
|
6579
6503
|
&& !value.show_x_axis
|
|
@@ -6614,8 +6538,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6614
6538
|
element_label: '[X Axis]',
|
|
6615
6539
|
value_name: 'show_x_axis',
|
|
6616
6540
|
default_value: true,
|
|
6617
|
-
clickFn: (value) => value.show = value.show
|
|
6618
|
-
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6541
|
+
clickFn: (value) => value.show = value.show
|
|
6542
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6619
6543
|
: value.show,
|
|
6620
6544
|
},
|
|
6621
6545
|
{
|
|
@@ -6623,8 +6547,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6623
6547
|
element_label: '[Data Series]',
|
|
6624
6548
|
value_name: 'show_data_series',
|
|
6625
6549
|
default_value: true,
|
|
6626
|
-
clickFn: (value) => value.show = value.show
|
|
6627
|
-
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6550
|
+
clickFn: (value) => value.show = value.show
|
|
6551
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6628
6552
|
: value.show,
|
|
6629
6553
|
},
|
|
6630
6554
|
{
|
|
@@ -6632,8 +6556,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6632
6556
|
element_label: 'Value',
|
|
6633
6557
|
value_name: 'show_value',
|
|
6634
6558
|
default_value: true,
|
|
6635
|
-
clickFn: (value) => value.show = value.show
|
|
6636
|
-
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6559
|
+
clickFn: (value) => value.show = value.show
|
|
6560
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6637
6561
|
: value.show,
|
|
6638
6562
|
},
|
|
6639
6563
|
{
|
|
@@ -6641,8 +6565,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6641
6565
|
element_label: '% Out of [X Axis]',
|
|
6642
6566
|
value_name: 'show_out_of_x_axis',
|
|
6643
6567
|
default_value: false,
|
|
6644
|
-
clickFn: (value) => value.show = value.show
|
|
6645
|
-
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6568
|
+
clickFn: (value) => value.show = value.show
|
|
6569
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6646
6570
|
: value.show,
|
|
6647
6571
|
},
|
|
6648
6572
|
{
|
|
@@ -6650,8 +6574,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6650
6574
|
element_label: '% Out of [Data Series]',
|
|
6651
6575
|
value_name: 'show_out_of_data_series',
|
|
6652
6576
|
default_value: false,
|
|
6653
|
-
clickFn: (value) => value.show = value.show
|
|
6654
|
-
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6577
|
+
clickFn: (value) => value.show = value.show
|
|
6578
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value || value.show_x_axis || value.show_data_series
|
|
6655
6579
|
: value.show,
|
|
6656
6580
|
},
|
|
6657
6581
|
]
|
|
@@ -6957,7 +6881,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6957
6881
|
axisTooltipDescription: 'The category (usually an independent variable) is shown on the x-axis and should be between 2 to 5 total columns. ',
|
|
6958
6882
|
legendTooltipTitle: 'Drag one field to further configure your x-axis.',
|
|
6959
6883
|
legendTooltipDescription: 'The breakdown subdivides the chart by a category field for further analysis of what’s contributing to the increase or decrease.',
|
|
6960
|
-
},
|
|
6884
|
+
},
|
|
6961
6885
|
'combo-chart': {
|
|
6962
6886
|
name: 'Combo Chart ',
|
|
6963
6887
|
label: 'Combo Chart ',
|
|
@@ -7769,7 +7693,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
7769
7693
|
_.forEach(Object.keys(dates), key => {
|
|
7770
7694
|
const dateConfiguration = dates[key];
|
|
7771
7695
|
const timestamp = dateConfiguration.timestamp;
|
|
7772
|
-
if (timestamp) {
|
|
7696
|
+
if (timestamp) {
|
|
7773
7697
|
const dateTzOffsetInSeconds = new Date(timestamp * 1000).getTimezoneOffset() * 60;
|
|
7774
7698
|
dateConfiguration.displayedValue = new Date((timestamp + dateTzOffsetInSeconds) * 1000)
|
|
7775
7699
|
.toLocaleDateString();
|
|
@@ -8068,7 +7992,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8068
7992
|
if (!(format && highchartsRenderer.isDateFormat(dateString, format) || highchartsRenderer.isDate(dateString))) {
|
|
8069
7993
|
return null;
|
|
8070
7994
|
}
|
|
8071
|
-
const utcDate = format
|
|
7995
|
+
const utcDate = format
|
|
8072
7996
|
? moment_lib.utc(dateString, format, true)
|
|
8073
7997
|
: moment_lib.utc(dateString);
|
|
8074
7998
|
return utcDate.startOf('day').unix();
|
|
@@ -8086,7 +8010,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8086
8010
|
}
|
|
8087
8011
|
|
|
8088
8012
|
let filters = [];
|
|
8089
|
-
|
|
8013
|
+
|
|
8090
8014
|
if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
|
|
8091
8015
|
const colFilter = highchartsRenderer.createFilterObject(widget.cols[0]);
|
|
8092
8016
|
const labels = [];
|
|
@@ -8114,7 +8038,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8114
8038
|
col_value,
|
|
8115
8039
|
highchartsRenderer.getDateFieldFormat(widget, widget.cols[index])
|
|
8116
8040
|
);
|
|
8117
|
-
|
|
8041
|
+
|
|
8118
8042
|
if ($.isEmptyObject(datetrange)) {
|
|
8119
8043
|
return;
|
|
8120
8044
|
}
|
|
@@ -8785,7 +8709,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8785
8709
|
}
|
|
8786
8710
|
|
|
8787
8711
|
highchartsRenderer.getDateFieldFormat = function(widget, dateField) {
|
|
8788
|
-
const aggregationConfig = widget.options && widget.options.date_aggregation_configs
|
|
8712
|
+
const aggregationConfig = widget.options && widget.options.date_aggregation_configs
|
|
8789
8713
|
? _.find(widget.options.date_aggregation_configs, { field_id: dateField.id })
|
|
8790
8714
|
: null;
|
|
8791
8715
|
|
|
@@ -8835,6 +8759,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8835
8759
|
}
|
|
8836
8760
|
}
|
|
8837
8761
|
|
|
8762
|
+
highchartsRenderer.getTrendSeriesName = function(series) {
|
|
8763
|
+
return series.name ? 'Trend Line (' + series.name + ')' : 'Trend Line';
|
|
8764
|
+
}
|
|
8765
|
+
|
|
8838
8766
|
return highchartsRenderer;
|
|
8839
8767
|
};
|
|
8840
8768
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as $ from 'jquery';
|
|
2
|
+
import * as lodash from 'lodash';
|
|
3
|
+
import * as moment from 'moment';
|
|
4
|
+
import initPivotTable from "../src/pivottable";
|
|
5
|
+
import initDRPivotTable from "../src/dr_pivottable";
|
|
6
|
+
|
|
7
|
+
const getHighchartsRenderer = require('../src/highcharts_renderer');
|
|
8
|
+
const DataFormatter = require('../src/dataformatter');
|
|
9
|
+
const DEFAULT_USER_COLORS = {
|
|
10
|
+
colors: ['#008aff', '#91e7e7', '#f37789', '#ffdc65', '#0e569d', '#bbe0ff', '#57b2ff', '#5ecfb9', '#c7ffda', '#179ab9'],
|
|
11
|
+
variance_color: null
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
let highchartsRenderer = {};
|
|
15
|
+
let _window = window;
|
|
16
|
+
let _document = document;
|
|
17
|
+
|
|
18
|
+
describe('highcharts_renderer', () => {
|
|
19
|
+
beforeAll(() => {
|
|
20
|
+
const Highcharts = {
|
|
21
|
+
opt: {},
|
|
22
|
+
setOptions: function(value) {Highcharts.opt = value;},
|
|
23
|
+
numberFormat: function(value) { return value ;},
|
|
24
|
+
getOptions: function() { return Highcharts.opt; }
|
|
25
|
+
};
|
|
26
|
+
_window.DataFormatter = DataFormatter;
|
|
27
|
+
initPivotTable($, _window, _document);
|
|
28
|
+
initDRPivotTable($, _window, _document);
|
|
29
|
+
|
|
30
|
+
highchartsRenderer = getHighchartsRenderer($, _document, Highcharts, DEFAULT_USER_COLORS, highchartsRenderer,
|
|
31
|
+
DataFormatter, lodash, moment, true)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('function isSystemField', () => {
|
|
35
|
+
it('system name', () => {
|
|
36
|
+
const field = {
|
|
37
|
+
name: 'Doc_ID'
|
|
38
|
+
};
|
|
39
|
+
expect(highchartsRenderer.isSystemField(field)).toBe(true)
|
|
40
|
+
});
|
|
41
|
+
it('not system name', () => {
|
|
42
|
+
const field = {
|
|
43
|
+
name: 'field name'
|
|
44
|
+
};
|
|
45
|
+
expect(highchartsRenderer.isSystemField(field)).toBe(false)
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|