@datarailsshared/dr_renderer 1.3.26 → 1.3.30

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
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.3.26",
3
+ "version": "1.3.30",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -1,3 +1,5 @@
1
+ const helpers = require('./../dr-renderer-helpers');
2
+
1
3
  function DrDonutChart(highchartsRenderer, pivotData, opts, drilldownFunc, disableAnimation) {
2
4
  const additionOptions = opts.chartOptions
3
5
  ? opts.chartOptions
@@ -19,6 +21,7 @@ function DrDonutChart(highchartsRenderer, pivotData, opts, drilldownFunc, disabl
19
21
 
20
22
  config.series = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, config, additionOptions, opts);
21
23
  highchartsRenderer.setTitleAndSubTitle(config, opts, additionOptions);
24
+ helpers.disableLegendInteractionIfRequired(config, additionOptions);
22
25
  this.setDrilldownConfig(config);
23
26
 
24
27
  return config;
@@ -1,3 +1,5 @@
1
+ const _ = require('lodash');
2
+
1
3
  function backendSortingKeysAreNotEmpty(keys) {
2
4
  return !!keys && (!!keys.row_keys && !!keys.row_keys.length || !!keys.col_keys && !!keys.col_keys.length);
3
5
  }
@@ -48,6 +50,18 @@ function removeSVGTextCorrection(svgEl, corr = 'yCorr') {
48
50
  return svgEl;
49
51
  }
50
52
 
53
+ function disableLegendInteractionIfRequired(chartOptions, additionOptions) {
54
+ const type = _.get(chartOptions, 'chart.type');
55
+ if (!type || !_.get(additionOptions, 'disable_legend_interaction')) return;
56
+
57
+ const legendItemClickFnPath = type === 'pie'
58
+ ? 'plotOptions.pie.point.events.legendItemClick'
59
+ : 'plotOptions.series.events.legendItemClick';
60
+
61
+ _.set(chartOptions, legendItemClickFnPath, () => false);
62
+ _.set(chartOptions, 'legend.itemStyle.cursor', 'default');
63
+ }
64
+
51
65
  module.exports = {
52
66
  backendSortingKeysAreNotEmpty,
53
67
  capitalize,
@@ -55,4 +69,5 @@ module.exports = {
55
69
  isNumber,
56
70
  mergeDeep,
57
71
  removeSVGTextCorrection,
72
+ disableLegendInteractionIfRequired,
58
73
  }
@@ -514,8 +514,8 @@ let initDRPivotTable = function($, window, document) {
514
514
  isColHideOnExpand = (ref5 = opts.colSubtotalDisplay) != null ? ref5.hideOnExpand : !opts.chartOptions.table_options.show_subtotals_for_columns;
515
515
  isColDisableExpandCollapse = (ref6 = opts.colSubtotalDisplay) != null ? ref6.disableExpandCollapse : void 0;
516
516
  colDisableAfter = (ref7 = opts.colSubtotalDisplay) != null ? ref7.disableAfter != null ? ref7.disableAfter : ref7.disableAfter = 9999 : void 0;
517
- arrowCollapsed = opts.arrowCollapsed != null ? opts.arrowCollapsed : opts.arrowCollapsed = '<i class="fa fa-plus dr-icon-add"></i> ';
518
- arrowExpanded = opts.arrowExpanded != null ? opts.arrowExpanded : opts.arrowExpanded = '<i class="fa fa-minus dr-icon-minus"></i> ';
517
+ arrowCollapsed = opts.arrowCollapsed != null ? opts.arrowCollapsed : opts.arrowCollapsed = '<i class="dr-icon-add"></i> ';
518
+ arrowExpanded = opts.arrowExpanded != null ? opts.arrowExpanded : opts.arrowExpanded = '<i class="dr-icon-minus"></i> ';
519
519
  colAttrs = pivotData.colAttrs;
520
520
  rowAttrs = pivotData.rowAttrs;
521
521
  rowKeys = pivotData.getRowKeys();
@@ -2476,7 +2476,12 @@ let initDRPivotTable = function($, window, document) {
2476
2476
  }
2477
2477
 
2478
2478
  if (tooMuch) {
2479
- const defaultPlaceholder = $('<div class="noData"><i class="fa fa-info"></i> There are too many rows to display in the table.<br>Please filter or change the table type in options.</div>');
2479
+ const defaultPlaceholder = $(`
2480
+ <div class="noData--table-many-rows">
2481
+ <span><i class="noData-icon dr-icon-info"></i> There are too many rows to display in the table.</span>
2482
+ <span>Please filter or change the table type in options.</span>
2483
+ </div>
2484
+ `);
2480
2485
 
2481
2486
  resultsArr.push($.pivotUtilities.errorHandling.getErrorPlaceholder(error_params) || defaultPlaceholder);
2482
2487
  } else {
@@ -2203,6 +2203,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2203
2203
  }];
2204
2204
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, 1, false, true);
2205
2205
 
2206
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
2207
+
2206
2208
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2207
2209
  };
