@datarailsshared/dr_renderer 1.2.217 → 1.2.218

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.217",
3
+ "version": "1.2.218",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -4365,7 +4365,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4365
4365
  title: 'Data Conflict',
4366
4366
  text: `Please adjust your dashboard's reference date and filter selections as \
4367
4367
  the quantity of data doesn't match the chart's ${ minCategories }-${ maxCategories } value limit.`,
4368
- class: 'nodata',
4368
+ class: uniqueCategories.length < minCategories ? 'waterfall-nodata' : 'waterfall-too-much-data',
4369
4369
  }
4370
4370
  return highchartsRenderer.getNoDataResult(options.rendererOptions, true);
4371
4371
  }
@@ -5086,22 +5086,71 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
5086
5086
  highchartsRenderer.addTemplateDataToCalcModel = function (selectedTemplate, calcModelOptions) {
5087
5087
  highchartsRenderer.setWidgetFieldsToTemplate(selectedTemplate);
5088
5088
 
5089
- var fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.widget_fields);
5090
- var fieldOb;
5091
- var selectedFields = [];
5089
+ const scenarioName = 'scenario';
5090
+ const fields = highchartsRenderer.objectCopyJsonMethod(selectedTemplate.fields);
5091
+ const fieldScenarioAlias = _.find(fields, field => (field.alias || '').toLowerCase() === scenarioName)
5092
+ const fieldScenario = _.find(fields, field => (field.name || '').toLowerCase() === scenarioName)
5093
+ const filters = calcModelOptions.config && calcModelOptions.config.filters;
5092
5094
 
5093
- // fill selected fields
5094
- lodash.forEach(calcModelOptions.fields, function (valObj) {
5095
- fieldOb = lodash.find(fields, {id: valObj.id});
5096
- if (fieldOb) {
5097
- selectedFields.push(fieldOb);
5098
- lodash.remove(fields, {id: fieldOb.id});
5095
+ const filterFields = [];
5096
+ const valueFields = [];
5097
+ const dateFields = [];
5098
+ const dataTypeFields = [];
5099
+ const dataSeriesFields = [];
5100
+
5101
+ let scenarioField = lodash.get(calcModelOptions, 'config.scenario', undefined) || fieldScenarioAlias || fieldScenario;
5102
+ let fieldOb;
5103
+
5104
+ const fillData = (fieldsArr, destinationArr) => {
5105
+ lodash.forEach(fieldsArr, function (valObj) {
5106
+ fieldOb = lodash.find(fields, { id: valObj.id });
5107
+ if (fieldOb) {
5108
+ destinationArr.push(fieldOb);
5109
+ lodash.remove(fields, { id: fieldOb.id });
5110
+ }
5111
+ });
5112
+ }
5113
+
5114
+ lodash.forEach(filters, function (filterObj) {
5115
+ fieldOb = lodash.find(fields, { id: filterObj.id });
5116
+ if (fieldOb && lodash.get(filterObj, 'values.datetype') === 'list') {
5117
+ filterObj.values = filterObj.values.val
5118
+ } else if (fieldOb && filterObj.values && filterObj.values.datetype && filterObj.values.datetype !== 'list') {
5119
+ fieldOb.values = filterObj.values;
5120
+ } else if (fieldOb && filterObj.values && filterObj.values.type === 'advanced') {
5121
+ fieldOb.values = filterObj.values;
5122
+ }
5123
+ if (fieldOb && filterObj.values && filterObj.values instanceof Array) {
5124
+ if (filterObj.is_excluded === true) {
5125
+ fieldOb.excludes = filterObj.values;
5126
+ } else {
5127
+ fieldOb.includes = filterObj.values;
5128
+ }
5129
+ }
5130
+ if (filterObj.allow_nulls && fieldOb) {
5131
+ fieldOb.allow_nulls = filterObj.allow_nulls;
5099
5132
  }
5100
5133
  });
5101
5134
 
5135
+ const storedGroupByFields = lodash.get(calcModelOptions, 'config.group_by', []);
5136
+ const storedDateFields = [lodash.get(calcModelOptions, 'config.date_field', undefined)].filter(f => !!f);
5137
+ const storedAggFields = [lodash.get(calcModelOptions, 'config.agg_field', undefined)].filter(f => !!f);
5138
+ const storedDataTypeFields = [lodash.get(calcModelOptions, 'config.data_type_field', undefined)].filter(f => !!f);
5139
+
5140
+ fillData(storedGroupByFields, dataSeriesFields);
5141
+ fillData(storedDateFields, dateFields);
5142
+ fillData(storedAggFields, valueFields);
5143
+ fillData(storedDataTypeFields, dataTypeFields);
5144
+ fillData(filters, filterFields);
5145
+
5102
5146
  calcModelOptions.pivot = {
5103
5147
  fieldsArray: fields,
5104
- selectedFieldsArray: selectedFields
5148
+ selectedFieldsArray: dataSeriesFields,
5149
+ filtersArray: filterFields,
5150
+ scenarioField,
5151
+ dateFields,
5152
+ dataTypeFields,
5153
+ valueFields
5105
5154
  };
5106
5155
  }
5107
5156