@datarailsshared/dr_renderer 1.2.56 → 1.2.57
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/package.json +1 -1
- package/src/highcharts_renderer.js +46 -29
package/package.json
CHANGED
|
@@ -909,6 +909,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
909
909
|
var variat_serias = null;
|
|
910
910
|
const n = col_n_keys.length;
|
|
911
911
|
const xSum = (1 + n) / 2 * n;
|
|
912
|
+
const trendSerieses = [];
|
|
912
913
|
|
|
913
914
|
lodash.forEach(row_n_keys, function (row_n_value) {
|
|
914
915
|
var ob = {};
|
|
@@ -973,11 +974,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
973
974
|
trendSeries.color = colors[i];
|
|
974
975
|
}
|
|
975
976
|
|
|
976
|
-
|
|
977
|
+
trendSerieses.push(trendSeries);
|
|
977
978
|
}
|
|
978
979
|
|
|
979
980
|
i++;
|
|
980
981
|
});
|
|
982
|
+
const ethalonSeries = chart_series[chart_series.length - 1];
|
|
981
983
|
|
|
982
984
|
if (has_delta && additionOptions && additionOptions.delta_column.only_variant) {
|
|
983
985
|
if (variat_serias)
|
|
@@ -996,10 +998,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
996
998
|
}
|
|
997
999
|
}
|
|
998
1000
|
|
|
999
|
-
|
|
1001
|
+
chart_series = [...chart_series, ...trendSerieses]
|
|
1000
1002
|
|
|
1001
1003
|
if (opts.total) {
|
|
1002
|
-
const newSeries = lodash.clone(
|
|
1004
|
+
const newSeries = lodash.clone(ethalonSeries);
|
|
1005
|
+
if (opts.totalSeriesSettings) {
|
|
1006
|
+
newSeries.yAxis = opts.totalSeriesSettings.secondaryAxis ? 1 : undefined;
|
|
1007
|
+
}
|
|
1003
1008
|
newSeries.name = 'Total';
|
|
1004
1009
|
newSeries.data = [];
|
|
1005
1010
|
col_n_keys.forEach(columnKey => {
|
|
@@ -1013,6 +1018,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1013
1018
|
chart_series.push(newSeries);
|
|
1014
1019
|
}
|
|
1015
1020
|
|
|
1021
|
+
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded(chart_series, pivotData, chartOptions, additionOptions, opts, opts.total && opts.totalSeriesSettings && opts.totalSeriesSettings.secondaryAxis);
|
|
1022
|
+
|
|
1016
1023
|
return chart_series;
|
|
1017
1024
|
};
|
|
1018
1025
|
|
|
@@ -1033,6 +1040,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1033
1040
|
var variat_serias = null;
|
|
1034
1041
|
const n = col_n_keys.length;
|
|
1035
1042
|
const xSum = (1 + n) / 2 * n;
|
|
1043
|
+
const trendSerieses = [];
|
|
1036
1044
|
|
|
1037
1045
|
lodash.forEach(row_n_keys, function (row_n_value) {
|
|
1038
1046
|
let ySum = 0;
|
|
@@ -1101,6 +1109,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1101
1109
|
|
|
1102
1110
|
chart_series.push(ob);
|
|
1103
1111
|
|
|
1112
|
+
|
|
1104
1113
|
if (opts.trendLine) {
|
|
1105
1114
|
const a = ((ySum * squareXSum) - (xSum * xySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
1106
1115
|
const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
|
|
@@ -1115,11 +1124,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1115
1124
|
trendSeries.color = colors[i];
|
|
1116
1125
|
}
|
|
1117
1126
|
|
|
1118
|
-
|
|
1127
|
+
trendSerieses.push(trendSeries);
|
|
1119
1128
|
}
|
|
1120
1129
|
i++;
|
|
1121
1130
|
});
|
|
1122
1131
|
|
|
1132
|
+
const ethalonSeries = chart_series[chart_series.length - 1];
|
|
1133
|
+
|
|
1123
1134
|
if (has_delta && additionOptions.delta_column.only_variant) {
|
|
1124
1135
|
if (variat_serias)
|
|
1125
1136
|
return [variat_serias];
|
|
@@ -1128,42 +1139,30 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1128
1139
|
}
|
|
1129
1140
|
}
|
|
1130
1141
|
|
|
1131
|
-
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded(chart_series, pivotData, chartOptions, additionOptions, opts);
|
|
1132
|
-
|
|
1133
1142
|
let weights = { line: 2,spline: 3 ,area:-2, areaspline: -1, scatter:4, column: 1 };
|
|
1134
1143
|
|
|
1135
1144
|
if (opts.comboOptions && chartType.includes('combo')) {
|
|
1136
1145
|
chart_series.forEach((series, seriesIndex) => {
|
|
1137
1146
|
const savedSeriesOption = lodash.find(opts.comboOptions.seriesOptions, {series: series.name});
|
|
1138
1147
|
if (savedSeriesOption) {
|
|
1139
|
-
|
|
1140
|
-
case 'line-chart':
|
|
1141
|
-
series.type = 'line';
|
|
1142
|
-
break;
|
|
1143
|
-
case 'line-chart-smooth':
|
|
1144
|
-
series.type = 'spline';
|
|
1145
|
-
break;
|
|
1146
|
-
case 'area-chart':
|
|
1147
|
-
series.type = 'area';
|
|
1148
|
-
break;
|
|
1149
|
-
case 'area-chart-smooth':
|
|
1150
|
-
series.type = 'areaspline';
|
|
1151
|
-
break;
|
|
1152
|
-
case 'scatter-chart':
|
|
1153
|
-
series.type = 'scatter';
|
|
1154
|
-
break;
|
|
1155
|
-
case 'column-chart' || 'column-chart-stacked':
|
|
1156
|
-
delete series.type;
|
|
1157
|
-
break;
|
|
1158
|
-
}
|
|
1148
|
+
highchartsRenderer.setChartTypeBySeriesType(savedSeriesOption.chartType, series);
|
|
1159
1149
|
} else if (seriesIndex === chart_series.length - 1 && !has_delta) {
|
|
1160
1150
|
series.type = 'line';
|
|
1161
1151
|
}
|
|
1162
1152
|
});
|
|
1163
1153
|
}
|
|
1164
1154
|
|
|
1155
|
+
chart_series = [...chart_series, ...trendSerieses]
|
|
1156
|
+
|
|
1165
1157
|
if (opts.total) {
|
|
1166
|
-
const totalSeries = lodash.clone(
|
|
1158
|
+
const totalSeries = lodash.clone(ethalonSeries);
|
|
1159
|
+
if (opts.totalSeriesSettings) {
|
|
1160
|
+
if (chartType.includes('combo')) {
|
|
1161
|
+
highchartsRenderer.setChartTypeBySeriesType(opts.totalSeriesSettings.chartType, totalSeries);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
totalSeries.yAxis = opts.totalSeriesSettings.secondaryAxis ? 1 : undefined;
|
|
1165
|
+
}
|
|
1167
1166
|
totalSeries.name = 'Total';
|
|
1168
1167
|
totalSeries.data = [];
|
|
1169
1168
|
col_n_keys.forEach(columnKey => {
|
|
@@ -1179,6 +1178,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1179
1178
|
chart_series.push(totalSeries);
|
|
1180
1179
|
}
|
|
1181
1180
|
|
|
1181
|
+
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded(chart_series, pivotData, chartOptions, additionOptions, opts, opts.total && opts.totalSeriesSettings && opts.totalSeriesSettings.secondaryAxis);
|
|
1182
|
+
|
|
1182
1183
|
chart_series.sort((a,b) => {
|
|
1183
1184
|
return (weights[a.type] || 0) > (weights[b.type] || 0) ? 1 : (weights[a.type] || 0) < (weights[b.type] || 0) ? -1 : 0
|
|
1184
1185
|
});
|
|
@@ -1186,6 +1187,22 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1186
1187
|
return chart_series;
|
|
1187
1188
|
}
|
|
1188
1189
|
|
|
1190
|
+
highchartsRenderer.setChartTypeBySeriesType = function (type, series) {
|
|
1191
|
+
const types = {
|
|
1192
|
+
'line-chart': 'line',
|
|
1193
|
+
'line-chart-smooth': 'spline',
|
|
1194
|
+
'area-chart': 'area',
|
|
1195
|
+
'area-chart-smooth': 'areaspline',
|
|
1196
|
+
'scatter-chart': 'scatter',
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
if (type === 'column-chart' || type === 'column-chart-stacked') {
|
|
1200
|
+
delete series.type;
|
|
1201
|
+
} else {
|
|
1202
|
+
series.type = types[type]
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1189
1206
|
highchartsRenderer.getVariantSeries = function (series, delta_column_options) {
|
|
1190
1207
|
const varianceColor = delta_column_options.color || highchartsRenderer.variance_color || Highcharts.getOptions().colors[7];
|
|
1191
1208
|
series.name = delta_column_options.name.replace('_', '');
|
|
@@ -1357,7 +1374,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1357
1374
|
});
|
|
1358
1375
|
};
|
|
1359
1376
|
|
|
1360
|
-
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded = function(chartSeries, pivotData, chartOptions, additionOptions, opts) {
|
|
1377
|
+
highchartsRenderer.moveSeriesToSecondYAxisIfNeeded = function(chartSeries, pivotData, chartOptions, additionOptions, opts, forceAddSecondaryAxis) {
|
|
1361
1378
|
if (!opts || !opts.comboOptions) {
|
|
1362
1379
|
return;
|
|
1363
1380
|
}
|
|
@@ -1373,7 +1390,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
1373
1390
|
}
|
|
1374
1391
|
});
|
|
1375
1392
|
|
|
1376
|
-
if (addSecondYAxis) {
|
|
1393
|
+
if (addSecondYAxis || forceAddSecondaryAxis) {
|
|
1377
1394
|
highchartsRenderer.addSecondYAxis(pivotData, chartOptions, additionOptions, opts);
|
|
1378
1395
|
}
|
|
1379
1396
|
}
|