@datarailsshared/dr_renderer 1.2.418 → 1.2.420
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
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* @typedef {Object} HighChartsRenderer
|
3
|
-
* @property {(rows: Rows, options: GTROptions, isTable: boolean, widget: any, pivotModel?: PivotModel) => string} rhPivotViewV2
|
3
|
+
* @property {(rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => string} rhPivotViewV2
|
4
4
|
*/
|
5
5
|
|
6
6
|
/**
|
@@ -17,8 +17,14 @@
|
|
17
17
|
* @typedef {Object} PivotModel
|
18
18
|
*/
|
19
19
|
|
20
|
+
/**
|
21
|
+
* @typedef {Object} RendererOptions
|
22
|
+
* @property {any} hcInstance
|
23
|
+
*/
|
24
|
+
|
20
25
|
/**
|
21
26
|
* @typedef {Object} GTROptions
|
27
|
+
* @property {RendererOptions} rendererOptions
|
22
28
|
*/
|
23
29
|
|
24
30
|
/**
|
@@ -58,6 +64,11 @@ export class GraphTableRenderer {
|
|
58
64
|
*/
|
59
65
|
#pivotUtilities;
|
60
66
|
|
67
|
+
/**
|
68
|
+
* @type {any | null}
|
69
|
+
*/
|
70
|
+
#hcInstance = null;
|
71
|
+
|
61
72
|
/**
|
62
73
|
*
|
63
74
|
* @param {HighChartsRenderer} hcr
|
@@ -97,12 +108,39 @@ export class GraphTableRenderer {
|
|
97
108
|
return this.#pivotModel;
|
98
109
|
}
|
99
110
|
|
111
|
+
/**
|
112
|
+
* @description returns Chart instance of HighCharts library
|
113
|
+
* @returns {any | null}
|
114
|
+
*/
|
115
|
+
hcInstance() {
|
116
|
+
return this.#hcInstance;
|
117
|
+
}
|
118
|
+
|
119
|
+
#setHcInstance() {
|
120
|
+
if (!this.#options) {
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
this.#hcInstance = this.#options.rendererOptions.hcInstance;
|
124
|
+
if (!this.#hcInstance) {
|
125
|
+
console.warn('[dr_renderer] HighCharts instance not found in options after the chart is rendered.');
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* hcInstance object is not needed in options after the chart is rendered - it's an internal object of HighCharts library
|
129
|
+
* Deleting to not supply it to widget object, so it cannot be used anywhere else
|
130
|
+
*/
|
131
|
+
delete this.#options.rendererOptions.hcInstance;
|
132
|
+
}
|
133
|
+
|
100
134
|
renderTable(widget = null) {
|
101
|
-
return this.#hcr.rhPivotViewV2(this.#rows, this.#options
|
135
|
+
return this.#hcr.rhPivotViewV2(this.#rows, this.#options, true, widget, this.#pivotModel);
|
102
136
|
}
|
103
137
|
|
104
138
|
renderChart(widget = null) {
|
105
|
-
|
139
|
+
const chart = this.#hcr.rhPivotViewV2(this.#rows, this.#options, false, widget, this.#pivotModel);
|
140
|
+
setTimeout(() => {
|
141
|
+
this.#setHcInstance();
|
142
|
+
});
|
143
|
+
return chart;
|
106
144
|
}
|
107
145
|
}
|
108
146
|
|
@@ -346,7 +346,24 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
346
346
|
},
|
347
347
|
exporting: {
|
348
348
|
enabled: false,
|
349
|
-
sourceWidth: 900
|
349
|
+
sourceWidth: 900,
|
350
|
+
chartOptions: {
|
351
|
+
chart: {
|
352
|
+
events: {
|
353
|
+
load: function () {
|
354
|
+
const chart = this;
|
355
|
+
chart.renderer.definition({
|
356
|
+
tagName: 'style',
|
357
|
+
textContent: `
|
358
|
+
.highcharts-xaxis-grid > .highcharts-grid-line {
|
359
|
+
stroke: none;
|
360
|
+
}
|
361
|
+
`,
|
362
|
+
});
|
363
|
+
},
|
364
|
+
},
|
365
|
+
},
|
366
|
+
},
|
350
367
|
},
|
351
368
|
drilldown: {
|
352
369
|
activeAxisLabelStyle: {
|
@@ -473,18 +490,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
473
490
|
return chart_option;
|
474
491
|
}
|
475
492
|
|
493
|
+
/**
|
494
|
+
* @deprecated For new angular just use hcInstance
|
495
|
+
*/
|
476
496
|
highchartsRenderer.downloadFile = function (title, graph_id, type) {
|
477
497
|
let chart = null;
|
478
498
|
|
479
499
|
const chartElement = $('#' + graph_id).find('div.chart');
|
480
500
|
if (chartElement.highcharts) {
|
501
|
+
// old angular
|
481
502
|
chart = chartElement.highcharts();
|
482
|
-
} else {
|
483
|
-
const graphIdString = graph_id.split('_')[1];
|
484
|
-
const graphId = Number(graphIdString) || graphIdString;
|
485
|
-
chart = lodash.findLast(Highcharts.charts, function(value) {
|
486
|
-
return value.options.widgetId === graphId;
|
487
|
-
});
|
488
503
|
}
|
489
504
|
|
490
505
|
if (!chart) return;
|
@@ -1090,19 +1105,25 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1090
1105
|
chartOptions = highchartsRenderer.updateChartOptions(chartOptions, opts);
|
1091
1106
|
chartOptions = highchartsRenderer.updateChartOptions(chartOptions, {credits: {enabled: false}});
|
1092
1107
|
result = $("<div>").addClass("chart");
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1108
|
+
|
1109
|
+
// old angular
|
1110
|
+
if (result.highcharts) {
|
1111
|
+
setTimeout(() => {
|
1096
1112
|
result.highcharts(chartOptions);
|
1097
|
-
chart = result.highcharts();
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1113
|
+
const chart = result.highcharts();
|
1114
|
+
if (opts && opts.testChart) {
|
1115
|
+
opts.testChart.chart = chart;
|
1116
|
+
}
|
1117
|
+
});
|
1118
|
+
} else {
|
1119
|
+
// new angular
|
1120
|
+
setTimeout(() => {
|
1121
|
+
const chart = Highcharts.chart(result[0], chartOptions);
|
1122
|
+
if (opts) {
|
1123
|
+
opts.hcInstance = chart;
|
1124
|
+
}
|
1125
|
+
});
|
1126
|
+
}
|
1106
1127
|
}
|
1107
1128
|
return result;
|
1108
1129
|
};
|
@@ -4612,26 +4633,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4612
4633
|
highchartsRenderer.sanitizeOptions(opts);
|
4613
4634
|
options.rendererOptions.labelsConvertFunction = highchartsRenderer.getFieldNameForTable(options);
|
4614
4635
|
opts.isTable = isTable;
|
4615
|
-
if (isTable == true && options.rendererOptions.chartOptions && options.rendererOptions.chartOptions.table_options && options.rendererOptions.chartOptions.table_options.transpose_table == true) {
|
4616
|
-
var temp_cols = opts.cols;
|
4617
|
-
opts.cols = opts.rows;
|
4618
|
-
opts.rows = temp_cols;
|
4619
|
-
|
4620
|
-
if (highchartsRenderer.sortHasBeenDoneOnBE(lodash.get(widget.pivot, 'keysObject'))) {
|
4621
|
-
opts.keysObject = lodash.cloneDeep(widget.pivot.keysObject);
|
4622
|
-
const tempColKeys = opts.keysObject.col_keys;
|
4623
|
-
opts.keysObject.col_keys = opts.keysObject.row_keys;
|
4624
|
-
opts.keysObject.row_keys = tempColKeys;
|
4625
|
-
}
|
4626
|
-
}
|
4627
4636
|
|
4628
4637
|
optsFiltered = $.extend(defaults, opts);
|
4629
4638
|
result = null;
|
4630
4639
|
try {
|
4631
|
-
const isTranspose = lodash.get(opts, 'rendererOptions.chartOptions.table_options.transpose_table', false);
|
4632
|
-
opts.getFormattedColKeys = isTranspose ? highchartsRenderer.getFormattedRowKeys : highchartsRenderer.getFormattedColKeys;
|
4633
|
-
opts.getFormattedRowKeys = isTranspose ? highchartsRenderer.getFormattedColKeys : highchartsRenderer.getFormattedRowKeys;
|
4634
|
-
|
4635
4640
|
pivotData = $.pivotUtilities.getPivotDataModel(rowData, opts);
|
4636
4641
|
pivotData.sortByValueAttrs = [];
|
4637
4642
|
try {
|
@@ -4782,26 +4787,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
4782
4787
|
highchartsRenderer.sanitizeOptions(opts);
|
4783
4788
|
options.rendererOptions.labelsConvertFunction = highchartsRenderer.getFieldNameForTable(options);
|
4784
4789
|
opts.isTable = isTable;
|
4785
|
-
if (isTable == true && options.rendererOptions.chartOptions && options.rendererOptions.chartOptions.table_options && options.rendererOptions.chartOptions.table_options.transpose_table == true) {
|
4786
|
-
var temp_cols = opts.cols;
|
4787
|
-
opts.cols = opts.rows;
|
4788
|
-
opts.rows = temp_cols;
|
4789
|
-
|
4790
|
-
if (highchartsRenderer.sortHasBeenDoneOnBE(lodash.get(widget.pivot, 'keysObject'))) {
|
4791
|
-
opts.keysObject = lodash.cloneDeep(widget.pivot.keysObject);
|
4792
|
-
const tempColKeys = opts.keysObject.col_keys;
|
4793
|
-
opts.keysObject.col_keys = opts.keysObject.row_keys;
|
4794
|
-
opts.keysObject.row_keys = tempColKeys;
|
4795
|
-
}
|
4796
|
-
}
|
4797
4790
|
|
4798
4791
|
optsFiltered = $.extend(defaults, opts);
|
4799
4792
|
result = null;
|
4800
4793
|
try {
|
4801
|
-
const isTranspose = lodash.get(opts, 'rendererOptions.chartOptions.table_options.transpose_table', false);
|
4802
|
-
opts.getFormattedColKeys = isTranspose ? highchartsRenderer.getFormattedRowKeys : highchartsRenderer.getFormattedColKeys;
|
4803
|
-
opts.getFormattedRowKeys = isTranspose ? highchartsRenderer.getFormattedColKeys : highchartsRenderer.getFormattedRowKeys;
|
4804
|
-
|
4805
4794
|
pivotData.sortByValueAttrs = [];
|
4806
4795
|
try {
|
4807
4796
|
if (options && options.onlyOptions) {
|
@@ -6276,7 +6265,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
6276
6265
|
element_type: 'checkbox',
|
6277
6266
|
element_label: 'Freeze panes <small>(old table only)</small>',
|
6278
6267
|
value_name: 'freeze_panes',
|
6279
|
-
default_value:
|
6268
|
+
default_value: false
|
6280
6269
|
},
|
6281
6270
|
{
|
6282
6271
|
element_type: 'checkbox',
|
@@ -6502,7 +6491,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
6502
6491
|
element_type: 'checkbox',
|
6503
6492
|
element_label: 'Freeze panes <small>(old table only)</small>',
|
6504
6493
|
value_name: 'freeze_panes',
|
6505
|
-
default_value:
|
6494
|
+
default_value: false
|
6506
6495
|
},
|
6507
6496
|
{
|
6508
6497
|
element_type: 'checkbox',
|
@@ -9185,9 +9174,28 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9185
9174
|
return {};
|
9186
9175
|
}
|
9187
9176
|
subopts.total_value_options = widget_obj.options.total_value_options;
|
9188
|
-
|
9189
|
-
|
9190
|
-
|
9177
|
+
subopts.getFormattedColKeys = highchartsRenderer.getFormattedColKeys;
|
9178
|
+
subopts.getFormattedRowKeys = highchartsRenderer.getFormattedRowKeys;
|
9179
|
+
|
9180
|
+
const is_transpose = lodash.get(widget_obj.options, 'chartOptions.table_options.transpose_table', false);
|
9181
|
+
|
9182
|
+
if (is_transpose) {
|
9183
|
+
subopts.getFormattedColKeys = highchartsRenderer.getFormattedRowKeys;
|
9184
|
+
subopts.getFormattedRowKeys = highchartsRenderer.getFormattedColKeys;
|
9185
|
+
|
9186
|
+
const tempCols = subopts.cols;
|
9187
|
+
subopts.cols = subopts.rows;
|
9188
|
+
subopts.rows = tempCols;
|
9189
|
+
|
9190
|
+
if (highchartsRenderer.sortHasBeenDoneOnBE(lodash.get(pivot, 'keysObject'))) {
|
9191
|
+
subopts.keysObject = lodash.cloneDeep(pivot.keysObject);
|
9192
|
+
const tempColKeys = subopts.keysObject.col_keys;
|
9193
|
+
subopts.keysObject.col_keys = subopts.keysObject.row_keys;
|
9194
|
+
subopts.keysObject.row_keys = tempColKeys;
|
9195
|
+
}
|
9196
|
+
}
|
9197
|
+
|
9198
|
+
if (isEditor == true) {
|
9191
9199
|
subopts.rendererOptions.totalFilterElements = {
|
9192
9200
|
col_total: $('<span>Grand Totals ' + highchartsRenderer.getIconsForTotalOptions(widget_obj.options, "col_total") + '</span>')[0],
|
9193
9201
|
row_total: $('<span>Grand Totals ' + highchartsRenderer.getIconsForTotalOptions(widget_obj.options, "row_total") + '</span>')[0]
|
@@ -9232,7 +9240,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
9232
9240
|
}
|
9233
9241
|
} else {
|
9234
9242
|
if (widget_obj.options && widget_obj.options.total_value_options && widget_obj.options.total_value_options) {
|
9235
|
-
is_transpose = lodash.get(widget_obj.options, 'chartOptions.table_options.transpose_table', false);
|
9236
9243
|
subopts.rendererOptions.totalFilterElements = {
|
9237
9244
|
col_total: $('<span>Grand Totals ' + highchartsRenderer.getIconsForTotalOptions(widget_obj.options, "col_total") + '</span>')[0],
|
9238
9245
|
row_total: $('<span>Grand Totals ' + highchartsRenderer.getIconsForTotalOptions(widget_obj.options, "row_total") + '</span>')[0]
|
@@ -4,6 +4,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
4
4
|
this.scope = {};
|
5
5
|
this.options = {};
|
6
6
|
this.isScenarioMode = null;
|
7
|
+
this.settings = {};
|
7
8
|
|
8
9
|
publishedItemsRenderer.formulaCellClicked = function (event, scope, options, window) {
|
9
10
|
event.stopPropagation();
|
@@ -30,16 +31,23 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
30
31
|
publishedItemsRenderer.resizePublishedImage(publish_item_image, iframeWindow, body);
|
31
32
|
}
|
32
33
|
|
33
|
-
publishedItemsRenderer.zoomTable = function(iframeWindow, table, body) {
|
34
|
+
publishedItemsRenderer.zoomTable = function (iframeWindow, table, body) {
|
34
35
|
const bodyZoom = parseFloat(body.style.zoom) || 1;
|
36
|
+
const SCROLL_OFFSET = 16;
|
37
|
+
|
38
|
+
const tableWidth = table.getBoundingClientRect().width * bodyZoom;
|
39
|
+
const tableHeight = table.getBoundingClientRect().height * bodyZoom;
|
40
|
+
const root = iframeWindow.document.documentElement;
|
41
|
+
|
42
|
+
let requiredZoom = (root.clientWidth - SCROLL_OFFSET) / tableWidth;
|
43
|
+
if (this.settings.resizeTableUsingBothDimensions) {
|
44
|
+
requiredZoom = Math.min(requiredZoom, (root.clientHeight - SCROLL_OFFSET) / tableHeight);
|
45
|
+
}
|
35
46
|
|
36
|
-
const tableWidth = (table.getBoundingClientRect().width + (iframeWindow.innerWidth - body.offsetWidth)) * bodyZoom;
|
37
|
-
const requiredZoom = iframeWindow.innerWidth / tableWidth;
|
38
|
-
|
39
47
|
table.style.zoom = requiredZoom;
|
40
48
|
};
|
41
49
|
|
42
|
-
publishedItemsRenderer.resizePublishedImage = function(publish_item_image, iframeWindow, body) {
|
50
|
+
publishedItemsRenderer.resizePublishedImage = function (publish_item_image, iframeWindow, body) {
|
43
51
|
if (!publish_item_image) return;
|
44
52
|
|
45
53
|
let body_zoom = body.style.zoom;
|
@@ -188,7 +196,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
188
196
|
const format = inputMetaData.format ? inputMetaData.format.toUpperCase() : 'MM/DD/YYYY';
|
189
197
|
const formattedDate = formatValue('d', format, inputMetaData.value).value
|
190
198
|
if (_this.isScenarioMode) {
|
191
|
-
|
199
|
+
dateEl.innerHTML = '<label class="value dateInput" style="background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;">' + formattedDate + '</label>';
|
192
200
|
} else {
|
193
201
|
dateEl.innerHTML = '<label class="value dateInput" style="cursor: pointer;">' + formattedDate + '</label>';
|
194
202
|
}
|
@@ -299,7 +307,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
299
307
|
if (resizeTimeout) {
|
300
308
|
cancelAnimationFrame(resizeTimeout);
|
301
309
|
}
|
302
|
-
|
310
|
+
|
303
311
|
resizeTimeout = requestAnimationFrame(() => {
|
304
312
|
publishedItemsRenderer.resizeTable(iframeWindow.__options__, iframeWindow);
|
305
313
|
});
|
@@ -342,7 +350,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
|
|
342
350
|
}, 500);
|
343
351
|
}
|
344
352
|
|
345
|
-
publishedItemsRenderer.applyInitDocumentStyles = function(document, iframeWindow) {
|
353
|
+
publishedItemsRenderer.applyInitDocumentStyles = function (document, iframeWindow) {
|
346
354
|
const table = document.getElementsByTagName('table')[0];
|
347
355
|
if (table) {
|
348
356
|
table.style.overflow = 'hidden';
|
@@ -367,23 +367,9 @@ describe('highcharts_renderer', () => {
|
|
367
367
|
});
|
368
368
|
|
369
369
|
describe('function downloadFile', () => {
|
370
|
-
const graphId = '1_1';
|
371
|
-
|
372
370
|
it('Old angular. No chart', () => {
|
373
371
|
expect(highchartsRenderer.downloadFile('test', '2_2', 'png')).toEqual(undefined)
|
374
372
|
});
|
375
|
-
|
376
|
-
it('New angular. png', () => {
|
377
|
-
jest.spyOn(Highcharts.charts[0], 'exportChartLocal', null);
|
378
|
-
highchartsRenderer.downloadFile('test', graphId, 'png')
|
379
|
-
expect(Highcharts.charts[0].exportChartLocal).toHaveBeenCalled();
|
380
|
-
});
|
381
|
-
|
382
|
-
it('New angular. XLS', () => {
|
383
|
-
jest.spyOn(Highcharts.charts[0], 'downloadXLS', null);
|
384
|
-
highchartsRenderer.downloadFile('test', graphId, 'XLS')
|
385
|
-
expect(Highcharts.charts[0].downloadXLS).toHaveBeenCalled();
|
386
|
-
});
|
387
373
|
});
|
388
374
|
|
389
375
|
describe('function defaultValueLabelsFormatter', () => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* @typedef {Object} HighChartsRenderer
|
3
|
-
* @property {(rows: Rows, options: GTROptions, isTable: boolean, widget: any, pivotModel?: PivotModel) => string} rhPivotViewV2
|
3
|
+
* @property {(rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => string} rhPivotViewV2
|
4
4
|
*/
|
5
5
|
/**
|
6
6
|
* @typedef {Object} PivotUtilities
|
@@ -13,8 +13,13 @@
|
|
13
13
|
/**
|
14
14
|
* @typedef {Object} PivotModel
|
15
15
|
*/
|
16
|
+
/**
|
17
|
+
* @typedef {Object} RendererOptions
|
18
|
+
* @property {any} hcInstance
|
19
|
+
*/
|
16
20
|
/**
|
17
21
|
* @typedef {Object} GTROptions
|
22
|
+
* @property {RendererOptions} rendererOptions
|
18
23
|
*/
|
19
24
|
/**
|
20
25
|
* @typedef {Record<string, Record<string, number | string> | number | string>[]} Rows - BE data response
|
@@ -42,13 +47,18 @@ export class GraphTableRenderer {
|
|
42
47
|
* @returns {PivotModel | undefined}
|
43
48
|
*/
|
44
49
|
getPivotModel(): PivotModel | undefined;
|
50
|
+
/**
|
51
|
+
* @description returns Chart instance of HighCharts library
|
52
|
+
* @returns {any | null}
|
53
|
+
*/
|
54
|
+
hcInstance(): any | null;
|
45
55
|
renderTable(widget?: null): string;
|
46
56
|
renderChart(widget?: null): string;
|
47
57
|
#private;
|
48
58
|
}
|
49
59
|
export default GraphTableRenderer;
|
50
60
|
export type HighChartsRenderer = {
|
51
|
-
rhPivotViewV2: (rows: Rows, options: GTROptions, isTable: boolean, widget: any, pivotModel?: PivotModel) => string;
|
61
|
+
rhPivotViewV2: (rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => string;
|
52
62
|
};
|
53
63
|
export type PivotUtilities = {
|
54
64
|
getPivotDataModel: (rows: Rows, options: GTROptions) => PivotModel;
|
@@ -57,7 +67,12 @@ export type JQuery = {
|
|
57
67
|
pivotUtilities: PivotUtilities;
|
58
68
|
};
|
59
69
|
export type PivotModel = Object;
|
60
|
-
export type
|
70
|
+
export type RendererOptions = {
|
71
|
+
hcInstance: any;
|
72
|
+
};
|
73
|
+
export type GTROptions = {
|
74
|
+
rendererOptions: RendererOptions;
|
75
|
+
};
|
61
76
|
/**
|
62
77
|
* - BE data response
|
63
78
|
*/
|