@datarailsshared/dr_renderer 1.2.10 → 1.2.11

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.
@@ -0,0 +1,403 @@
1
+ [
2
+ {
3
+ "id": 9422,
4
+ "template_id": 7199,
5
+ "rows": [
6
+ {
7
+ "name": "Scenario",
8
+ "id": 161922,
9
+ "type": "Text",
10
+ "idx": 18,
11
+ "format": null,
12
+ "allow_blanks": true,
13
+ "is_calculated": false,
14
+ "calculated_formula": null,
15
+ "sorting": null,
16
+ "is_consolidated": false,
17
+ "consolidated_fields": [],
18
+ "error_policy": "SET_DEFAULT",
19
+ "default_value": null,
20
+ "date_split_options": null,
21
+ "date_field_before_split": null,
22
+ "category": [],
23
+ "mandatory": false,
24
+ "letter_case": null,
25
+ "trim": true,
26
+ "kind": null,
27
+ "date_format": "infer",
28
+ "consider_fiscal_in_view": false,
29
+ "description": null,
30
+ "is_hidden": false,
31
+ "usage_info": {
32
+ "usage_info": {
33
+ "ex_tables": [
34
+ 7076
35
+ ]
36
+ }
37
+ },
38
+ "ignore_hours": true,
39
+ "alias": ""
40
+ }
41
+ ],
42
+ "cols": [
43
+ {
44
+ "name": "Account level 1",
45
+ "id": 161918,
46
+ "type": "Text",
47
+ "idx": 14,
48
+ "format": null,
49
+ "allow_blanks": true,
50
+ "is_calculated": false,
51
+ "calculated_formula": null,
52
+ "sorting": null,
53
+ "is_consolidated": false,
54
+ "consolidated_fields": [],
55
+ "error_policy": "SET_DEFAULT",
56
+ "default_value": null,
57
+ "date_split_options": null,
58
+ "date_field_before_split": null,
59
+ "category": [],
60
+ "mandatory": false,
61
+ "letter_case": null,
62
+ "trim": true,
63
+ "kind": null,
64
+ "date_format": "infer",
65
+ "consider_fiscal_in_view": false,
66
+ "description": null,
67
+ "is_hidden": false,
68
+ "usage_info": {
69
+ "usage_info": {
70
+ "ex_tables": [
71
+ 7076
72
+ ]
73
+ }
74
+ },
75
+ "ignore_hours": true,
76
+ "alias": ""
77
+ },
78
+ {
79
+ "name": "Account level 2",
80
+ "id": 161919,
81
+ "type": "Text",
82
+ "idx": 15,
83
+ "format": null,
84
+ "allow_blanks": true,
85
+ "is_calculated": false,
86
+ "calculated_formula": null,
87
+ "sorting": null,
88
+ "is_consolidated": false,
89
+ "consolidated_fields": [],
90
+ "error_policy": "SET_DEFAULT",
91
+ "default_value": null,
92
+ "date_split_options": null,
93
+ "date_field_before_split": null,
94
+ "category": [],
95
+ "mandatory": false,
96
+ "letter_case": null,
97
+ "trim": true,
98
+ "kind": null,
99
+ "date_format": "infer",
100
+ "consider_fiscal_in_view": false,
101
+ "description": null,
102
+ "is_hidden": false,
103
+ "usage_info": {
104
+ "usage_info": {
105
+ "ex_tables": [
106
+ 7076
107
+ ]
108
+ }
109
+ },
110
+ "ignore_hours": true,
111
+ "alias": ""
112
+ },
113
+ {
114
+ "name": "Posting Date",
115
+ "id": 161923,
116
+ "type": "Date",
117
+ "idx": 19,
118
+ "format": null,
119
+ "allow_blanks": true,
120
+ "is_calculated": false,
121
+ "calculated_formula": null,
122
+ "sorting": null,
123
+ "is_consolidated": false,
124
+ "consolidated_fields": [],
125
+ "error_policy": "SET_DEFAULT",
126
+ "default_value": null,
127
+ "date_split_options": null,
128
+ "date_field_before_split": null,
129
+ "category": [],
130
+ "mandatory": false,
131
+ "letter_case": null,
132
+ "trim": true,
133
+ "kind": null,
134
+ "date_format": "infer",
135
+ "consider_fiscal_in_view": false,
136
+ "description": null,
137
+ "is_hidden": false,
138
+ "usage_info": {
139
+ "usage_info": {
140
+ "ex_tables": [
141
+ 7076
142
+ ]
143
+ }
144
+ },
145
+ "ignore_hours": true,
146
+ "alias": ""
147
+ }
148
+ ],
149
+ "calculated_values": [
150
+ {
151
+ "calc_id": 23,
152
+ "name": "Test value",
153
+ "field": 161922,
154
+ "side": "legend",
155
+ "format": null
156
+ }
157
+ ],
158
+ "filters": [
159
+ {
160
+ "field": 161918,
161
+ "name": "Account level 1",
162
+ "values": [
163
+ "Expenses",
164
+ "Income",
165
+ "Other Expense",
166
+ "Other Income"
167
+ ],
168
+ "is_excluded": false,
169
+ "show_in_graph": true,
170
+ "type": "Text",
171
+ "override_global_filter": true
172
+ },
173
+ {
174
+ "field": 161923,
175
+ "name": "Posting Date",
176
+ "values": {
177
+ "datetype": "range",
178
+ "val": {
179
+ "fromdate": 1641859200,
180
+ "todate": 1653696000
181
+ }
182
+ },
183
+ "is_excluded": false,
184
+ "show_in_graph": false,
185
+ "type": "Date",
186
+ "override_global_filter": false
187
+ },
188
+ {
189
+ "field": 161924,
190
+ "name": "Reporting Date",
191
+ "values": [
192
+ 1646006400,
193
+ 1643587200
194
+ ],
195
+ "is_excluded": false,
196
+ "show_in_graph": true,
197
+ "type": "Date",
198
+ "override_global_filter": true
199
+ }
200
+ ],
201
+ "options": {
202
+ "chartOptions": {
203
+ "axisY": {
204
+ "autoylabel": true,
205
+ "name": "Amount",
206
+ "min": null,
207
+ "max": null
208
+ },
209
+ "axisX": {
210
+ "autoxlabel": true,
211
+ "name": "Account level 1",
212
+ "min": null,
213
+ "max": null,
214
+ "label_step": null,
215
+ "zoom_x": false
216
+ },
217
+ "tooltips": {
218
+ "show": true,
219
+ "font_style": "Poppins",
220
+ "font_size": "12",
221
+ "font_color": "#545a6b",
222
+ "show_x_axis": true,
223
+ "show_data_series": true,
224
+ "show_value": true,
225
+ "show_out_of_x_axis": false,
226
+ "show_out_of_data_series": false
227
+ },
228
+ "label": {
229
+ "show": true,
230
+ "overlap": false,
231
+ "font_style": "Poppins",
232
+ "font_size": "11",
233
+ "font_color": "#151a41",
234
+ "show_value": true,
235
+ "show_out_of_x_axis": false,
236
+ "show_out_of_data_series": false
237
+ },
238
+ "subtitle": {
239
+ "subtitle": ""
240
+ },
241
+ "widget_library": {
242
+ "categories": "",
243
+ "description": "",
244
+ "tags": []
245
+ },
246
+ "table_options": {
247
+ "table_colors_offset": 0,
248
+ "show_column_total": true,
249
+ "show_row_total": true,
250
+ "show_subtotals_for_columns": false,
251
+ "show_subtotals_for_rows": false,
252
+ "show_subtotals_in_brackets": false,
253
+ "transpose_table": false,
254
+ "start_collapsed_rows": false,
255
+ "start_collapsed_columns": false,
256
+ "colorize_headers": true,
257
+ "remove_underscores": true,
258
+ "use_handsOnTable": false,
259
+ "use_new_table_design": true,
260
+ "hide_nulls_in_headers": true,
261
+ "show_all": false,
262
+ "freeze_panes": true,
263
+ "eliminate_calc_totals": false
264
+ },
265
+ "table_design_options": {
266
+ "columns_font_style": "Poppins",
267
+ "columns_font_size": "10",
268
+ "columns_align_text": "left",
269
+ "rows_font_style": "Poppins",
270
+ "rows_font_size": "10",
271
+ "rows_align_text": "left",
272
+ "values_font_style": "Poppins",
273
+ "values_font_size": "10",
274
+ "values_align_text": "left",
275
+ "totals_font_style": "Poppins",
276
+ "totals_font_size": "10",
277
+ "totals_align_text": "left"
278
+ },
279
+ "chart": {
280
+ "colors_offset": 0,
281
+ "zoom_type": "None",
282
+ "show": true
283
+ },
284
+ "delta_column": {
285
+ "field": "",
286
+ "name": "_Variance",
287
+ "formula": "x2-x1",
288
+ "chart": "",
289
+ "only_variant": false,
290
+ "same_yaxis": false,
291
+ "same_xaxis": false,
292
+ "is_percentage": false,
293
+ "sort_by_variance": false,
294
+ "sort_by_absolute_variance": false
295
+ },
296
+ "advanced": {
297
+ "error_policy": "None",
298
+ "from_latest": ""
299
+ },
300
+ "legends_position": {
301
+ "value": "top"
302
+ },
303
+ "hideChartHeader": true
304
+ },
305
+ "useDefaultFormat": false,
306
+ "average": false,
307
+ "total": false,
308
+ "comboOptions": {
309
+ "secondaryAxisSettings": {
310
+ "name": "Secondary Axis",
311
+ "max": null,
312
+ "min": null,
313
+ "is_percentage": false
314
+ },
315
+ "seriesOptions": []
316
+ },
317
+ "error_params": null,
318
+ "chart_title": "New Widget234",
319
+ "chartLabels": {
320
+ "legend": "Data series",
321
+ "axis": "X - Axis"
322
+ },
323
+ "widgetId": 9422,
324
+ "paletteOptions": {
325
+ "dashboardPalette": {
326
+ "id": 7615,
327
+ "is_default": true,
328
+ "colors": [
329
+ "rgba(205, 229, 255, 1)",
330
+ "rgba(0, 0, 0, 1)",
331
+ "rgba(94, 149, 105, 1)",
332
+ "rgba(251, 5, 86, 1)",
333
+ "#0E3E9E",
334
+ "#7DC5FF",
335
+ "#269AFF",
336
+ "#3DC5AA",
337
+ "rgba(112, 32, 100, 1)",
338
+ "#1591AD"
339
+ ],
340
+ "name": "testOne1212",
341
+ "organization": 1,
342
+ "variance_color": "#3DC5AA"
343
+ }
344
+ },
345
+ "chart_series": [
346
+ "Actuals"
347
+ ],
348
+ "resetSortingElement": null,
349
+ "show_more_max_items": 5,
350
+ "value_drill_down_fn": null,
351
+ "defaults_colors": [
352
+ "#0087FE",
353
+ "#3AD4D4",
354
+ "#EF4760",
355
+ "#FFCF33",
356
+ "#0E3E9E",
357
+ "#7DC5FF",
358
+ "#269AFF",
359
+ "#3DC5AA",
360
+ "#66FF99",
361
+ "#1591AD"
362
+ ],
363
+ "date_aggregation_configs": [
364
+ {
365
+ "field_id": 161923,
366
+ "field_name": "Posting Date",
367
+ "fnc": "sum",
368
+ "aggregate_by": "month",
369
+ "type": "YTD",
370
+ "rolling_month_before": 12,
371
+ "is_end_of_period": true,
372
+ "is_formatting_by_aggregation_method": true
373
+ }
374
+ ],
375
+ "error_has_occurred": false
376
+ },
377
+ "vals": [
378
+ {
379
+ "field": 161925,
380
+ "name": "Amount",
381
+ "aggregator": "SUM",
382
+ "type": "Float"
383
+ }
384
+ ],
385
+ "value_filter_options": "{}",
386
+ "values_format": "#,###",
387
+ "chart_type": "column-chart-stacked",
388
+ "widget_template_id": null,
389
+ "dashboard_name": "123",
390
+ "published_item": null,
391
+ "name": "New Widget234",
392
+ "dashboard": 9013,
393
+ "width": 6,
394
+ "height": 8,
395
+ "x": 0,
396
+ "y": 0,
397
+ "is_analysis": false,
398
+ "is_drill_down": false,
399
+ "is_any_field_is_empty": false,
400
+ "showTable": false,
401
+ "mydrilldownFunc": null
402
+ }
403
+ ]
@@ -0,0 +1,114 @@
1
+ import seriesPointStylesHelper from '../src/seriesPointStyles-helper';
2
+
3
+ describe('setSeriesPointStylesOnClick', () => {
4
+ it('should update point styles on click and update other points to non-selected styles on click', () => {
5
+ const selectedPoint = {
6
+ update: jest.fn(),
7
+ series: {
8
+ chart: {
9
+ series: [{ points: [] }],
10
+ redraw: jest.fn()
11
+ }
12
+ }
13
+ };
14
+
15
+ const otherPoint = {
16
+ update: jest.fn(),
17
+ series: selectedPoint.series
18
+ };
19
+
20
+ selectedPoint.series.chart.series[0].points.push(selectedPoint, otherPoint);
21
+
22
+ const mockEvent = { point: selectedPoint };
23
+
24
+ seriesPointStylesHelper.setSeriesPointStylesOnClick(mockEvent);
25
+
26
+ expect(selectedPoint.update).toHaveBeenCalledWith(
27
+ {
28
+ opacity: 1,
29
+ marker: {
30
+ enabled: true,
31
+ radius: 8
32
+ },
33
+ dataLabels: {
34
+ style: {
35
+ fontWeight: 'bold'
36
+ }
37
+ }
38
+ },
39
+ false
40
+ );
41
+ expect(otherPoint.update).toHaveBeenCalledWith(
42
+ {
43
+ opacity: 0.1,
44
+ marker: {
45
+ enabled: true,
46
+ radius: 3
47
+ },
48
+ dataLabels: {
49
+ style: {
50
+ fontWeight: 'normal'
51
+ }
52
+ }
53
+ },
54
+ false
55
+ );
56
+ expect(selectedPoint.series.chart.redraw).toHaveBeenCalled();
57
+ });
58
+ });
59
+
60
+ describe('setInitialPointStyles', () => {
61
+ it('should set initial point styles based on selection', () => {
62
+ const opts = { selectedPoint: { initialName: 'point1', y: 10 } };
63
+ const mockPoint = { initialName: 'point1', y: 10 };
64
+ const mockSeries = { data: [mockPoint] };
65
+ const series = [mockSeries];
66
+
67
+ seriesPointStylesHelper.setInitialPointStyles(opts, series);
68
+
69
+ expect(mockPoint).toEqual(
70
+ Object.assign(
71
+ mockPoint,
72
+ {
73
+ opacity: 1,
74
+ marker: {
75
+ enabled: true,
76
+ radius: 8
77
+ },
78
+ dataLabels: {
79
+ style: {
80
+ fontWeight: 'bold'
81
+ }
82
+ }
83
+ }
84
+ )
85
+ );
86
+ });
87
+
88
+ it('should not set styles if point is not selected', () => {
89
+ const opts = { selectedPoint: { initialName: 'point1', y: 10 } };
90
+ const mockPoint = { initialName: 'point2', y: 20 };
91
+ const mockSeries = { data: [mockPoint] };
92
+ const series = [mockSeries];
93
+
94
+ seriesPointStylesHelper.setInitialPointStyles(opts, series);
95
+
96
+ expect(mockPoint).toEqual(
97
+ Object.assign(
98
+ mockPoint,
99
+ {
100
+ opacity: 0.1,
101
+ marker: {
102
+ enabled: true,
103
+ radius: 3
104
+ },
105
+ dataLabels: {
106
+ style: {
107
+ fontWeight: 'normal'
108
+ }
109
+ }
110
+ }
111
+ )
112
+ );
113
+ });
114
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "allowJs": true,
5
+ "declarationDir": "./types",
6
+ "checkJs": true,
7
+ "moduleResolution": "Node16",
8
+ "module": "Node16",
9
+ "target": "esnext",
10
+ "emitDeclarationOnly": true,
11
+ "strict": true
12
+ },
13
+ "include": ["./src/graph-table-renderer.js"],
14
+ "exclude": ["node_modules"]
15
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @typedef {Object} HighChartsRenderer
3
+ * @property {(rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => string} rhPivotViewV2
4
+ */
5
+ /**
6
+ * @typedef {Object} PivotUtilities
7
+ * @property {(rows: Rows, options: GTROptions) => PivotModel} getPivotDataModel
8
+ */
9
+ /**
10
+ * @typedef {Object} JQuery
11
+ * @property {PivotUtilities} pivotUtilities
12
+ */
13
+ /**
14
+ * @typedef {Object} PivotModel
15
+ */
16
+ /**
17
+ * @typedef {Object} RendererOptions
18
+ * @property {any} hcInstance
19
+ */
20
+ /**
21
+ * @typedef {Object} GTROptions
22
+ * @property {RendererOptions} rendererOptions
23
+ */
24
+ /**
25
+ * @typedef {Record<string, Record<string, number | string> | number | string>[]} Rows - BE data response
26
+ */
27
+ export class GraphTableRenderer {
28
+ /**
29
+ *
30
+ * @param {HighChartsRenderer} hcr
31
+ * @param {JQuery} $
32
+ */
33
+ constructor(hcr: HighChartsRenderer, $: JQuery);
34
+ /**
35
+ * Creates Pivot Data Model that works we BE data response to aggregate data to render with Chart and Table
36
+ * @param {Rows} rows BE data response
37
+ * @param {GTROptions} options
38
+ * @returns {this}
39
+ */
40
+ createPivotModel(rows: Rows, options: GTROptions): this;
41
+ /**
42
+ * @returns {void}
43
+ */
44
+ disposePivotModel(): void;
45
+ /**
46
+ * @see createPivotModel
47
+ * @returns {PivotModel | undefined}
48
+ */
49
+ getPivotModel(): PivotModel | undefined;
50
+ /**
51
+ * @description returns Chart instance of HighCharts library
52
+ * @returns {any | null}
53
+ */
54
+ hcInstance(): any | null;
55
+ renderTable(widget?: null): string;
56
+ renderChart(widget?: null): string;
57
+ #private;
58
+ }
59
+ export default GraphTableRenderer;
60
+ export type HighChartsRenderer = {
61
+ rhPivotViewV2: (rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => string;
62
+ };
63
+ export type PivotUtilities = {
64
+ getPivotDataModel: (rows: Rows, options: GTROptions) => PivotModel;
65
+ };
66
+ export type JQuery = {
67
+ pivotUtilities: PivotUtilities;
68
+ };
69
+ export type PivotModel = Object;
70
+ export type RendererOptions = {
71
+ hcInstance: any;
72
+ };
73
+ export type GTROptions = {
74
+ rendererOptions: RendererOptions;
75
+ };
76
+ /**
77
+ * - BE data response
78
+ */
79
+ export type Rows = Record<string, Record<string, number | string> | number | string>[];
@@ -0,0 +1 @@
1
+ export * from './graph-table-renderer';