2208
2210
 
@@ -2418,6 +2420,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2418
2420
  else if (!pivotData.isDrillDownDisabled)
2419
2421
  chartOptions.drilldown = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(pivotData, chartOptions, additionOptions, opts);
2420
2422
 
2423
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
2424
+
2421
2425
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2422
2426
 
2423
2427
  };
@@ -2531,6 +2535,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2531
2535
  if (opts.selectedPoint) {
2532
2536
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
2533
2537
  }
2538
+
2539
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
2540
+
2534
2541
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2535
2542
  };
2536
2543
 
@@ -2616,6 +2623,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2616
2623
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
2617
2624
  }
2618
2625
 
2626
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
2627
+
2619
2628
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2620
2629
  };
2621
2630
 
@@ -2712,6 +2721,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2712
2721
  if (opts.selectedPoint) {
2713
2722
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
2714
2723
  }
2724
+
2725
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
2726
+
2715
2727
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2716
2728
  };
2717
2729
 
@@ -2799,6 +2811,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2799
2811
  if (opts.selectedPoint) {
2800
2812
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
2801
2813
  }
2814
+
2815
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
2816
+
2802
2817
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2803
2818
  };
2804
2819
 
@@ -2866,6 +2881,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2866
2881
 
2867
2882
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, rowAttrs.length, false);
2868
2883
 
2884
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
2885
+
2869
2886
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2870
2887
  };
2871
2888
 
@@ -2983,6 +3000,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
2983
3000
  chartOptions.legend = highchartsRenderer.getOptionsForLegends(additionOptions, rowAttrs.length, false);
2984
3001
 
2985
3002
  chartOptions.drilldown = highchartsRenderer.getDataLabelsStylesForDrillDown(additionOptions);
3003
+
3004
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
3005
+
2986
3006
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
2987
3007
  };
2988
3008
 
@@ -3128,7 +3148,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3128
3148
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
3129
3149
  }
3130
3150
 
3131
- highchartsRenderer.handleGridLines(additionOptions, chartOptions)
3151
+ highchartsRenderer.handleGridLines(additionOptions, chartOptions);
3152
+
3153
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
3132
3154
 
3133
3155
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3134
3156
  };
@@ -3217,6 +3239,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3217
3239
 
3218
3240
  highchartsRenderer.handleGridLines(additionOptions, chartOptions)
3219
3241
 
3242
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
3243
+
3220
3244
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3221
3245
  };
3222
3246
 
@@ -3297,6 +3321,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3297
3321
  if (opts.selectedPoint) {
3298
3322
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
3299
3323
  }
3324
+
3325
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
3326
+
3300
3327
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3301
3328
  };
3302
3329
 
@@ -3389,7 +3416,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3389
3416
  if (opts.selectedPoint) {
3390
3417
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
3391
3418
  }
3392
- highchartsRenderer.handleGridLines(additionOptions, chartOptions)
3419
+ highchartsRenderer.handleGridLines(additionOptions, chartOptions);
3420
+
3421
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
3393
3422
 
3394
3423
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3395
3424
  };
@@ -3514,6 +3543,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3514
3543
  if (opts.selectedPoint) {
3515
3544
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
3516
3545
  }
3546
+
3547
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
3548
+
3517
3549
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3518
3550
  };
3519
3551
 
@@ -3634,6 +3666,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3634
3666
  seriesPointStylesHelper.setInitialPointStyles(opts, chartOptions.series);
3635
3667
  }
3636
3668
 
3669
+ helpers.disableLegendInteractionIfRequired(chartOptions, additionOptions);
3670
+
3637
3671
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3638
3672
  }
3639
3673
 
@@ -4260,7 +4294,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4260
4294
  let ret_str = '';
4261
4295
  if (options && options.total_value_options && options.total_value_options.filter_options && options.total_value_options.filter_options.axis == tr_axis) {
4262
4296
  //TODO add tooltip with description of filter
4263
- ret_str += '<i class="fa fa-filter"></i>';
4297
+ ret_str += '<i class="dr-icon-filter-old"></i>';
4264
4298
  }
4265
4299
 
4266
4300
  return ret_str;
package/src/pivot.css CHANGED
@@ -5,6 +5,17 @@
5
5
  flex-direction: column;
6
6
  }
7
7
 
