@datarailsshared/dr_renderer 1.2.196-dragons → 1.2.197

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.196-dragons",
3
+ "version": "1.2.197",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -1339,12 +1339,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1339
1339
  return chart_series;
1340
1340
  }
1341
1341
 
1342
- highchartsRenderer.ptCreateWaterfallBreakdownSeries = function (pivotData, additionOptions, opts) {
1342
+ highchartsRenderer.ptCreateWaterfallBreakdownSeries = function (pivotData, onlyNumbers, additionOptions, opts) {
1343
1343
  const colorOptions = opts.breakdown_options.colors;
1344
- const chart_series = [];
1345
- const row_n_keys = pivotData.getRowKeys();
1346
- const col_n_keys = pivotData.getColKeys();
1347
- const hasBreakdownValues = lodash.get(opts, 'breakdown_options.values.breakdown.length');
1344
+ var chart_series = [],
1345
+ row_n_keys = pivotData.getRowKeys(),
1346
+ col_n_keys = pivotData.getColKeys();
1347
+
1348
+ if (row_n_keys.length === 0) {
1349
+ row_n_keys.push([]);
1350
+ }
1348
1351
 
1349
1352
  let resultObject = {
1350
1353
  data: [],
@@ -1360,46 +1363,56 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1360
1363
  };
1361
1364
  resultObject = highchartsRenderer.getDataLabelsOptions(additionOptions, resultObject);
1362
1365
 
1366
+ const breakdownValues = [];
1363
1367
  lodash.forEach(col_n_keys, function(col_n_value, col_index) {
1368
+ breakdownValues.push([]);
1369
+ lodash.forEach(row_n_keys, function (row_n_value, row_index) {
1370
+ var agg = pivotData.getAggregator(row_n_value, col_n_value);
1371
+ var val = agg.value();
1364
1372
 
1365
- const totalColumnValue = pivotData.colTotals[col_n_value].sum;
1366
- const nextTotalColumnKey = col_n_keys[col_index + 1];
1367
- const nextTotalColumnValue = nextTotalColumnKey ? pivotData.colTotals[nextTotalColumnKey].sum : null;
1368
- resultObject.data.push({
1369
- y: totalColumnValue,
1370
- name: lodash.unescape(col_n_value).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
1371
- isSum: !!col_index,
1372
- isTotal: true,
1373
- color: colorOptions.total,
1374
- });
1373
+ if (val != null && $.isNumeric(val)) {
1374
+ val = parseFloat(val);
1375
+ } else if (onlyNumbers) {
1376
+ val = NaN;
1377
+ } else {
1378
+ val = 0;
1379
+ }
1375
1380
 
1376
- if (col_index !== col_n_keys.length - 1) {
1377
- lodash.forEach(row_n_keys, function (row_n_value) {
1378
- const agg = pivotData.getAggregator(row_n_value, col_n_value);
1379
- let val = hasBreakdownValues
1380
- ? agg.value()
1381
- : nextTotalColumnValue - totalColumnValue;
1382
-
1383
- val = $.isNumeric(val) ? parseFloat(val) : 0;
1384
- if (val) {
1385
- const tmoobj = {};
1386
- const key = lodash.isArray(row_n_value) ? row_n_value[0] : row_n_value;
1387
- tmoobj.name = lodash.unescape(key);
1381
+ breakdownValues[col_index][row_index] = val;
1382
+
1383
+ if (col_index) {
1384
+ const value = val - breakdownValues[col_index - 1][row_index];
1388
1385
 
1386
+ if (value) {
1387
+ var tmoobj = {};
1388
+ var key = row_n_value;
1389
+ if (lodash.isArray(row_n_value)) {
1390
+ key = row_n_value[0];
1391
+ }
1392
+ tmoobj.name = lodash.unescape(key);
1393
+
1389
1394
  if (tmoobj.name) {
1390
1395
  tmoobj.name = tmoobj.name.replace('DR_Others', highchartsRenderer.getOthersName(opts));
1391
1396
  }
1397
+
1392
1398
  if (lodash.isEmpty(String(tmoobj.name))) {
1393
1399
  tmoobj.name = lodash.unescape(col_n_value);
1394
1400
  tmoobj.visible = false;
1395
1401
  }
1396
-
1397
- tmoobj.y = val;
1402
+ tmoobj.y = value;
1398
1403
  tmoobj.colKeys = [lodash.unescape(col_n_keys[col_index - 1]), lodash.unescape(col_n_value)];
1399
1404
  resultObject.data.push(tmoobj);
1400
1405
  }
1401
- });
1402
- }
1406
+ }
1407
+ });
1408
+
1409
+ resultObject.data.push({
1410
+ y: pivotData.colTotals[col_n_value].sum,
1411
+ name: lodash.unescape(col_n_value).replace('DR_Others', highchartsRenderer.getOthersName(opts)),
1412
+ isSum: !!col_index,
1413
+ isTotal: true,
1414
+ color: colorOptions.total,
1415
+ });
1403
1416
  });
1404
1417
 
1405
1418
  chart_series.push(resultObject);
@@ -3177,8 +3190,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3177
3190
  ? opts.chartOptions
3178
3191
  : highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN);
3179
3192
 
3180
- pivotData.colKeys = lodash.map(lodash.keys(pivotData.colTotals), key => [key]);
3181
-
3182
3193
  chartOptions.chart = {
3183
3194
  type: 'waterfall',
3184
3195
  zoomType: additionOptions && additionOptions.chart && additionOptions.chart.zoom_type ? additionOptions.chart.zoom_type : 'None',
@@ -3229,7 +3240,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3229
3240
  chartOptions.colors = opts.paletteOptions.dashboardPalette.colors;
3230
3241
  }
3231
3242
  chartOptions.series = highchartsRenderer
3232
- .ptCreateWaterfallBreakdownSeries(pivotData, additionOptions, opts);
3243
+ .ptCreateWaterfallBreakdownSeries(pivotData, null, additionOptions, opts);
3233
3244
 
3234
3245
  chartOptions = highchartsRenderer.prepareAxisX(chartOptions, additionOptions, pivotData.getColKeys());
3235
3246
  chartOptions.plotOptions = {
@@ -3265,10 +3276,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
3265
3276
  enabled: false
3266
3277
  };
3267
3278
 
3268
- chartOptions.xAxis.labels = {
3269
- formatter: highchartsRenderer.getBreakdownXAxisLabelFormatter(chartOptions.series),
3270
- };
3271
-
3272
3279
  return highchartsRenderer.ptCreateElementAndDraw(chartOptions, opts);
3273
3280
  };
3274
3281
 
@@ -4360,12 +4367,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4360
4367
  );
