@datarailsshared/dr_renderer 1.2.196-dragons → 1.2.198

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.198",
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;
1388
1382
 
1383
+ if (col_index) {
1384
+ const value = val - breakdownValues[col_index - 1][row_index];
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 = {
@@ -4360,12 +4371,15 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
4360
4371
  );
4361
4372
 
4362
4373
  if (uniqueCategories && (uniqueCategories.length > maxCategories || uniqueCategories.length < minCategories )) {
4374
+ const commonErrorSentence = `Please choose ${ minCategories }-${ maxCategories } items in the Category section.`
4363
4375
  options.error_has_occurred = true;
4364
4376
  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' ,
4377
+ title: uniqueCategories.length > maxCategories
4378
+ ? `There is too much data. ${ commonErrorSentence }`
4379
+ : `Not enough data. ${ commonErrorSentence }`,
4380
+ text: '',
4381
+ btnText: 'Edit Widget',
4382
+ class: 'too-much-data',
4369
4383
  }
4370
4384
  return highchartsRenderer.getNoDataResult(options.rendererOptions, true);
4371
4385
  }
@@ -6784,18 +6798,16 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
6784
6798
 
6785
6799
  highchartsRenderer.chartsTypesInfo = {
6786
6800
  [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.',
6801
+ name: 'Waterfall Breakdown Chart ',
6802
+ label: 'Waterfall Breakdown Chart ',
6803
+ title: 'TODO: add text',
6804
+ description: 'TODO: add text',
6791
6805
  titleInEditor: 'This chart displays the breakdown of variance between two or more total values.',
6792
6806
  axisName: 'Category',
6793
6807
  legendName: 'Breakdown',
6794
6808
  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.',
6809
+ axisTooltipTitle: 'TODO: add text',
6810
+ legendTooltipTitle: 'TODO: add text',
6799
6811
  },
6800
6812
  'combo-chart': {
6801
6813
  name: 'Combo Chart ',
@@ -7432,12 +7444,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7432
7444
  {
7433
7445
  type: 'waterfall-chart',
7434
7446
  name: 'Waterfall',
7435
- class: 'google-visualization-charteditor-mini-waterfall',
7447
+ hidden: true,
7448
+ class: 'google-visualization-charteditor-mini-column',
7436
7449
  subtypes: [
7437
7450
  {
7438
7451
  type: highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN,
7439
7452
  name: highchartsRenderer.chartsTypesInfo[highchartsRenderer.CHART_TYPES.WATERFALL_BREAKDOWN].name,
7440
- class: 'google-visualization-charteditor-thumbs-breakdown',
7453
+ class: 'google-visualization-charteditor-thumbs-columnchart',
7441
7454
  render: highchartsRenderer.ptRenderWaterfallBreakdown,
7442
7455
  suboptions: [
7443
7456
  highchartsRenderer.suboptions["axisY"],
@@ -8660,7 +8673,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
8660
8673
  rows = [];
8661
8674
  } else {
8662
8675
  rows = cols;
8663
- cols = [point.colKeys[1]];
8676
+ cols = [];
8664
8677
  }
8665
8678
  return { rows, cols };
8666
8679
  }