@datarailsshared/dr_renderer 1.2.423 → 1.2.425
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 +1 -1
- package/src/dr_pivottable.js +7 -44
- package/src/highcharts_renderer.js +0 -27
- package/tests/highcharts_renderer.test.js +15 -58
package/package.json
CHANGED
package/src/dr_pivottable.js
CHANGED
@@ -454,11 +454,11 @@ let initDRPivotTable = function($, window, document) {
|
|
454
454
|
}
|
455
455
|
|
456
456
|
SubtotalRenderer = function(pivotData, opts, charttype, tooMuch = false, error_params) {
|
457
|
-
var addClass, allTotal, arrowCollapsed, arrowExpanded, buildColHeaderHeader, buildColHeaderHeaders, buildColHeaderHeadersClickEvents, buildColHeaders, buildColTotals, buildColTotalsHeader, buildGrandTotal, buildRowHeaderHeaders, buildRowHeaderHeadersClickEvents, buildRowHeaders, buildRowTotalsHeader, buildValues, classColCollapsed, classColExpanded, classColHide, classColShow, classCollapsed, classExpanded, classRowCollapsed, classRowExpanded, classRowHide, classRowShow, clickStatusCollapsed, clickStatusExpanded, colAttrs, colDisableAfter, colKeys, colTotals, collapseCol, collapseColsAt, collapseHideDescendantRow, collapseRow, collapseRowsAt, collapseShowColSubtotal, collapseShowRowSubtotal, applyInlineStyles, createElement, defaults, expandChildCol, expandChildRow, expandCol, expandColsAt, expandHideColSubtotal, expandHideRowSubtotal, expandRow, expandRowsAt, expandShowColSubtotal, expandShowRowSubtotal, getTableEventHandlers, hasClass, hideDescendantCol, isColDisable, isColDisableExpandCollapse, isColHideOnExpand, isRowDisable, isRowDisableExpandCollapse, isRowHideOnExpand, main, getSubtotalInBrackets, processKeys, encodeHtmlEntities, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, removeClass, replaceClass, rowAttrs, rowDisableAfter, rowKeys, rowTotals, setAttributes, showChildCol, showChildRow, toggleCol, toggleColHeaderHeader, toggleRow, toggleRowHeaderHeader, tree,
|
457
|
+
var addClass, allTotal, arrowCollapsed, arrowExpanded, buildColHeaderHeader, buildColHeaderHeaders, buildColHeaderHeadersClickEvents, buildColHeaders, buildColTotals, buildColTotalsHeader, buildGrandTotal, buildRowHeaderHeaders, buildRowHeaderHeadersClickEvents, buildRowHeaders, buildRowTotalsHeader, buildValues, classColCollapsed, classColExpanded, classColHide, classColShow, classCollapsed, classExpanded, classRowCollapsed, classRowExpanded, classRowHide, classRowShow, clickStatusCollapsed, clickStatusExpanded, colAttrs, colDisableAfter, colKeys, colTotals, collapseCol, collapseColsAt, collapseHideDescendantRow, collapseRow, collapseRowsAt, collapseShowColSubtotal, collapseShowRowSubtotal, applyInlineStyles, createElement, defaults, expandChildCol, expandChildRow, expandCol, expandColsAt, expandHideColSubtotal, expandHideRowSubtotal, expandRow, expandRowsAt, expandShowColSubtotal, expandShowRowSubtotal, getTableEventHandlers, hasClass, hideDescendantCol, isColDisable, isColDisableExpandCollapse, isColHideOnExpand, isRowDisable, isRowDisableExpandCollapse, isRowHideOnExpand, main, getSubtotalInBrackets, processKeys, encodeHtmlEntities, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, removeClass, replaceClass, rowAttrs, rowDisableAfter, rowKeys, rowTotals, setAttributes, showChildCol, showChildRow, toggleCol, toggleColHeaderHeader, toggleRow, toggleRowHeaderHeader, tree, subscribeToClick;
|
458
458
|
var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, handleFreezePanesScroll, selectFreezableElements, removeRowHeaderNullValue;
|
459
459
|
var getAdditionalAggregation, buildAdditionalHeaderCols, buildAdditionalHeaderRows, buildAdditionalColValues, buildAdditionalRowValues, buildAdditionalRowTotals, buildAdditionalColTotals;
|
460
460
|
var additionalFieldsCol, additionalFieldsRow, additionalFieldsList;
|
461
|
-
var
|
461
|
+
var getExistingAggregator;
|
462
462
|
|
463
463
|
var horizontalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' horizontal-freeze-pane' : '';
|
464
464
|
var verticalFreezePaneClass = opts.chartOptions.table_options.freeze_panes ? ' vertical-freeze-pane' : '';
|
@@ -509,7 +509,6 @@ let initDRPivotTable = function($, window, document) {
|
|
509
509
|
if(opts.chartOptions.table_options.start_collapsed_columns) {
|
510
510
|
opts.collapseColsAt = 0;
|
511
511
|
}
|
512
|
-
edit_assumptions = opts.chartOptions.edit_assumptions;
|
513
512
|
isRowDisable = (ref = opts.rowSubtotalDisplay) != null ? ref.disableSubtotal : void 0;
|
514
513
|
isRowHideOnExpand = (ref1 = opts.rowSubtotalDisplay) != null ? ref1.hideOnExpand : !opts.chartOptions.table_options.show_subtotals_for_rows;
|
515
514
|
isRowDisableExpandCollapse = (ref2 = opts.rowSubtotalDisplay) != null ? ref2.disableExpandCollapse : void 0;
|
@@ -1540,7 +1539,7 @@ let initDRPivotTable = function($, window, document) {
|
|
1540
1539
|
if ((isRowSubtotal && (isRowHideOnExpand || isRowDisable || rowHeader.col > rowDisableAfter)) || (isColSubtotal && (isColHideOnExpand || isColDisable || colHeader.col > colDisableAfter))) {
|
1541
1540
|
td.style.display = "none";
|
1542
1541
|
}
|
1543
|
-
|
1542
|
+
subscribeToClick(td, rowHeader, rowAttrs, colHeader, colAttrs, val);
|
1544
1543
|
|
1545
1544
|
tr.appendChild(td);
|
1546
1545
|
}
|
@@ -1578,7 +1577,7 @@ let initDRPivotTable = function($, window, document) {
|
|
1578
1577
|
td.style.display = "none";
|
1579
1578
|
}
|
1580
1579
|
|
1581
|
-
|
1580
|
+
subscribeToClick(td, rowHeader, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
1582
1581
|
|
1583
1582
|
if(opts.chartOptions.table_options.show_row_total)
|
1584
1583
|
tr.appendChild(td);
|
@@ -1588,43 +1587,7 @@ let initDRPivotTable = function($, window, document) {
|
|
1588
1587
|
return results;
|
1589
1588
|
};
|
1590
1589
|
|
1591
|
-
|
1592
|
-
if(edit_assumptions){
|
1593
|
-
var filters = [];
|
1594
|
-
var i=0;
|
1595
|
-
var temp;
|
1596
|
-
for(i=0; i<rowHeader.key.length; i++){
|
1597
|
-
temp = {
|
1598
|
-
name: rowAttrs[i],
|
1599
|
-
values: [rowHeader.key[i]],
|
1600
|
-
is_excluded:false
|
1601
|
-
}
|
1602
|
-
filters.push(temp);
|
1603
|
-
}
|
1604
|
-
for(i=0; i<colHeader.key.length; i++){
|
1605
|
-
temp = {
|
1606
|
-
name: colAttrs[i],
|
1607
|
-
values: [colHeader.key[i]],
|
1608
|
-
is_excluded:false
|
1609
|
-
}
|
1610
|
-
filters.push(temp);
|
1611
|
-
}
|
1612
|
-
var obj_to_send = {
|
1613
|
-
"flatColKey": colHeader.flatKey,
|
1614
|
-
"flatRowKey": rowHeader.flatKey,
|
1615
|
-
"val": val,
|
1616
|
-
"filters": filters
|
1617
|
-
};
|
1618
|
-
|
1619
|
-
// td.addEventListener('dblclick', function(){
|
1620
|
-
// edit_assumptions.fn(obj_to_send, this);
|
1621
|
-
// });
|
1622
|
-
|
1623
|
-
td.addEventListener('click', function(){
|
1624
|
-
edit_assumptions.fn(obj_to_send, this);
|
1625
|
-
});
|
1626
|
-
}
|
1627
|
-
|
1590
|
+
subscribeToClick = function(td, rowHeader, rowAttrs, colHeader, colAttrs, val){
|
1628
1591
|
if(opts.value_drill_down_fn){
|
1629
1592
|
td.classList.add('clickable');
|
1630
1593
|
td.addEventListener('click', function(rowKey, colKey, rowAttrs, colAttrs){
|
@@ -1685,7 +1648,7 @@ let initDRPivotTable = function($, window, document) {
|
|
1685
1648
|
td.style.display = "none";
|
1686
1649
|
}
|
1687
1650
|
|
1688
|
-
|
1651
|
+
subscribeToClick(td, {key:[], flatKey:''}, rowAttrs, h, colAttrs, val);
|
1689
1652
|
|
1690
1653
|
results.push(tr.appendChild(td));
|
1691
1654
|
}
|
@@ -1711,7 +1674,7 @@ let initDRPivotTable = function($, window, document) {
|
|
1711
1674
|
"data-value": val
|
1712
1675
|
}, getTableEventHandlers(val, [], []));
|
1713
1676
|
createTotalValsBolder(td);
|
1714
|
-
|
1677
|
+
subscribeToClick(td, {key:[], flatKey:''}, rowAttrs, {key:[], flatKey:''}, colAttrs, val);
|
1715
1678
|
|
1716
1679
|
tr.appendChild(td);
|
1717
1680
|
return result.appendChild(tr);
|
@@ -1985,7 +1985,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
1985
1985
|
highchartsRenderer.getDataLabelsStylesForDrillDown = function(additionOptions) {
|
1986
1986
|
let result = highchartsRenderer.getDataLabelsOptions(additionOptions, { dataLabels: {} });
|
1987
1987
|
|
1988
|
-
if (!result.dataLabels) return {};
|
1989
1988
|
return {
|
1990
1989
|
activeDataLabelStyle: {
|
1991
1990
|
color: result.dataLabels.color,
|
@@ -8483,32 +8482,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
8483
8482
|
return presentation_data_tag;
|
8484
8483
|
};
|
8485
8484
|
|
8486
|
-
highchartsRenderer.getDashboardApplyScenarios = function (data_model, graph, local_current_dashboard) {
|
8487
|
-
if (local_current_dashboard == undefined) {
|
8488
|
-
local_current_dashboard = data_model.current_dashboard;
|
8489
|
-
}
|
8490
|
-
|
8491
|
-
let applyScenarios = [];
|
8492
|
-
if (data_model.ebmedded_apply_scenario_ids && data_model.ebmedded_apply_scenario_ids.length > 0) {
|
8493
|
-
return data_model.ebmedded_apply_scenario_ids;
|
8494
|
-
}
|
8495
|
-
|
8496
|
-
if (local_current_dashboard && graph && graph.vals && graph.vals.length == 1) {
|
8497
|
-
// Check Scenarios
|
8498
|
-
lodash.forEach(local_current_dashboard.scenario_models, function (dashboard_scenario_model) {
|
8499
|
-
if (dashboard_scenario_model && dashboard_scenario_model.value && dashboard_scenario_model.scenario_model && dashboard_scenario_model.scenario_model.source_fields) {
|
8500
|
-
if (lodash.includes(dashboard_scenario_model.scenario_model.source_fields, graph.vals[0].field)) {
|
8501
|
-
let selected_scenario = lodash.find(dashboard_scenario_model.scenario_model.scenarios, {id: dashboard_scenario_model.value});
|
8502
|
-
if (selected_scenario) {
|
8503
|
-
applyScenarios.push(selected_scenario);
|
8504
|
-
}
|
8505
|
-
}
|
8506
|
-
}
|
8507
|
-
});
|
8508
|
-
}
|
8509
|
-
return lodash.map(applyScenarios, 'id');
|
8510
|
-
};
|
8511
|
-
|
8512
8485
|
highchartsRenderer.isDate = function (date) {
|
8513
8486
|
return new Date(date) !== "Invalid Date" && !isNaN(new Date(date));
|
8514
8487
|
};
|
@@ -4155,64 +4155,6 @@ describe('highcharts_renderer', () => {
|
|
4155
4155
|
});
|
4156
4156
|
});
|
4157
4157
|
|
4158
|
-
describe('function getDashboardApplyScenarios', () => {
|
4159
|
-
let data_model;
|
4160
|
-
let graph;
|
4161
|
-
|
4162
|
-
beforeEach(() => {
|
4163
|
-
graph = { vals: [{ field: 'field1' }] };
|
4164
|
-
data_model = {
|
4165
|
-
current_dashboard: {
|
4166
|
-
scenario_models: [
|
4167
|
-
{
|
4168
|
-
value: 1,
|
4169
|
-
scenario_model: { source_fields: ['field1'], scenarios: [{ id: 1 }, { id: 2 }] },
|
4170
|
-
},
|
4171
|
-
{
|
4172
|
-
value: 2,
|
4173
|
-
scenario_model: { source_fields: ['field2'], scenarios: [{ id: 3 }, { id: 4 }] },
|
4174
|
-
},
|
4175
|
-
],
|
4176
|
-
},
|
4177
|
-
ebmedded_apply_scenario_ids: [],
|
4178
|
-
};
|
4179
|
-
});
|
4180
|
-
|
4181
|
-
it('returns ebmedded_apply_scenario_ids if data_model has it', () => {
|
4182
|
-
data_model.ebmedded_apply_scenario_ids = [5, 6];
|
4183
|
-
const local_current_dashboard = { foo: 'bar' };
|
4184
|
-
const result = highchartsRenderer.getDashboardApplyScenarios(data_model, graph, local_current_dashboard);
|
4185
|
-
expect(result).toEqual([5, 6]);
|
4186
|
-
});
|
4187
|
-
|
4188
|
-
it('returns empty array if scenario_models in local_current_dashboard are not provided', () => {
|
4189
|
-
const result = highchartsRenderer.getDashboardApplyScenarios(data_model, {vals: [null]}, {});
|
4190
|
-
expect(result).toEqual([]);
|
4191
|
-
});
|
4192
|
-
|
4193
|
-
it('returns empty array if graph has no vals', () => {
|
4194
|
-
const result = highchartsRenderer.getDashboardApplyScenarios(data_model, {});
|
4195
|
-
expect(result).toEqual([]);
|
4196
|
-
});
|
4197
|
-
|
4198
|
-
it('returns empty array if graph has more than one val', () => {
|
4199
|
-
const graph = { vals: [{ field: 'field1' }, { field: 'field2' }] };
|
4200
|
-
const result = highchartsRenderer.getDashboardApplyScenarios(data_model, graph, {});
|
4201
|
-
expect(result).toEqual([]);
|
4202
|
-
});
|
4203
|
-
|
4204
|
-
it('returns array of selected scenario ids', () => {
|
4205
|
-
const result = highchartsRenderer.getDashboardApplyScenarios(data_model, graph, data_model.current_dashboard);
|
4206
|
-
expect(result).toEqual([1]);
|
4207
|
-
});
|
4208
|
-
|
4209
|
-
it('returns empty array if no matching scenario is found', () => {
|
4210
|
-
const graph = { vals: [{ field: 'field3' }] };
|
4211
|
-
const result = highchartsRenderer.getDashboardApplyScenarios(data_model, graph, data_model.current_dashboard);
|
4212
|
-
expect(result).toEqual([]);
|
4213
|
-
});
|
4214
|
-
});
|
4215
|
-
|
4216
4158
|
describe('function isDate', () => {
|
4217
4159
|
it('returns true for valid date string', () => {
|
4218
4160
|
expect(highchartsRenderer.isDate('2022-01-01')).toBe(true);
|
@@ -8931,4 +8873,19 @@ describe('highcharts_renderer', () => {
|
|
8931
8873
|
});
|
8932
8874
|
});
|
8933
8875
|
|
8876
|
+
describe('Function getDataLabelsStylesForDrillDown', () => {
|
8877
|
+
|
8878
|
+
it('should return an object with activeDataLabelStyle containing color from dataLabels', () => {
|
8879
|
+
const mockColor = 'red';
|
8880
|
+
const additionalOptions = {
|
8881
|
+
label_option: {
|
8882
|
+
font_color: mockColor,
|
8883
|
+
},
|
8884
|
+
};
|
8885
|
+
|
8886
|
+
const result = highchartsRenderer.getDataLabelsStylesForDrillDown(additionalOptions);
|
8887
|
+
expect(result).toEqual({ activeDataLabelStyle: { color: mockColor } });
|
8888
|
+
});
|
8889
|
+
});
|
8890
|
+
|
8934
8891
|
});
|