8
+ .pivot-wrapper .noData--table-many-rows {
9
+ display: flex;
10
+ flex-direction: column;
11
+ }
12
+ .pivot-wrapper .noData--table-many-rows > *:first-child {
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ line-height: 25px;
17
+ }
18
+
8
19
  table.pvtTable {
9
20
  font-size: 8pt;
10
21
  text-align: left;
@@ -228,16 +239,27 @@ table.pvtTable.newPvtTable thead tr th {
228
239
  border-right: 1px solid #fff;
229
240
  }
230
241
 
231
- table.pvtTable.newPvtTable thead tr th .fa,
232
- table.pvtTable.newPvtTable thead tr th .dr-icon-add,
233
- table.pvtTable.newPvtTable thead tr th .dr-icon-minus {
234
- padding: 2px;
235
- background-color: #ffffff;
236
- border-radius: 2px;
237
- margin-right: 2px;
238
- margin-left: 1px;
239
- font-size: 8px;
240
- color: #151a41;
242
+ table.pvtTable.newPvtTable thead tr th i,
243
+ table.pvtTable.newPvtTable tbody tr th i {
244
+ position: relative;
245
+ bottom: -1px;
246
+ background-color: #ffffff;
247
+ border-radius: 2px;
248
+ margin-right: 2px;
249
+ margin-left: 1px;
250
+ font-weight: bold;
251
+ font-size: 10px;
252
+ color: #151a41;
253
+ }
254
+
255
+ table.pvtTable.newPvtTable tbody tr th i {
256
+ bottom: -2px;
257
+ background-color: #dfe6ec;
258
+ }
259
+
260
+ table.pvtTable.newPvtTable thead tr th .dr-icon-filter-old,
261
+ table.pvtTable.newPvtTable tbody tr th .dr-icon-filter-old {
262
+ font-weight: normal;
241
263
  }
242
264
 
243
265
  table.pvtTable.newPvtTable.colorized tr th.colTotal,
@@ -261,14 +283,6 @@ table.pvtTable.newPvtTable tbody tr td.rowTotal {
261
283
  border-color: #ffffff !important;
262
284
  }
263
285
 
264
- table.pvtTable.newPvtTable tbody tr th .fa {
265
- padding: 2px;
266
- background-color: #dfe6ec;
267
- border-radius: 2px;
268
- margin-right: 2px;
269
- font-size: 8px;
270
- }
271
-
272
286
  table.pvtTable.newPvtTable tbody tr th,
273
287
  table.pvtTable.newPvtTable tbody tr td {
274
288
  border: 1px solid #dfe6ec;
@@ -147,4 +147,52 @@ describe('dr-renderer-helpers', () => {
147
147
  expect(svg.xCorr).toBe(0);
148
148
  });
149
149
  });
150
+
151
+ describe('disableLegendInteractionIfRequired', () => {
152
+ const notPieTypes = ['column', 'line', 'area', 'areaspline', 'scatter', 'spline', 'bar', 'waterfall'];
153
+
154
+ it('should not update legend settings', () => {
155
+ const chartOptionsMock = {
156
+ chart: {
157
+ type: 'column',
158
+ },
159
+ };
160
+ const additionOptionsMock = {
161
+ disable_legend_interaction: false,
162
+ };
163
+ drRendererHelpers.disableLegendInteractionIfRequired(chartOptionsMock, additionOptionsMock);
164
+ expect(chartOptionsMock.plotOptions).toBeFalsy();
165
+ expect(chartOptionsMock.legend).toBeFalsy();
166
+ });
167
+
168
+ it('should update legend styles and set click event (for pie chart)', () => {
169
+ const chartOptionsMock = {
170
+ chart: {
171
+ type: 'pie',
172
+ },
173
+ };
174
+ const additionOptionsMock = {
175
+ disable_legend_interaction: true,
176
+ };
177
+ drRendererHelpers.disableLegendInteractionIfRequired(chartOptionsMock, additionOptionsMock);
178
+ expect(chartOptionsMock.plotOptions.pie.point.events.legendItemClick).toEqual(jasmine.any(Function));
179
+ expect(chartOptionsMock.legend.itemStyle.cursor).toEqual('default');
180
+ });
181
+
182
+ notPieTypes.forEach((chartType) => {
183
+ it(`should update legend styles and set click event (for ${ chartType } chart)`, () => {
184
+ const chartOptionsMock = {
185
+ chart: {
186
+ type: chartType,
187
+ },
188
+ };
189
+ const additionOptionsMock = {
190
+ disable_legend_interaction: true,
191
+ };
192
+ drRendererHelpers.disableLegendInteractionIfRequired(chartOptionsMock, additionOptionsMock);
193
+ expect(chartOptionsMock.plotOptions.series.events.legendItemClick).toEqual(jasmine.any(Function));
194
+ expect(chartOptionsMock.legend.itemStyle.cursor).toEqual('default');
195
+ });
196
+ });
197
+ });
150
198
  });
@@ -917,7 +917,7 @@ describe('highcharts_renderer', () => {
917
917
 
918
918
  it('should return filter icon for matching axis', () => {
919
919
  const axis = 'row'
920
- const expected = '<i class="fa fa-filter"></i>'
920
+ const expected = '<i class="dr-icon-filter-old"></i>'
921
921
  const result = highchartsRenderer.getIconsForTotalOptions(options, axis)
922
922
  expect(result).toEqual(expected)
923
923
  });