@datarailsshared/dr_renderer 1.1.41 → 1.2.2
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 +86 -0
- package/README.md +23 -23
- package/babel.config.js +3 -0
- package/jest.config.js +27 -0
- package/package.json +50 -28
- package/src/charts/dr_gauge_chart.js +566 -0
- package/src/dataformatter.d.ts +13 -0
- package/src/dataformatter.js +1076 -1023
- package/src/dr-renderer-helpers.js +58 -0
- package/src/dr_chart_tooltip.js +277 -0
- package/src/dr_pivottable.js +2639 -2178
- package/src/graph-table-renderer.js +147 -0
- package/src/highcharts_renderer.js +10020 -6262
- package/src/index.js +27 -21
- package/src/novix_renderer.js +906 -829
- package/src/pivot.css +426 -301
- package/src/pivottable.js +1901 -1824
- package/src/published_items_renderer.js +365 -0
- package/src/seriesPointStyles-helper.js +43 -0
- package/start_run.sh +3 -3
- package/tests/dr-renderer-helpers.test.js +150 -0
- package/tests/dr_chart_tooltip.test.js +739 -0
- package/tests/dr_gauge_chart.test.js +1931 -0
- package/tests/highcharts_renderer.test.js +9358 -0
- package/tests/mock/add-in-dynamic-ranges.json +127 -0
- package/tests/mock/add-in-functions.json +410 -0
- package/tests/mock/add-in-tables.json +347 -0
- package/tests/mock/tables.json +2258 -0
- package/tests/mock/widgets.json +403 -0
- package/tests/seriesPointStyles-helper.test.js +114 -0
- package/tsconfig.json +15 -0
- package/types/graph-table-renderer.d.ts +79 -0
- package/types/index.d.ts +1 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} HighChartsRenderer
|
|
3
|
+
* @property {(rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => string} rhPivotViewV2
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} PivotUtilities
|
|
8
|
+
* @property {(rows: Rows, options: GTROptions) => PivotModel} getPivotDataModel
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {Object} JQuery
|
|
13
|
+
* @property {PivotUtilities} pivotUtilities
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} PivotModel
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} RendererOptions
|
|
22
|
+
* @property {any} hcInstance
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {Object} GTROptions
|
|
27
|
+
* @property {RendererOptions} rendererOptions
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {Record<string, Record<string, number | string> | number | string>[]} Rows - BE data response
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
export class GraphTableRenderer {
|
|
35
|
+
/**
|
|
36
|
+
* @type {PivotModel | undefined}
|
|
37
|
+
*/
|
|
38
|
+
#pivotModel;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @type {GTROptions | null}
|
|
42
|
+
*/
|
|
43
|
+
#options = null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @type {Record<string, Record<string, number | string> | number | string>[]}
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
#rows = [];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Utility properties
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @type {HighChartsRenderer}
|
|
56
|
+
*/
|
|
57
|
+
#hcr;
|
|
58
|
+
/**
|
|
59
|
+
* @type {JQuery}
|
|
60
|
+
*/
|
|
61
|
+
#$;
|
|
62
|
+
/**
|
|
63
|
+
* @type {PivotUtilities}
|
|
64
|
+
*/
|
|
65
|
+
#pivotUtilities;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @type {any | null}
|
|
69
|
+
*/
|
|
70
|
+
#hcInstance = null;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @param {HighChartsRenderer} hcr
|
|
75
|
+
* @param {JQuery} $
|
|
76
|
+
*/
|
|
77
|
+
constructor(hcr, $) {
|
|
78
|
+
this.#hcr = hcr;
|
|
79
|
+
this.#$ = $;
|
|
80
|
+
this.#pivotUtilities = this.#$.pivotUtilities;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Creates Pivot Data Model that works we BE data response to aggregate data to render with Chart and Table
|
|
85
|
+
* @param {Rows} rows BE data response
|
|
86
|
+
* @param {GTROptions} options
|
|
87
|
+
* @returns {this}
|
|
88
|
+
*/
|
|
89
|
+
createPivotModel(rows, options) {
|
|
90
|
+
this.#options = options;
|
|
91
|
+
this.#rows = rows;
|
|
92
|
+
this.#pivotModel = this.#pivotUtilities.getPivotDataModel(rows, options);
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @returns {void}
|
|
98
|
+
*/
|
|
99
|
+
disposePivotModel() {
|
|
100
|
+
this.#pivotModel = undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @see createPivotModel
|
|
105
|
+
* @returns {PivotModel | undefined}
|
|
106
|
+
*/
|
|
107
|
+
getPivotModel() {
|
|
108
|
+
return this.#pivotModel;
|
|
109
|
+
}
|
|
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
|
+
|
|
134
|
+
renderTable(widget = null) {
|
|
135
|
+
return this.#hcr.rhPivotViewV2(this.#rows, this.#options, true, widget, this.#pivotModel);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
renderChart(widget = null) {
|
|
139
|
+
const chart = this.#hcr.rhPivotViewV2(this.#rows, this.#options, false, widget, this.#pivotModel);
|
|
140
|
+
setTimeout(() => {
|
|
141
|
+
this.#setHcInstance();
|
|
142
|
+
});
|
|
143
|
+
return chart;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export default GraphTableRenderer;
|