@datarailsshared/dr_renderer 1.5.94 → 1.5.103
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 +3 -5
- package/src/highcharts_renderer.js +17 -38
- package/src/index.d.ts +10 -2
- package/src/index.js +2 -2
- package/tests/highcharts_renderer.test.js +6 -13
package/package.json
CHANGED
package/src/dr_pivottable.js
CHANGED
|
@@ -10,8 +10,6 @@ let initDRPivotTable = function($, window, document) {
|
|
|
10
10
|
const newTableColors = ['rgb(127, 196, 255)', 'rgb(200, 243,243)', 'rgb(247, 161, 173)', 'rgb(255, 237, 178)', 'rgb(221, 239, 255)',
|
|
11
11
|
'rgb(171, 216, 255)', 'rgb(174, 231, 220)', 'rgb(227, 255, 236)', 'rgb(162, 215, 227)', 'rgb(223, 239, 236)'];
|
|
12
12
|
|
|
13
|
-
const useNewUx = document.ReportHippo && document.ReportHippo && document.ReportHippo.user &&
|
|
14
|
-
document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.use_new_ux;
|
|
15
13
|
// const numberOfRows = 500; // change to activate the handsontable when num of rows bigger then this.
|
|
16
14
|
|
|
17
15
|
DRPivotData = (function(superClass) {
|
|
@@ -437,7 +435,7 @@ let initDRPivotTable = function($, window, document) {
|
|
|
437
435
|
colors = newTableColors;
|
|
438
436
|
}
|
|
439
437
|
|
|
440
|
-
var isNewDesign =
|
|
438
|
+
var isNewDesign = opts.chartOptions && opts.chartOptions.table_options && opts.chartOptions.table_options.use_new_table_design;
|
|
441
439
|
if (value) {
|
|
442
440
|
var offset = parseInt(value);
|
|
443
441
|
if (offset) {
|
|
@@ -500,12 +498,12 @@ let initDRPivotTable = function($, window, document) {
|
|
|
500
498
|
};
|
|
501
499
|
|
|
502
500
|
createTotalValsBolder = function(element){
|
|
503
|
-
if(opts.chartOptions.table_options.colorize_headers == true && (!
|
|
501
|
+
if(opts.chartOptions.table_options.colorize_headers == true && (!opts.chartOptions.table_options.use_new_table_design)){
|
|
504
502
|
element.style.setProperty("border-bottom", "3px double #000000", "important");
|
|
505
503
|
}
|
|
506
504
|
};
|
|
507
505
|
createGrandTotalBolder = function(element){
|
|
508
|
-
if(opts.chartOptions.table_options.colorize_headers == true && (!
|
|
506
|
+
if(opts.chartOptions.table_options.colorize_headers == true && (!opts.chartOptions.table_options.use_new_table_design)){
|
|
509
507
|
element.style.setProperty("border-top", "3px solid #000000", "important");
|
|
510
508
|
}
|
|
511
509
|
};
|
|
@@ -173,7 +173,7 @@ const FEATURES = helpers.FEATURES;
|
|
|
173
173
|
const TICKS_COUNT = 5;
|
|
174
174
|
|
|
175
175
|
let getHighchartsRenderer = function ($, document, Highcharts, default_colors, highchartsRenderer,
|
|
176
|
-
DataFormatter, lodash, moment_lib, isNewAngular) {
|
|
176
|
+
DataFormatter, lodash, moment_lib, isNewAngular, envOptions) {
|
|
177
177
|
|
|
178
178
|
/** Highcharts initial configuration section **/
|
|
179
179
|
if(!lodash){
|
|
@@ -214,6 +214,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
214
214
|
|
|
215
215
|
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
|
216
216
|
let disableAnimation = false;
|
|
217
|
+
const environment = envOptions || {};
|
|
218
|
+
highchartsRenderer.environment = environment;
|
|
217
219
|
|
|
218
220
|
const _handleComputationalError = (err, onlyOptions) => {
|
|
219
221
|
if (err instanceof BaseRendererError) {
|
|
@@ -244,13 +246,14 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
highchartsRenderer.hasFeature = function(featureFlagKey) {
|
|
247
|
-
return lodash.includes(
|
|
249
|
+
return lodash.includes(highchartsRenderer.features || [], featureFlagKey);
|
|
248
250
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
disableAnimation = document.ReportHippo.user.organization && document.ReportHippo.user.organization.settings && document.ReportHippo.user.organization.settings.disable_animation
|
|
251
|
+
highchartsRenderer.setFeatures = function(features) {
|
|
252
|
+
highchartsRenderer.features = features || [];
|
|
252
253
|
highchartsRenderer.enabledNewWidgetValueFormatting = highchartsRenderer.hasFeature(FEATURES.ENABLE_NEW_WIDGET_VALUE_FORMATTING);
|
|
253
254
|
}
|
|
255
|
+
highchartsRenderer.setFeatures(lodash.get(environment, 'features', []));
|
|
256
|
+
disableAnimation = !!lodash.get(environment, 'disable_animation', false);
|
|
254
257
|
|
|
255
258
|
// fix issue of use tootip.stickOnContact with tooltip.outside , source: https://github.com/highcharts/highcharts/pull/15960
|
|
256
259
|
// TODO: remove it after it is fixed in highcharts library new version
|
|
@@ -544,30 +547,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
544
547
|
return chart_option;
|
|
545
548
|
}
|
|
546
549
|
|
|
547
|
-
/**
|
|
548
|
-
* @deprecated For new angular just use hcInstance
|
|
549
|
-
*/
|
|
550
|
-
highchartsRenderer.downloadFile = function (title, graph_id, type) {
|
|
551
|
-
let chart = null;
|
|
552
|
-
|
|
553
|
-
const chartElement = $('#' + graph_id).find('div.chart');
|
|
554
|
-
if (chartElement.highcharts) {
|
|
555
|
-
// old angular
|
|
556
|
-
chart = chartElement.highcharts();
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
if (!chart) return;
|
|
560
|
-
|
|
561
|
-
if (type === 'png') {
|
|
562
|
-
chart.exportChartLocal({
|
|
563
|
-
filename: title
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
if (type === 'XLS') {
|
|
567
|
-
chart.downloadXLS();
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
|
|
571
550
|
//TODO No totals formatts
|
|
572
551
|
highchartsRenderer.defaultValueLabelsFormatter = function (pivotData, opts, forcePercentage = false) {
|
|
573
552
|
const deltaColumn = lodash.get(opts, 'chartOptions.delta_column', null);
|
|
@@ -988,7 +967,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
988
967
|
tempAr[temp_len - 1] = highchartsRenderer.getFieldName(colAttrs[j]);
|
|
989
968
|
}
|
|
990
969
|
|
|
991
|
-
const formattedColKeys = highchartsRenderer.getFormattedColKeys(pivotData, null);
|
|
970
|
+
const formattedColKeys = highchartsRenderer.getFormattedColKeys(pivotData, null, true);
|
|
992
971
|
tempAr = tempAr.concat(lodash.map(formattedColKeys, function (row) {
|
|
993
972
|
return row[j];
|
|
994
973
|
}));
|
|
@@ -9464,11 +9443,11 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9464
9443
|
}
|
|
9465
9444
|
|
|
9466
9445
|
highchartsRenderer.getFiscalYearMonthModifier = function() {
|
|
9467
|
-
return lodash.get(
|
|
9446
|
+
return lodash.get(highchartsRenderer, 'environment.fiscal_year_starts_from', 1) - 1;
|
|
9468
9447
|
}
|
|
9469
9448
|
|
|
9470
9449
|
highchartsRenderer.isFiscalYearBackEnabled = function() {
|
|
9471
|
-
return lodash.get(
|
|
9450
|
+
return lodash.get(highchartsRenderer, 'environment.fiscal_year_back');
|
|
9472
9451
|
}
|
|
9473
9452
|
|
|
9474
9453
|
highchartsRenderer.getTimeframeByFormat = function(format) {
|
|
@@ -9528,7 +9507,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9528
9507
|
}
|
|
9529
9508
|
|
|
9530
9509
|
// Method for getting formatted kyes for Axis (cols, rows)
|
|
9531
|
-
highchartsRenderer.getFormattedKey = function (initialKey, pivotData, type) {
|
|
9510
|
+
highchartsRenderer.getFormattedKey = function (initialKey, pivotData, type, forceFormatDates) {
|
|
9532
9511
|
const isFlatKey = lodash.isString(initialKey) || lodash.isNumber(initialKey);
|
|
9533
9512
|
if (isFlatKey || lodash.isArray(initialKey)) {
|
|
9534
9513
|
let values = isFlatKey ? initialKey.toString().split(highchartsRenderer.delimer) : lodash.cloneDeep(initialKey);
|
|
@@ -9537,7 +9516,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9537
9516
|
const formatInfo = pivotData[type][key] || {};
|
|
9538
9517
|
const valueToFloat = parseFloat(value);
|
|
9539
9518
|
const isDate = formatInfo.type === 'Date' && (moment_lib(valueToFloat).isValid() || moment_lib(value, formatInfo.format).isValid());
|
|
9540
|
-
const isDateFormatting = isDate && highchartsRenderer.isFormattingDatesAsOtherAxisTypes();
|
|
9519
|
+
const isDateFormatting = isDate && (forceFormatDates || highchartsRenderer.isFormattingDatesAsOtherAxisTypes());
|
|
9541
9520
|
const isNumberFormatting = !isDate && formatInfo.format && highchartsRenderer.isFormattingNumberAxis(pivotData);
|
|
9542
9521
|
|
|
9543
9522
|
if (isNumberFormatting || isDateFormatting) {
|
|
@@ -9565,13 +9544,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
9565
9544
|
return highchartsRenderer.getFormattedKey(initialValue, pivotData, 'rowFormats')
|
|
9566
9545
|
}
|
|
9567
9546
|
|
|
9568
|
-
highchartsRenderer.getFormattedKeys = function(pivotData, isCols, keys) {
|
|
9547
|
+
highchartsRenderer.getFormattedKeys = function(pivotData, isCols, keys, forceFormatDates) {
|
|
9569
9548
|
keys = keys || (isCols ? pivotData.getColKeys() : pivotData.getRowKeys());
|
|
9570
|
-
return lodash.map(keys, key => highchartsRenderer.getFormattedKey(key, pivotData, isCols ? 'colFormats' : 'rowFormats'));
|
|
9549
|
+
return lodash.map(keys, key => highchartsRenderer.getFormattedKey(key, pivotData, isCols ? 'colFormats' : 'rowFormats', forceFormatDates));
|
|
9571
9550
|
}
|
|
9572
9551
|
|
|
9573
|
-
highchartsRenderer.getFormattedColKeys = function(pivotData, keys) {
|
|
9574
|
-
return highchartsRenderer.getFormattedKeys(pivotData, true, keys);
|
|
9552
|
+
highchartsRenderer.getFormattedColKeys = function(pivotData, keys, forceFormatDates) {
|
|
9553
|
+
return highchartsRenderer.getFormattedKeys(pivotData, true, keys, forceFormatDates);
|
|
9575
9554
|
}
|
|
9576
9555
|
|
|
9577
9556
|
highchartsRenderer.getFormattedRowKeys = function(pivotData, keys) {
|
package/src/index.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ declare namespace DrRenderFactory {
|
|
|
31
31
|
isNewAngular: boolean;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
interface EnvironmentOptions {
|
|
35
|
+
features?: string[];
|
|
36
|
+
disable_animation?: boolean;
|
|
37
|
+
fiscal_year_starts_from?: number;
|
|
38
|
+
fiscal_year_back?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
interface Factory {
|
|
35
42
|
init($: any, window: Window, document: Document, Handsontable?: any): void;
|
|
36
43
|
getInitHighchartsRenderer(
|
|
@@ -41,12 +48,13 @@ declare namespace DrRenderFactory {
|
|
|
41
48
|
highchartsRenderer: any,
|
|
42
49
|
lodash: any,
|
|
43
50
|
moment_lib: any,
|
|
44
|
-
isNewAngular: boolean
|
|
51
|
+
isNewAngular: boolean,
|
|
52
|
+
envOptions?: EnvironmentOptions
|
|
45
53
|
): any;
|
|
46
54
|
getInitPublishedItemsRenderer(publishedItemsRenderer: any, bind?: any): any;
|
|
47
55
|
|
|
48
56
|
DataFormatter: typeof DataFormatterType;
|
|
49
|
-
|
|
57
|
+
|
|
50
58
|
// Error types and classes
|
|
51
59
|
RendererErrorCodes: typeof ErrorTypes.RendererErrorCodes;
|
|
52
60
|
BaseRendererError: typeof ErrorTypes.BaseRendererError;
|
package/src/index.js
CHANGED
|
@@ -17,8 +17,8 @@ dr_render_factory.init = function($, window, document, Handsontable){
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
dr_render_factory.getInitHighchartsRenderer = function($, document, Highcharts, default_colors, highchartsRenderer, lodash, moment_lib, isNewAngular){
|
|
21
|
-
return getHighchartsRenderer($, document, Highcharts, default_colors, highchartsRenderer, DataFormatter, lodash, moment_lib, isNewAngular);
|
|
20
|
+
dr_render_factory.getInitHighchartsRenderer = function($, document, Highcharts, default_colors, highchartsRenderer, lodash, moment_lib, isNewAngular, envOptions){
|
|
21
|
+
return getHighchartsRenderer($, document, Highcharts, default_colors, highchartsRenderer, DataFormatter, lodash, moment_lib, isNewAngular, envOptions);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
dr_render_factory.getInitPublishedItemsRenderer = function (publishedItemsRenderer, bind = {}) {
|
|
@@ -338,12 +338,6 @@ describe('highcharts_renderer', () => {
|
|
|
338
338
|
});
|
|
339
339
|
});
|
|
340
340
|
|
|
341
|
-
describe('function downloadFile', () => {
|
|
342
|
-
it('Old angular. No chart', () => {
|
|
343
|
-
expect(highchartsRenderer.downloadFile('test', '2_2', 'png')).toEqual(undefined)
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
|
|
347
341
|
describe('function defaultValueLabelsFormatter', () => {
|
|
348
342
|
let funcContext;
|
|
349
343
|
|
|
@@ -1630,7 +1624,7 @@ describe('highcharts_renderer', () => {
|
|
|
1630
1624
|
|
|
1631
1625
|
describe('dynamic system fields', () => {
|
|
1632
1626
|
it('should count Scenario & Budget Cycle as system field', () => {
|
|
1633
|
-
|
|
1627
|
+
highchartsRenderer.setFeatures(['multiple_dimension_tags', 'use_new_scenario_tag']);
|
|
1634
1628
|
|
|
1635
1629
|
const fieldWithScenario = { name: 'Scenario' };
|
|
1636
1630
|
expect(highchartsRenderer.isSystemField(fieldWithScenario)).toBe(true);
|
|
@@ -5091,7 +5085,7 @@ describe('highcharts_renderer', () => {
|
|
|
5091
5085
|
});
|
|
5092
5086
|
|
|
5093
5087
|
it('should return formatted multivalue colKey as array (format_dates_as_other_axis_types is ON)', () => {
|
|
5094
|
-
|
|
5088
|
+
highchartsRenderer.setFeatures(['format_dates_as_other_axis_types']);
|
|
5095
5089
|
const initialKey = [1687277052, 1687277052];
|
|
5096
5090
|
const pivotData = {
|
|
5097
5091
|
colFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
@@ -5103,7 +5097,7 @@ describe('highcharts_renderer', () => {
|
|
|
5103
5097
|
});
|
|
5104
5098
|
|
|
5105
5099
|
it('should return formatted multivalue rowKey as array (format_dates_as_other_axis_types is ON)', () => {
|
|
5106
|
-
|
|
5100
|
+
highchartsRenderer.setFeatures(['format_dates_as_other_axis_types']);
|
|
5107
5101
|
const initialKey = [1687277052, 1687277052];
|
|
5108
5102
|
const pivotData = {
|
|
5109
5103
|
rowFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
@@ -5115,7 +5109,7 @@ describe('highcharts_renderer', () => {
|
|
|
5115
5109
|
});
|
|
5116
5110
|
|
|
5117
5111
|
it('should return NOT formatted multivalue colKey as array (format_dates_as_other_axis_types is OFF)', () => {
|
|
5118
|
-
|
|
5112
|
+
highchartsRenderer.setFeatures([]);
|
|
5119
5113
|
const initialKeyAlreadyFormatted = ['10/10/2020', '10/10/2021'];
|
|
5120
5114
|
const pivotData = {
|
|
5121
5115
|
colFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
@@ -5127,7 +5121,7 @@ describe('highcharts_renderer', () => {
|
|
|
5127
5121
|
});
|
|
5128
5122
|
|
|
5129
5123
|
it('should return NOT formatted multivalue rowKey as array (format_dates_as_other_axis_types is OFF)', () => {
|
|
5130
|
-
|
|
5124
|
+
highchartsRenderer.setFeatures([]);
|
|
5131
5125
|
const initialKeyAlreadyFormatted = ['10/10/2020', '10/10/2021'];
|
|
5132
5126
|
const pivotData = {
|
|
5133
5127
|
rowFormats: [{ type: 'Date', format: 'MM/DD/YYYY' }, { type: 'Date', format: 'MMM-yy' }],
|
|
@@ -5272,7 +5266,7 @@ describe('highcharts_renderer', () => {
|
|
|
5272
5266
|
|
|
5273
5267
|
it('should getFormattedColKeys call getFormattedKeys for colFormats', () => {
|
|
5274
5268
|
highchartsRenderer.getFormattedColKeys('test1', 'test2');
|
|
5275
|
-
expect(highchartsRenderer.getFormattedKeys).toHaveBeenCalledWith('test1', true, 'test2');
|
|
5269
|
+
expect(highchartsRenderer.getFormattedKeys).toHaveBeenCalledWith('test1', true, 'test2', undefined);
|
|
5276
5270
|
});
|
|
5277
5271
|
|
|
5278
5272
|
it('should getFormattedRowKeys call getFormattedKeys for rowFormats', () => {
|
|
@@ -9406,5 +9400,4 @@ describe('highcharts_renderer', () => {
|
|
|
9406
9400
|
expect(result).toEqual({ activeDataLabelStyle: { color: mockColor } });
|
|
9407
9401
|
});
|
|
9408
9402
|
});
|
|
9409
|
-
|
|
9410
9403
|
});
|