@datarailsshared/dr_renderer 1.2.356 → 1.2.358

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.356",
3
+ "version": "1.2.358",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -12,6 +12,10 @@ let initDRPivotTable = function($, window, document) {
12
12
  document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
13
13
  // const numberOfRows = 500; // change to activate the handsontable when num of rows bigger then this.
14
14
 
15
+ const isFlatKeyInPivotKeys = function(keys, flatKey) {
16
+ return keys.some(key => key.join(delim) === flatKey);
17
+ };
18
+
15
19
  DRPivotData = (function(superClass) {
16
20
  extend(DRPivotData, superClass);
17
21
 
@@ -199,10 +203,10 @@ let initDRPivotTable = function($, window, document) {
199
203
  let flatColKey = colKey.join(delim);
200
204
 
201
205
  if (this.keysLength === rowKey.length + colKey.length) {
202
- if (!this.rowKeys.some(rKey => rKey.join(delim) === flatRowKey)) {
206
+ if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.rowKeys, flatRowKey)) {
203
207
  this.rowKeys.push(rowKey);
204
208
  }
205
- if (!this.colKeys.some(cKey => cKey.join(delim) === flatColKey)) {
209
+ if (!this.isKeysSortingDoneOnBackendSide && !isFlatKeyInPivotKeys(this.colKeys, flatColKey)) {
206
210
  this.colKeys.push(colKey);
207
211
  }
208
212
  }
@@ -234,7 +238,6 @@ let initDRPivotTable = function($, window, document) {
234
238
  insight: insight,
235
239
  });
236
240
  }
237
-
238
241
  return;
239
242
  }
240
243
 
@@ -21,6 +21,9 @@ const CHART_COLORS = {
21
21
  LABEL: '#cfd7dd',
22
22
  LABEL_SECOND: '#85889c',
23
23
  DRILL_UP_FILL: '#eef3f6',
24
+ DRILL_BUTTON_COLOR_FILL: 'white',
25
+ DRILL_BUTTON_COLOR: '#6D6E6F',
26
+ DRILL_BUTTON_COLOR_HOVER: '#333333',
24
27
  PLOT_BORDER: '#606063',
25
28
  MINOR_GRID_LINE: '#505053',
26
29
  TICK_COLOR: '#666',
@@ -61,6 +64,7 @@ const CHART_TYPES = {
61
64
 
62
65
  const HIGHCHARTS_CONSTANTS = {
63
66
  delimer: ' , ',
67
+ DRILL_BUTTON_FONT_SIZE: '14px',
64
68
  MAX_ROWS_FOR_AUTO_REFRESH: 100000,
65
69
  MAX_ROWS_FOR_SHOW_RESULTS: 10000,
66
70
  DR_OTHERS_KEY: 'DR_Others',
@@ -146,6 +150,7 @@ const FEATURES = {
146
150
  FORMAT_DATES_AS_OTHER_AXIS_TYPES: 'format_dates_as_other_axis_types',
147
151
  MULTIPLE_DIMENSION_TAGS: 'multiple_dimension_tags',
148
152
  USE_NEW_SCENARIO_TAG: 'use_new_scenario_tag',
153
+ ENABLE_SERVER_WIDGET_DATA_SORTING: 'enable_server_widget_data_sorting',
149
154
  }
150
155
 
151
156
  const TICKS_COUNT = 5;
@@ -201,6 +206,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
201
206
  highchartsRenderer.useTotalsCalculation = highchartsRenderer.hasFeature(FEATURES.ENABLE_SERVER_TOTALS_CALCULATION);
202
207
  disableAnimation = document.ReportHippo.user.organization && document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.disable_animation
203
208
  highchartsRenderer.enabledNewWidgetValueFormatting = highchartsRenderer.hasFeature(FEATURES.ENABLE_NEW_WIDGET_VALUE_FORMATTING);
209
+ highchartsRenderer.isSortingOnBackendEnabled = highchartsRenderer.hasFeature(FEATURES.ENABLE_SERVER_WIDGET_DATA_SORTING);
204
210
  }
205
211
 
206
212
  // fix issue of use tootip.stickOnContact with tooltip.outside , source: https://github.com/highcharts/highcharts/pull/15960
@@ -1036,8 +1042,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1036
1042
  chartOptions.yAxis && chartOptions.yAxis.title && (chartOptions.yAxis.title.text || chartOptions.yAxis.title.autoylabel) ? -60 : -40;
1037
1043
  const y = isPieChart ? 27 :
1038
1044
  chartOptions.xAxis && chartOptions.xAxis.title && (chartOptions.xAxis.title.text || chartOptions.xAxis.title.autoxlabel) ? 65 : 43;
1045
+ chartOptions.chart.spacingBottom = 30;
1039
1046
  chartOptions.drilldown.breadcrumbs = {
1040
- formatter: () => '< Back',
1047
+ formatter: () => 'Back',
1041
1048
  showFullPath: false,
1042
1049
  position: {
1043
1050
  align: 'left',
@@ -1046,23 +1053,21 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1046
1053
  y: y,
1047
1054
  },
1048
1055
  floating: true,
1056
+ position: { align: 'left', x: 12, y: 6, verticalAlign: 'bottom' },
1057
+ relativeTo: 'spacingBox',
1049
1058
  buttonTheme: {
1050
- fill: 'white',
1051
- color: CHART_COLORS.LABEL_SECOND,
1052
- 'stroke-width': 1,
1053
- stroke: CHART_COLORS.LABEL_SECOND,
1054
- r: 3,
1055
- padding: 3,
1059
+ fill: CHART_COLORS.DRILL_BUTTON_COLOR_FILL,
1060
+ style: {
1061
+ fontSize: HIGHCHARTS_CONSTANTS.DRILL_BUTTON_FONT_SIZE,
1062
+ color: CHART_COLORS.DRILL_BUTTON_COLOR,
1063
+ },
1056
1064
  states: {
1057
1065
  hover: {
1058
- fill: CHART_COLORS.DRILL_UP_FILL,
1059
- stroke: CHART_COLORS.LABEL_SECOND,
1060
- color: CHART_COLORS.LABEL_SECOND
1061
- },
1062
- select: {
1063
- stroke: CHART_COLORS.LABEL_SECOND,
1064
- fill: CHART_COLORS.DRILL_UP_FILL,
1065
- color: CHART_COLORS.LABEL_SECOND
1066
+ fill: CHART_COLORS.DRILL_BUTTON_COLOR_FILL,
1067
+ style: {
1068
+ fontSize: HIGHCHARTS_CONSTANTS.DRILL_BUTTON_FONT_SIZE,
1069
+ color: CHART_COLORS.DRILL_BUTTON_COLOR_HOVER,
1070
+ }
1066
1071
  }
1067
1072
  }
1068
1073
  },
@@ -1538,6 +1543,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1538
1543
  const chart_series = [];
1539
1544
  const row_n_keys = pivotData.getRowKeys();
1540
1545
  const col_n_keys = pivotData.getColKeys();
1546
+ const rows_by_cols = pivotData.rowKeysByCols;
1541
1547
 
1542
1548
  let resultObject = {
1543
1549
  data: [],
@@ -1567,7 +1573,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1567
1573
  });
1568
1574
 
1569
1575
  if (col_index !== col_n_keys.length - 1) {
1570
- lodash.forEach(row_n_keys, function (row_n_value) {
1576
+
1577
+ const rowKeys = rows_by_cols ? rows_by_cols[col_index] : row_n_keys;
1578
+ lodash.forEach(rowKeys, function (row_n_value) {
1571
1579
  const agg = pivotData.getAggregator(row_n_value, col_n_value);
1572
1580
  let val = agg.value();
1573
1581
 
@@ -4795,20 +4803,22 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4795
4803
  opts.rendererOptions.onlyOptions = true;
4796
4804
  }
4797
4805
 
4798
- const sortByValueSettings = lodash.filter(
4799
- lodash.get(widget, 'options.sortingFields', []),
4800
- sortingField => lodash.includes(['field_values', 'variance'], lodash.get(sortingField, 'sorting.sort_by'))
4801
- );
4802
-
4803
- if (sortByValueSettings.length) {
4804
- pivotData.sortByValueAttrs = lodash.map(sortByValueSettings, fieldSorting => fieldSorting.name);
4805
- let new_sorting_function = highchartsRenderer.generateSortingFunctionByValues(sortByValueSettings, pivotData, opts, widget);
4806
- opts.sorters = new_sorting_function;
4807
- optsFiltered.sorters = new_sorting_function;
4808
- pivotData.sorters = new_sorting_function;
4809
-
4810
- if (lodash.isObject(lodash.get(widget, 'pivot'))) {
4811
- widget.pivot.sorters = new_sorting_function;
4806
+ if (!highchartsRenderer.isSortingOnBackendEnabled) {
4807
+ const sortByValueSettings = lodash.filter(
4808
+ lodash.get(widget, 'options.sortingFields', []),
4809
+ sortingField => lodash.includes(['field_values', 'variance'], lodash.get(sortingField, 'sorting.sort_by'))
4810
+ );
4811
+
4812
+ if (sortByValueSettings.length) {
4813
+ pivotData.sortByValueAttrs = lodash.map(sortByValueSettings, fieldSorting => fieldSorting.name);
4814
+ let new_sorting_function = highchartsRenderer.generateSortingFunctionByValues(sortByValueSettings, pivotData, opts, widget);
4815
+ opts.sorters = new_sorting_function;
4816
+ optsFiltered.sorters = new_sorting_function;
4817
+ pivotData.sorters = new_sorting_function;
4818
+
4819
+ if (lodash.isObject(lodash.get(widget, 'pivot'))) {
4820
+ widget.pivot.sorters = new_sorting_function;
4821
+ }
4812
4822
  }
4813
4823
  }
4814
4824
 
@@ -4872,6 +4882,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4872
4882
  rowFormats: highchartsRenderer.getTableFormatInfosForWidgetFields(widget, pivotOptions, widget.rows),
4873
4883
  rendererOptions: widget.options,
4874
4884
  dateValuesDictionary: pivotOptions ? pivotOptions.dateValuesDictionary : null,
4885
+ keysObject: pivotOptions ? pivotOptions.keysObject : null,
4875
4886
  };
4876
4887
 
4877
4888
  if (!subopts.rendererOptions) {
@@ -8774,8 +8785,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8774
8785
  };
8775
8786
 
8776
8787
  highchartsRenderer.getWidgetDataSorters = function (res, widget, defaultDateFormat) {
8777
-
8778
8788
  const isFormattingDatesAsOtherAxisTypes = highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
8789
+ let sorters;
8779
8790
 
8780
8791
  if ($.pivotUtilities && !$.pivotUtilities.additionalFieldsList) {
8781
8792
  $.pivotUtilities.additionalFieldsList = [
@@ -8784,7 +8795,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8784
8795
  ];
8785
8796
  }
8786
8797
 
8787
- var datesFields = [];
8798
+ let datesFields = [];
8788
8799
  datesFields = lodash.filter(widget.rows, element => element.type == 'Date');
8789
8800
  datesFields = datesFields.concat(lodash.filter(widget.cols, element => element.type == 'Date'));
8790
8801
 
@@ -8808,8 +8819,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8808
8819
  } //'MMM - yyyy' format
8809
8820
  });
8810
8821
 
8811
- var data = res;
8812
-
8813
8822
  if (!isFormattingDatesAsOtherAxisTypes) {
8814
8823
  lodash.forEach(datesFields, function (row) {
8815
8824
  row.val_not_convert = highchartsRenderer.check_values_not_for_convert(widget, row.name);
@@ -8817,7 +8826,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8817
8826
  }
8818
8827
 
8819
8828
  if (datesFields.length > 0) {
8820
- lodash.forEach(data, function (element) {
8829
+ const invertedDateStringMap = {};
8830
+ lodash.forEach(res, function (element) {
8821
8831
  for (var i in datesFields) {
8822
8832
  if (element.hasOwnProperty(datesFields[i].name)) {
8823
8833
  datesFields[i].values.push(element[datesFields[i].name]);
@@ -8832,133 +8842,154 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8832
8842
  widget.pivot.dateValuesDictionary = {}
8833
8843
  }
8834
8844
  widget.pivot.dateValuesDictionary[dateStringValue] = element[datesFields[i].name];
8845
+ invertedDateStringMap[element[datesFields[i].name]] = dateStringValue;
8835
8846
  }
8836
8847
  element[datesFields[i].name] = dateStringValue;
8837
8848
  }
8838
8849
  }
8839
8850
  }
8840
8851
  });
8841
- }
8842
8852
 
8843
- lodash.forEach(datesFields, function (row) {
8844
- row.values = lodash.uniq(row.values);
8853
+ if (highchartsRenderer.isSortingOnBackendEnabled && !isFormattingDatesAsOtherAxisTypes && lodash.get(widget, 'pivot.keysObject')) {
8854
+ lodash.forEach(['col_keys', 'row_keys'], (keysListName, index) => {
8855
+ const widgetFields = index ? widget.rows : widget.cols;
8856
+ const uniqueFormattedKeysList = [];
8857
+ lodash.forEach(widget.pivot.keysObject[keysListName], subKeysList => {
8858
+ lodash.forEach(subKeysList, (key, index) => {
8859
+ if (widgetFields[index].type === 'Date') {
8860
+ subKeysList[index] = invertedDateStringMap[key] || key;
8861
+ }
8862
+ });
8863
+ if (!lodash.find(uniqueFormattedKeysList, formattedSubKeys => lodash.isEqual(formattedSubKeys, subKeysList))) {
8864
+ uniqueFormattedKeysList.push(subKeysList);
8865
+ }
8866
+ });
8867
+ widget.pivot.keysObject[keysListName] = uniqueFormattedKeysList;
8868
+ });
8869
+ }
8870
+ }
8845
8871
 
8846
- const isTimestampDateField = row.type === 'Date' && lodash.some(row.values, value => typeof value ==='number');
8847
- if (isTimestampDateField) {
8848
- const nullValueIndex = row.values.indexOf(NULL_VALUE);
8849
- if (~nullValueIndex) {
8850
- row.values.splice(nullValueIndex, 1);
8872
+ if (!highchartsRenderer.isSortingOnBackendEnabled) {
8873
+
8874
+ lodash.forEach(datesFields, function (row) {
8875
+ row.values = lodash.uniq(row.values);
8876
+
8877
+ const isTimestampDateField = row.type === 'Date' && lodash.some(row.values, value => typeof value ==='number');
8878
+ if (isTimestampDateField) {
8879
+ const nullValueIndex = row.values.indexOf(NULL_VALUE);
8880
+ if (~nullValueIndex) {
8881
+ row.values.splice(nullValueIndex, 1);
8882
+ }
8883
+ row.values = row.values.sort((a, b) => a - b);
8884
+ if (~nullValueIndex) {
8885
+ row.values.push(NULL_VALUE);
8886
+ }
8887
+ } else {
8888
+ row.values = row.values.sort();
8851
8889
  }
8852
- row.values = row.values.sort((a, b) => a - b);
8853
- if (~nullValueIndex) {
8854
- row.values.push(NULL_VALUE);
8890
+
8891
+ if (row.sorting && row.sorting.type == "largestToSmallest") {
8892
+ row.values = lodash.reverse(row.values);
8855
8893
  }
8856
- } else {
8857
- row.values = row.values.sort();
8858
- }
8894
+ delete row.sorting;
8859
8895
 
8860
- if (row.sorting && row.sorting.type == "largestToSmallest") {
8861
- row.values = lodash.reverse(row.values);
8862
- }
8863
- delete row.sorting;
8896
+ if (!isFormattingDatesAsOtherAxisTypes) {
8897
+ row.values = lodash.map(row.values, function (val) {
8898
+ return highchartsRenderer.returnRawDataValue(row.type, val, row.format, row.name, row.val_not_convert) + "";
8899
+ });
8900
+ }
8901
+ });
8864
8902
 
8865
- if (!isFormattingDatesAsOtherAxisTypes) {
8866
- row.values = lodash.map(row.values, function (val) {
8867
- return highchartsRenderer.returnRawDataValue(row.type, val, row.format, row.name, row.val_not_convert) + "";
8903
+ /* date string */
8904
+ var rowsAndCols = [];
8905
+ rowsAndCols = widget.rows.concat(widget.cols);
8906
+
8907
+ if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
8908
+
8909
+ // if it is breakdown widget - redefine sorting according to breakdown_options
8910
+ // TODO: remove this when BE sort will be implemented (FE subtickets for story DR-18469)
8911
+ const isTwoColumnComparisonWidget = lodash.get(widget, 'options.breakdown_options.values.totals', []).length === 2;
8912
+ lodash.forEach(rowsAndCols, function (field) {
8913
+ const waterfallFieldType = field.id === widget.cols[0].id ? 'totals' : 'breakdown';
8914
+ if (waterfallFieldType !== 'totals' || isTwoColumnComparisonWidget) {
8915
+ field.sorting = {
8916
+ type: 'CustomOrder',
8917
+ values: lodash.map(
8918
+ widget.options.breakdown_options.values[waterfallFieldType],
8919
+ value => value.key
8920
+ ),
8921
+ };
8922
+ } else {
8923
+ field.sorting = null;
8924
+ }
8925
+ });
8926
+ } else if (isCustomSorting) {
8927
+ lodash.forEach(rowsAndCols, function (field) {
8928
+ const fieldToSort = lodash.find(
8929
+ widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
8930
+ );
8931
+ field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
8868
8932
  });
8869
8933
  }
8870
- });
8871
8934
 
8872
- /* date string */
8873
- var rowsAndCols = [];
8874
- rowsAndCols = widget.rows.concat(widget.cols);
8875
-
8876
- if (widget.chart_type === highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN) {
8877
-
8878
- // if it is breakdown widget - redefine sorting according to breakdown_options
8879
- // TODO: remove this when BE sort will be implemented
8880
- const isTwoColumnComparisonWidget = lodash.get(widget, 'options.breakdown_options.values.totals', []).length === 2;
8881
- lodash.forEach(rowsAndCols, function (field) {
8882
- const waterfallFieldType = field.id === widget.cols[0].id ? 'totals' : 'breakdown';
8883
- if (waterfallFieldType !== 'totals' || isTwoColumnComparisonWidget) {
8884
- field.sorting = {
8885
- type: 'CustomOrder',
8886
- values: lodash.map(
8887
- widget.options.breakdown_options.values[waterfallFieldType],
8888
- value => value.key
8889
- ),
8890
- };
8891
- } else {
8892
- field.sorting = null;
8893
- }
8894
- });
8895
- } else if (isCustomSorting) {
8896
8935
  lodash.forEach(rowsAndCols, function (field) {
8897
- const fieldToSort = lodash.find(
8898
- widget.options.sortingFields, element => element.id === field.id && lodash.get(element, 'sorting.sort_by') === 'field_items'
8899
- );
8900
- field.sorting = fieldToSort ? fieldToSort.sorting : field.sorting;
8901
- });
8902
- }
8903
-
8904
- lodash.forEach(rowsAndCols, function (field) {
8905
- if (field.sorting && (field.sorting.type == "DateString" || field.sorting.type == "largestToSmallest")) {
8906
- var find_field = lodash.find(datesFields, {name: field.name});
8907
- if (find_field) {
8908
- if (find_field.type != 'Date')
8909
- find_field.sorting = field.sorting;
8910
- } else {
8936
+ if (field.sorting && (field.sorting.type == "DateString" || field.sorting.type == "largestToSmallest")) {
8937
+ var find_field = lodash.find(datesFields, {name: field.name});
8938
+ if (find_field) {
8939
+ if (find_field.type != 'Date')
8940
+ find_field.sorting = field.sorting;
8941
+ } else {
8942
+ datesFields.push({
8943
+ "format": field.format,
8944
+ "name": field.name,
8945
+ "type": field.type,
8946
+ "values": [],
8947
+ "sorting": field.sorting,
8948
+ });
8949
+ }
8950
+ } else if (field.sorting && field.sorting.type == "CustomOrder" && field.sorting.values) {
8911
8951
  datesFields.push({
8912
8952
  "format": field.format,
8913
8953
  "name": field.name,
8914
8954
  "type": field.type,
8915
- "values": [],
8916
- "sorting": field.sorting,
8955
+ "values": field.sorting.values
8917
8956
  });
8918
8957
  }
8919
- } else if (field.sorting && field.sorting.type == "CustomOrder" && field.sorting.values) {
8920
- datesFields.push({
8921
- "format": field.format,
8922
- "name": field.name,
8923
- "type": field.type,
8924
- "values": field.sorting.values
8925
- });
8926
- }
8927
- });
8928
-
8929
- if (widget.vals && widget.vals.length > 1) {
8930
- datesFields.push({name: "DR_Values", values: lodash.map(widget.vals, 'name')});
8931
- }
8932
-
8933
- /****** END *******/
8958
+ });
8934
8959
 
8935
- // TODO: Remove. sortingValues looks like lagacy which is not in use neither in webclient nor in renderer
8936
- if (widget.options && widget.options.sortingValues) {
8937
- var field = lodash.find(datesFields, {name: widget.options.sortingValues.field});
8938
- if (field) {
8939
- field.values = widget.options.sortingValues.values;
8940
- field.sorting = null;
8941
- } else {
8942
- datesFields.push({
8943
- name: widget.options.sortingValues.field,
8944
- values: widget.options.sortingValues.values
8945
- });
8960
+ if (widget.vals && widget.vals.length > 1) {
8961
+ datesFields.push({name: "DR_Values", values: lodash.map(widget.vals, 'name')});
8946
8962
  }
8947
- }
8963
+
8964
+ /****** END *******/
8948
8965
 
8949
- let sorters = function (attr) {
8950
- var field = lodash.find(datesFields, {name: attr});
8951
- if (field)
8952
- if (field.sorting && field.sorting.type == "DateString") {
8953
- return $.pivotUtilities.sortDateStrings(field.sorting.month_order);
8954
- } else if (field.sorting && field.sorting.type == "largestToSmallest") {
8955
- if (field.sorting.is_absolute)
8956
- return $.pivotUtilities.largeToSmallSortByAbsolute;
8957
- return $.pivotUtilities.largeToSmallSort;
8966
+ // TODO: Remove. sortingValues looks like lagacy which is not in use neither in webclient nor in renderer
8967
+ if (widget.options && widget.options.sortingValues) {
8968
+ var field = lodash.find(datesFields, {name: widget.options.sortingValues.field});
8969
+ if (field) {
8970
+ field.values = widget.options.sortingValues.values;
8971
+ field.sorting = null;
8958
8972
  } else {
8959
- return $.pivotUtilities.sortAs(field.values);
8973
+ datesFields.push({
8974
+ name: widget.options.sortingValues.field,
8975
+ values: widget.options.sortingValues.values
8976
+ });
8960
8977
  }
8961
- };
8978
+ }
8979
+ sorters = function (attr) {
8980
+ var field = lodash.find(datesFields, {name: attr});
8981
+ if (field)
8982
+ if (field.sorting && field.sorting.type == "DateString") {
8983
+ return $.pivotUtilities.sortDateStrings(field.sorting.month_order);
8984
+ } else if (field.sorting && field.sorting.type == "largestToSmallest") {
8985
+ if (field.sorting.is_absolute)
8986
+ return $.pivotUtilities.largeToSmallSortByAbsolute;
8987
+ return $.pivotUtilities.largeToSmallSort;
8988
+ } else {
8989
+ return $.pivotUtilities.sortAs(field.values);
8990
+ }
8991
+ };
8992
+ }
8962
8993
 
8963
8994
  return sorters;
8964
8995
  };
@@ -8978,6 +9009,12 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8978
9009
 
8979
9010
  //highchartsRenderer.getGraphOptions(scope.data, override_values, res, scope.dataModel.templatesWithOutData, scope.openDrillDownList, drillDownFunction)
8980
9011
  highchartsRenderer.getGraphOptions = function (widget_obj, override_values, row_data, templates, openDrillDownListFunction, drillDownFunction) {
9012
+
9013
+ let keysObject;
9014
+ if (highchartsRenderer.isSortingOnBackendEnabled) {
9015
+ keysObject = row_data.pop();
9016
+ }
9017
+
8981
9018
  let res = highchartsRenderer.updateSelectedOverrideValues(widget_obj, override_values, row_data);
8982
9019
  res = highchartsRenderer.convertUniqueDateValues(widget_obj, templates, res);
8983
9020
 
@@ -8991,6 +9028,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8991
9028
 
8992
9029
  let pivot = {};
8993
9030
 
9031
+ if (highchartsRenderer.isSortingOnBackendEnabled) {
9032
+ pivot.keysObject = keysObject;
9033
+ }
9034
+
8994
9035
  let templateNoData = lodash.find(templates, {id: widget_obj.template_id});
8995
9036
  if (templateNoData) {
8996
9037
 
@@ -9031,6 +9072,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9031
9072
  subopts.onlyOptions = true;
9032
9073
  }
9033
9074
 
9075
+ subopts.keysObject = keysObject;
9076
+
9034
9077
  let hc_options = highchartsRenderer.rhPivotView(res, subopts, is_table, widget_obj);
9035
9078
 
9036
9079
  return hc_options;
package/src/pivottable.js CHANGED
@@ -686,8 +686,17 @@ let initPivotTable = function($, window, document) {
686
686
  });
687
687
  this.tree = {};
688
688
  this.insights = [];
689
- this.rowKeys = [];
690
- this.colKeys = [];
689
+
690
+ this.isKeysSortingDoneOnBackendSide = opts.keysObject && typeof opts.keysObject === 'object';
691
+ if (this.isKeysSortingDoneOnBackendSide) {
692
+ this.rowKeys = opts.keysObject.row_keys;
693
+ this.colKeys = opts.keysObject.col_keys;
694
+ // TODO: add also for breakdown sort object when BE story is ready.
695
+ } else {
696
+ this.rowKeys = [];
697
+ this.colKeys = [];
698
+ }
699
+
691
700
  this.rowTotals = {};
692
701
  this.colTotals = {};
693
702
  this.allTotal = this.aggregator(this, [], []);
@@ -859,12 +868,16 @@ let initPivotTable = function($, window, document) {
859
868
  };
860
869
 
861
870
  PivotData.prototype.getColKeys = function() {
862
- this.sortKeys();
871
+ if (!this.isKeysSortingDoneOnBackendSide) {
872
+ this.sortKeys();
873
+ }
863
874
  return this.colKeys;
864
875
  };
865
876
 
866
877
  PivotData.prototype.getRowKeys = function() {
867
- this.sortKeys();
878
+ if (!this.isKeysSortingDoneOnBackendSide) {
879
+ this.sortKeys();
880
+ }
868
881
  return this.rowKeys;
869
882
  };
870
883