@datarailsshared/dr_renderer 1.2.78 → 1.2.81

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.2.78",
3
+ "version": "1.2.81",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -6,8 +6,6 @@ let initDRPivotTable = function($, window, document) {
6
6
  var DRPivotData, sortDateStrings, getSort, processKey, SubtotalRenderer, getFormattedNumber, largeToSmallSort, largeToSmallSortByAbsolute, NovixRenderer;
7
7
 
8
8
  var delim = " , ";
9
- const newTableColors = ['rgb(127, 196, 255)', 'rgb(200, 243,243)', 'rgb(247, 161, 173)', 'rgb(255, 237, 178)', 'rgb(221, 239, 255)',
10
- 'rgb(171, 216, 255)', 'rgb(174, 231, 220)', 'rgb(227, 255, 236)', 'rgb(162, 215, 227)', 'rgb(223, 239, 236)'];
11
9
  const useNewUx = document.ReportHippo && document.ReportHippo && document.ReportHippo.user &&
12
10
  document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
13
11
  // const numberOfRows = 500; // change to activate the handsontable when num of rows bigger then this.
@@ -643,18 +641,56 @@ let initDRPivotTable = function($, window, document) {
643
641
  }
644
642
 
645
643
  getColorsWithOffsetForTable = function (value) {
644
+ var colors = [];
645
+
646
+ if (opts.paletteOptions.widgetPalette) {
647
+ const mc_palette = _.find(_.get(opts.paletteOptions, 'monochromePalettes', []), { selected: true });
648
+ colors = mc_palette ? mc_palette.colors : opts.paletteOptions.widgetPalette;
649
+ } else if (opts.paletteOptions.dashboardPalette.colors) {
650
+ colors = opts.paletteOptions.dashboardPalette.colors;
651
+ }
652
+
646
653
  var isNewDesign = useNewUx && opts.chartOptions.table_options.use_new_table_design;
647
654
  if (value) {
648
655
  var offset = parseInt(value);
649
656
  if (offset) {
650
657
  if (isNewDesign) {
651
- return offsetColors(offset, newTableColors);
658
+ return offsetColors(offset, colors);
652
659
  } else {
653
660
  return offsetColors(offset, opts.defaults_colors);
654
661
  }
655
662
  }
656
663
  }
657
- return isNewDesign ? newTableColors : opts.defaults_colors;
664
+ return isNewDesign ? colors : opts.defaults_colors;
665
+ }
666
+
667
+ function invertColors(color) {
668
+ const hexLuminance = 186;
669
+ const rgbLuminance = 0.5;
670
+ let isHex = color[0] === '#';
671
+ let r;
672
+ let g;
673
+ let b;
674
+ if (!isHex) {
675
+ let rgbaColorParts = color.replace(/[^0-9.,]/g, '').split(',');
676
+ r = rgbaColorParts[0]/255;
677
+ g = rgbaColorParts[1]/255;
678
+ b = rgbaColorParts[2]/255;
679
+ } else {
680
+ color = color.slice(1);
681
+
682
+ if (color.length === 3) {
683
+ color = color[0].repeat(2) + color[1].repeat(2) + color[2].repeat(2);
684
+ } else if (color.length !== 6) {
685
+ return "#FFFFFF";
686
+ }
687
+ r = parseInt(color.slice(0, 2), 16);
688
+ g = parseInt(color.slice(2, 4), 16);
689
+ b = parseInt(color.slice(4, 6), 16);
690
+ }
691
+ return (r * 0.299 + g * 0.587 + b * 0.114) > (isHex ? hexLuminance : rgbLuminance)
692
+ ? '#000000'
693
+ : '#FFFFFF';
658
694
  }
659
695
 
660
696
  colorizeRowLabelHeaders = function(element, cols_count){
@@ -665,7 +701,9 @@ let initDRPivotTable = function($, window, document) {
665
701
  if(color_to_set){
666
702
  element.style.setProperty("background-color", color_to_set, "important");
667
703
  element.style.setProperty("border-color", color_to_set, "important");
668
- element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design? '#3a3b39' : '#FFFFFF';
704
+ element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design
705
+ ? invertColors(color_to_set)
706
+ : '#3a3b39';
669
707
  element.style.fontWeight = "bold";
670
708
  if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
671
709
  for (const child of element.children) {
@@ -695,7 +733,9 @@ let initDRPivotTable = function($, window, document) {
695
733
  element.style.setProperty("background-color", color_to_set, "important");
696
734
  element.style.setProperty("border-color", color_to_set, "important");
697
735
  element.style.setProperty("vertical-align", "baseline");
698
- element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design? '#3a3b39' : '#FFFFFF';
736
+ element.style.color = useNewUx && opts.chartOptions.table_options.use_new_table_design
737
+ ? invertColors(color_to_set)
738
+ : '#3a3b39';
699
739
  element.style.fontWeight = "bold";
700
740
  if (opts.chartOptions.table_options.freeze_panes && element.firstChild) {
701
741
  for (const child of element.children) {
@@ -440,7 +440,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
440
440
  rows = [];
441
441
  }
442
442
 
443
- if (pivotData.rowAttrs.length == 0) {
443
+ if (pivotData.rowAttrs.length == 0
444
+ || this.series.options.className === 'totalSeries'
445
+ || this.series.options.className === 'trendSeries') {
444
446
  rows = [];
445
447
  }
446
448
  var cols = this.key;
@@ -533,7 +535,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
533
535
  if (is_drill_down_pie && highchartsRenderer.selfStartsWith(series_name,"Series ")) {
534
536
  rows = [];
535
537
  }
536
- if (pivotData.rowAttrs.length == 0) {
538
+ if (pivotData.rowAttrs.length == 0
539
+ || this.series.options.className === 'totalSeries'
540
+ || this.series.options.className === 'trendSeries') {
537
541
  rows = [];
538
542
  }
539
543
  var cols = this.key;
@@ -980,6 +984,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
980
984
  const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
981
985
 
982
986
  const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
987
+ trendSeries.className = 'trendSeries';
983
988
  trendSeries.name = 'Trend Line (' + trendSeries.name + ')';
984
989
  trendSeries.dashStyle = 'shortdot';
985
990
  trendSeries.type = 'line';
@@ -1026,6 +1031,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1026
1031
  if (opts.totalSeriesSettings) {
1027
1032
  newSeries.yAxis = opts.totalSeriesSettings.secondaryAxis ? 1 : undefined;
1028
1033
  }
1034
+ newSeries.className = 'totalSeries';
1029
1035
  newSeries.name = 'Total';
1030
1036
  newSeries.data = [];
1031
1037
  col_n_keys.forEach(columnKey => {
@@ -1145,6 +1151,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1145
1151
  const b = ((n * xySum) - (xSum* ySum)) / ((n * squareXSum) - (xSum * xSum));
1146
1152
 
1147
1153
  const trendSeries = lodash.clone(chart_series[chart_series.length - 1]);
1154
+ trendSeries.className = 'trendSeries';
1148
1155
  trendSeries.name = 'Trend Line (' + trendSeries.name + ')';
1149
1156
  trendSeries.dashStyle = 'shortdot';
1150
1157
  trendSeries.type = 'line';
@@ -1206,6 +1213,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1206
1213
  }
1207
1214
  }
1208
1215
 
1216
+ totalSeries.className = 'totalSeries';
1209
1217
  totalSeries.name = 'Total';
1210
1218
  totalSeries.data = [];
1211
1219
  col_n_keys.forEach(columnKey => {
@@ -155,14 +155,14 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
155
155
  labelEl.innerText = inputMetaData.format ? formatValue('n', inputMetaData.format, inputMetaData.value).value : inputMetaData.value;
156
156
  }
157
157
  if (_this.isScenarioMode) {
158
- labelEl.setAttribute("style", "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;");
158
+ labelEl.setAttribute("style", "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;");
159
159
  } else {
160
160
  labelEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 6px;text-align: inherit;display: block; cursor: pointer;");
161
161
  }
162
162
  const onLabelClick = function (event, isScenarioMode) {
163
163
  event.stopPropagation();
164
164
  if (isScenarioMode) {
165
- inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: block;");
165
+ inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: block;");
166
166
  } else {
167
167
  inEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: block;");
168
168
  }
@@ -176,7 +176,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
176
176
  inEl.setAttribute("type", "number");
177
177
  inEl.setAttribute("name", inputMetaData.name);
178
178
  if (_this.isScenarioMode) {
179
- inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: none;");
179
+ inEl.setAttribute("style", "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: none;");
180
180
  } else {
181
181
  inEl.setAttribute("style", "background: transparent;width: calc(100% - 15px);border: 0;margin: 5px;text-align: inherit;display: none;");
182
182
  }
@@ -207,7 +207,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
207
207
  const format = inputMetaData.format ? inputMetaData.format.toUpperCase() : 'MM/DD/YYYY';
208
208
  const formattedDate = formatValue('d', format, inputMetaData.value).value
209
209
  if (_this.isScenarioMode) {
210
- dateEl.innerHTML = '<label class="value dateInput" style="background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;">' + formattedDate + '</label>';
210
+ 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>';
211
211
  } else {
212
212
  dateEl.innerHTML = '<label class="value dateInput" style="cursor: pointer;">' + formattedDate + '</label>';
213
213
  }
@@ -244,7 +244,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
244
244
  let listHolderEl = document.createElement("DIV");
245
245
  listHolderEl.setAttribute("class", "filter_list_holder");
246
246
  if (_this.isScenarioMode) {
247
- listHolderEl.innerHTML = '<label class="value filterList" style="background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor: pointer;">' + inputMetaData.value + '</label><i class="filter_icon"></i>';
247
+ listHolderEl.innerHTML = '<label class="value filterList" style="background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor: pointer;">' + inputMetaData.value + '</label><i class="filter_icon"></i>';
248
248
  } else {
249
249
  listHolderEl.innerHTML = '<label class="value filterList" style="cursor: pointer;">' + inputMetaData.value + '</label><i class="filter_icon"></i>';
250
250
  }
@@ -289,7 +289,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
289
289
  const inputs = document.querySelectorAll('td>input');
290
290
  const dateInputs = document.querySelectorAll('.dateInput');
291
291
  const filterList = document.querySelectorAll('.filterList');
292
- const styleForLabel = "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;";
292
+ const styleForLabel = "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;cursor:pointer;";
293
293
  if (!options.inputValuesData) {
294
294
  options.inputValuesData = {};
295
295
  }
@@ -299,7 +299,7 @@ let getPublishedItemsRenderer = function (publishedItemsRenderer) {
299
299
  inputs.forEach(element => {
300
300
  const labelElement = element.nextSibling;
301
301
  labelElement.setAttribute("style", isScenarioMode ?
302
- "background: #FFEDBF;padding: 2px 8px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;" :
302
+ "background: #FFEDBF;padding: 2px 1px 2px 6px;border: 1px solid #FABC5F;border-radius: 6px;width: calc(100% - 15px);margin: 6px;text-align: inherit;display: block; cursor: pointer;" :
303
303
  "background: transparent;width: calc(100% - 15px);border: 0;margin: 6px;text-align: inherit;display: block; cursor: pointer;");
304
304
  });
305
305
  }