4361
4368
 
4362
4369
  if (uniqueCategories && (uniqueCategories.length > maxCategories || uniqueCategories.length < minCategories )) {
4370
+ const commonErrorSentence = `Please choose ${ minCategories }-${ maxCategories } items in the Category section.`
4363
4371
  options.error_has_occurred = true;
4364
4372
  options.error_params = {
4365
- title: 'Data Conflict',
4366
- text: `Please adjust your dashboard's reference date and filter selections as \
4367
- the quantity of data doesn't match the chart's ${ minCategories }-${ maxCategories } value limit.`,
4368
- class: 'nodata' ,
4373
+ title: uniqueCategories.length > maxCategories
4374
+ ? `There is too much data. ${ commonErrorSentence }`
4375
+ : `Not enough data. ${ commonErrorSentence }`,
4376
+ text: '',
4377
+ btnText: 'Edit Widget',
4378
+ class: 'too-much-data',
4369
4379
  }
4370
4380
  return highchartsRenderer.getNoDataResult(options.rendererOptions, true);
4371
4381
  }
@@ -6784,18 +6794,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6784
6794
 
6785
6795
  highchartsRenderer.chartsTypesInfo = {
6786
6796
  [highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN]: {
6787
- name: 'Breakdown Chart ',
6788
- label: 'Breakdown Chart ',
6789
- title: 'Analyzes what’s contributing to the financial increase or decrease.',
6790
- description: 'For example, analyzes what’s contributing most to the difference in total revenue between last year and this year.',
6797
+ name: 'Waterfall Breakdown Chart ',
6798
+ label: 'Waterfall Breakdown Chart ',
6799
+ title: 'TODO: add text',
6800
+ description: 'TODO: add text',
6791
6801
  titleInEditor: 'This chart displays the breakdown of variance between two or more total values.',
6792
6802
  axisName: 'Category',
6793
6803
  legendName: 'Breakdown',
6794
6804
  startedMessage: 'To get started, drag one field to the Category and one field to the Value section.',
6795
- axisTooltipTitle: 'Drag one field to configure your x-axis.',
6796
- axisTooltipDescription: 'The category (usually an independent variable) is shown on the x-axis and should be between 2 to 5 total columns. ',
6797
- legendTooltipTitle: 'Drag one field to further configure your x-axis.',
6798
- legendTooltipDescription: 'The breakdown subdivides the chart by a category field for further analysis of what’s contributing to the increase or decrease.',
6805
+ axisTooltipTitle: 'TODO: add text',
6806
+ legendTooltipTitle: 'TODO: add text',
6799
6807
  },
6800
6808
  'combo-chart': {
6801
6809
  name: 'Combo Chart ',
@@ -7432,12 +7440,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7432
7440
  {
7433
7441
  type: 'waterfall-chart',
7434
7442
  name: 'Waterfall',
7435
- class: 'google-visualization-charteditor-mini-waterfall',
7443
+ hidden: true,
7444
+ class: 'google-visualization-charteditor-mini-column',
7436
7445
  subtypes: [
7437
7446
  {
7438
7447
  type: highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN,
7439
7448
  name: highchartsRenderer.chartsTypesInfo[highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN].name,
7440
- class: 'google-visualization-charteditor-thumbs-breakdown',
7449
+ class: 'google-visualization-charteditor-thumbs-columnchart',
7441
7450
  render: highchartsRenderer.ptRenderWaterfallBreakdown,
7442
7451
  suboptions: [
7443
7452
  highchartsRenderer.suboptions["axisY"],
@@ -8660,19 +8669,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8660
8669
  rows = [];
8661
8670
  } else {
8662
8671
  rows = cols;
8663
- cols = [point.colKeys[1]];
8672
+ cols = [];
8664
8673
  }
8665
8674
  return { rows, cols };
8666
8675
  }
8667
8676
 
8668
- highchartsRenderer.getBreakdownXAxisLabelFormatter = function(chartSeries) {
8669
- const styleForBreakdownLabel = 'font-weight: normal; color: #51566f;';
8670
- return function() {
8671
- const isTotal = lodash.some(chartSeries[0].data, point => point.name === this.value && point.isTotal);
8672
- return `<span style="${ isTotal ? '' : styleForBreakdownLabel }">${ this.value }</span>`;
8673
- }
8674
- }
8675
-
8676
8677
  return highchartsRenderer;
8677
8678
  };
8678
8679