@datarailsshared/dr_renderer 1.5.150 → 1.5.159
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 +5 -2
- package/src/charts/dr_donut_chart.d.ts +79 -0
- package/src/charts/dr_donut_chart.js +7 -2
- package/src/charts/dr_gauge_categories_summary_chart.d.ts +136 -0
- package/src/charts/dr_gauge_chart.d.ts +18 -0
- package/src/charts/dr_gauge_chart.js +31 -0
- package/src/dr-renderer-helpers.d.ts +18 -0
- package/src/dr-renderer-helpers.js +2 -2
- package/src/dr_pivottable.d.ts +2 -0
- package/src/dr_pivottable.js +32 -75
- package/src/errors.js +1 -0
- package/src/{types/graph-table-renderer.d.ts → graph-table-renderer.d.ts} +57 -4
- package/src/graph-table-renderer.js +74 -2
- package/src/highcharts_renderer.d.ts +5 -0
- package/src/highcharts_renderer.js +1 -0
- package/src/index.d.ts +83 -86
- package/src/index.js +77 -3
- package/src/novix_renderer.d.ts +2 -0
- package/src/novix_renderer.js +7 -0
- package/src/options/builders.js +1 -0
- package/src/options/constants.js +1 -0
- package/src/options/elements.js +1 -0
- package/src/options/helpers.js +1 -0
- package/src/options/index.js +1 -0
- package/src/options/presets.js +1 -0
- package/src/pivot-table/freeze-panes/constants.d.ts +26 -0
- package/src/pivot-table/freeze-panes/constants.js +42 -0
- package/src/pivot-table/freeze-panes/freeze-panes.css +282 -0
- package/src/pivot-table/freeze-panes/index.d.ts +115 -0
- package/src/pivot-table/freeze-panes/index.js +143 -0
- package/src/pivot-table/freeze-panes/sticky-strategy.d.ts +38 -0
- package/src/pivot-table/freeze-panes/sticky-strategy.js +247 -0
- package/src/pivot-table/freeze-panes/transform-strategy.d.ts +61 -0
- package/src/pivot-table/freeze-panes/transform-strategy.js +131 -0
- package/src/pivot.css +2 -98
- package/src/published_items_renderer.d.ts +10 -0
- package/src/seriesPointStyles-helper.d.ts +2 -0
- package/src/smart_queries_helper.d.ts +12 -0
- package/src/value.formatter.d.ts +3 -0
- package/tests/dr-renderer-helpers.test.js +29 -0
- package/tests/pivot-table/freeze-panes/constants.test.js +92 -0
- package/tests/pivot-table/freeze-panes/index.test.js +193 -0
- package/tests/pivot-table/freeze-panes/sticky-strategy.test.js +542 -0
- package/tests/pivot-table/freeze-panes/transform-strategy.test.js +304 -0
- package/tsconfig.json +7 -10
- package/src/types/index.d.ts +0 -12
- package/tsconfig.tsbuildinfo +0 -1
- /package/src/{types/errors.d.ts → errors.d.ts} +0 -0
- /package/src/{types/options → options}/builders.d.ts +0 -0
- /package/src/{types/options → options}/constants.d.ts +0 -0
- /package/src/{types/options → options}/elements.d.ts +0 -0
- /package/src/{types/options → options}/helpers.d.ts +0 -0
- /package/src/{types/options → options}/index.d.ts +0 -0
- /package/src/{types/options → options}/presets.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datarailsshared/dr_renderer",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.159",
|
|
4
4
|
"description": "DataRails charts and tables renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datarails",
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"login": "npm login",
|
|
13
13
|
"test": "jest --coverage",
|
|
14
|
-
"build:types": "npx tsc --build --verbose"
|
|
14
|
+
"build:types": "npx tsc --build --verbose",
|
|
15
|
+
"build:types:clean": "npx tsc --build --clean",
|
|
16
|
+
"watch": "npm run watch:types",
|
|
17
|
+
"watch:types": "npx tsc --build --watch"
|
|
15
18
|
},
|
|
16
19
|
"author": "Sergey Spivakov",
|
|
17
20
|
"repository": {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export function DrDonutChart(highchartsRenderer: any, pivotData: any, opts: any, drilldownFunc: any, disableAnimation: any): void;
|
|
2
|
+
export class DrDonutChart {
|
|
3
|
+
constructor(highchartsRenderer: any, pivotData: any, opts: any, drilldownFunc: any, disableAnimation: any);
|
|
4
|
+
render: () => any;
|
|
5
|
+
getConfig: () => {
|
|
6
|
+
chart: {
|
|
7
|
+
type: string;
|
|
8
|
+
events: {
|
|
9
|
+
drilldown: (e: any) => void;
|
|
10
|
+
drillup: (e: any) => void;
|
|
11
|
+
render: () => void;
|
|
12
|
+
};
|
|
13
|
+
animation: boolean;
|
|
14
|
+
};
|
|
15
|
+
plotOptions: {
|
|
16
|
+
series: {
|
|
17
|
+
animation: boolean;
|
|
18
|
+
dataLabels: {
|
|
19
|
+
allowOverlap: any;
|
|
20
|
+
enabled: any;
|
|
21
|
+
formatter: any;
|
|
22
|
+
style: any;
|
|
23
|
+
};
|
|
24
|
+
showInLegend: boolean;
|
|
25
|
+
innerSize: string;
|
|
26
|
+
states: {
|
|
27
|
+
hover: {
|
|
28
|
+
halo: {
|
|
29
|
+
size: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
colors: any;
|
|
36
|
+
tooltip: {
|
|
37
|
+
headerFormat: string;
|
|
38
|
+
pointFormatter: any;
|
|
39
|
+
};
|
|
40
|
+
legend: any;
|
|
41
|
+
};
|
|
42
|
+
getChartConfig: () => {
|
|
43
|
+
type: string;
|
|
44
|
+
events: {
|
|
45
|
+
drilldown: (e: any) => void;
|
|
46
|
+
drillup: (e: any) => void;
|
|
47
|
+
render: () => void;
|
|
48
|
+
};
|
|
49
|
+
animation: boolean;
|
|
50
|
+
};
|
|
51
|
+
getPlotOptionsConfig: () => {
|
|
52
|
+
series: {
|
|
53
|
+
animation: boolean;
|
|
54
|
+
dataLabels: {
|
|
55
|
+
allowOverlap: any;
|
|
56
|
+
enabled: any;
|
|
57
|
+
formatter: any;
|
|
58
|
+
style: any;
|
|
59
|
+
};
|
|
60
|
+
showInLegend: boolean;
|
|
61
|
+
innerSize: string;
|
|
62
|
+
states: {
|
|
63
|
+
hover: {
|
|
64
|
+
halo: {
|
|
65
|
+
size: number;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
getColorSettings: () => any;
|
|
72
|
+
getTooltipConfig: () => {
|
|
73
|
+
headerFormat: string;
|
|
74
|
+
pointFormatter: any;
|
|
75
|
+
};
|
|
76
|
+
drawTotalLabel: () => void;
|
|
77
|
+
setDrilldownConfig: (chartConfig: any) => void;
|
|
78
|
+
setChartPositioning: (chart: any) => void;
|
|
79
|
+
}
|
|
@@ -90,10 +90,15 @@ function DrDonutChart(highchartsRenderer, pivotData, opts, drilldownFunc, disabl
|
|
|
90
90
|
const series = chart.series[0];
|
|
91
91
|
|
|
92
92
|
const aggTotal = pivotData.getAggregator([], []);
|
|
93
|
+
const hasAggValue = aggTotal && typeof aggTotal.value === 'function';
|
|
94
|
+
const hasAggFormat = aggTotal && typeof aggTotal.format === 'function';
|
|
95
|
+
const totalValue = hasAggValue ? aggTotal.value() : series.total;
|
|
93
96
|
const formattedValue =
|
|
94
97
|
additionOptions && additionOptions.customTotalValueFormatFn
|
|
95
|
-
? additionOptions.customTotalValueFormatFn(
|
|
96
|
-
:
|
|
98
|
+
? additionOptions.customTotalValueFormatFn(totalValue)
|
|
99
|
+
: hasAggFormat
|
|
100
|
+
? aggTotal.format(totalValue, true)
|
|
101
|
+
: totalValue;
|
|
97
102
|
|
|
98
103
|
if (totalLabel) {
|
|
99
104
|
totalLabel.destroy();
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export function DrGaugeCategoriesSummaryChart(pivotData: any, opts: any): void;
|
|
2
|
+
export class DrGaugeCategoriesSummaryChart {
|
|
3
|
+
constructor(pivotData: any, opts: any);
|
|
4
|
+
completionPercentage: number;
|
|
5
|
+
render: () => any;
|
|
6
|
+
createPlotBands: (options: any) => any;
|
|
7
|
+
getDefaultValueForChart: (type: any, existing_options: any) => any;
|
|
8
|
+
mergeOptions: (options: any) => any;
|
|
9
|
+
prepareSegments: (options: any) => void;
|
|
10
|
+
getCompletionPercentage: (options: any) => number;
|
|
11
|
+
clampValueToPane: (value: any, max?: any, min?: any) => number;
|
|
12
|
+
formatValueLabel: (value: any, options: any) => string;
|
|
13
|
+
createValueLabel: (chart: any, options: any) => any;
|
|
14
|
+
getPaneDimensions: (chart: any, options: any) => {
|
|
15
|
+
radius: number;
|
|
16
|
+
center: number[];
|
|
17
|
+
};
|
|
18
|
+
setPane: (chart: any, options: any) => void;
|
|
19
|
+
setCustomElements: (chart: any, options: any) => void;
|
|
20
|
+
updateCustomElements: (chart: any, options: any) => void;
|
|
21
|
+
moveCustomElementsToFront: (chart: any) => void;
|
|
22
|
+
configChart: () => {
|
|
23
|
+
title: {
|
|
24
|
+
text: null;
|
|
25
|
+
};
|
|
26
|
+
subtitle: null;
|
|
27
|
+
exporting: {
|
|
28
|
+
allowHTML: boolean;
|
|
29
|
+
};
|
|
30
|
+
tooltip: {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
};
|
|
33
|
+
chart: {
|
|
34
|
+
type: string;
|
|
35
|
+
backgroundColor: any;
|
|
36
|
+
plotBackgroundColor: null;
|
|
37
|
+
plotBackgroundImage: null;
|
|
38
|
+
plotBorderWidth: number;
|
|
39
|
+
plotShadow: boolean;
|
|
40
|
+
events: {
|
|
41
|
+
render: (event: any) => void;
|
|
42
|
+
beforeRedraw: (event: any) => void;
|
|
43
|
+
beforeRender: (event: any) => void;
|
|
44
|
+
};
|
|
45
|
+
margin: number[];
|
|
46
|
+
spacing: number[];
|
|
47
|
+
};
|
|
48
|
+
pane: {
|
|
49
|
+
startAngle: number;
|
|
50
|
+
endAngle: number;
|
|
51
|
+
background: null;
|
|
52
|
+
center: number[];
|
|
53
|
+
};
|
|
54
|
+
yAxis: {
|
|
55
|
+
min: any;
|
|
56
|
+
max: any;
|
|
57
|
+
tickPositions: any;
|
|
58
|
+
tickPosition: string;
|
|
59
|
+
tickColor: any;
|
|
60
|
+
tickLength: any;
|
|
61
|
+
tickWidth: any;
|
|
62
|
+
minorTickInterval: null;
|
|
63
|
+
labels: {
|
|
64
|
+
enabled: boolean;
|
|
65
|
+
};
|
|
66
|
+
lineWidth: number;
|
|
67
|
+
plotBands: any;
|
|
68
|
+
};
|
|
69
|
+
series: {
|
|
70
|
+
name: null;
|
|
71
|
+
data: number[];
|
|
72
|
+
dataLabels: {
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
}[];
|
|
75
|
+
dial: {
|
|
76
|
+
radius: string;
|
|
77
|
+
backgroundColor: string;
|
|
78
|
+
baseWidth: number;
|
|
79
|
+
baseLength: string;
|
|
80
|
+
rearLength: string;
|
|
81
|
+
};
|
|
82
|
+
pivot: {
|
|
83
|
+
backgroundColor: string;
|
|
84
|
+
radius: any;
|
|
85
|
+
};
|
|
86
|
+
}[];
|
|
87
|
+
};
|
|
88
|
+
options: any;
|
|
89
|
+
aggregation: any;
|
|
90
|
+
format: any;
|
|
91
|
+
goal: any;
|
|
92
|
+
plotBands: any;
|
|
93
|
+
ticks: any;
|
|
94
|
+
value: any;
|
|
95
|
+
max: any;
|
|
96
|
+
min: any;
|
|
97
|
+
}
|
|
98
|
+
export namespace GAUGE_CATEGORIES_SUMMARY_OPTIONS_DEFAULT {
|
|
99
|
+
export namespace gauge {
|
|
100
|
+
let background: string;
|
|
101
|
+
let startAngle: number;
|
|
102
|
+
let endAngle: number;
|
|
103
|
+
let thickness: number;
|
|
104
|
+
let tickLength: number;
|
|
105
|
+
let tickWidth: number;
|
|
106
|
+
let valueOffset: number[];
|
|
107
|
+
let offset: number[];
|
|
108
|
+
let goalIcon: string;
|
|
109
|
+
let goalIconSize: number[];
|
|
110
|
+
namespace pivot {
|
|
111
|
+
let radius: number;
|
|
112
|
+
let color: string;
|
|
113
|
+
}
|
|
114
|
+
namespace colors {
|
|
115
|
+
let meta: string;
|
|
116
|
+
let goal: string;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export namespace goal_1 {
|
|
120
|
+
let title: string;
|
|
121
|
+
let value: number;
|
|
122
|
+
}
|
|
123
|
+
export { goal_1 as goal };
|
|
124
|
+
export let isAbsoluteValue: boolean;
|
|
125
|
+
export let segments: ({
|
|
126
|
+
title: string;
|
|
127
|
+
count: number;
|
|
128
|
+
isCompletionParameter: boolean;
|
|
129
|
+
color: string;
|
|
130
|
+
} | {
|
|
131
|
+
title: string;
|
|
132
|
+
count: number;
|
|
133
|
+
color: string;
|
|
134
|
+
isCompletionParameter?: undefined;
|
|
135
|
+
})[];
|
|
136
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DrGaugeChart constructor function
|
|
3
|
+
*/
|
|
4
|
+
export function DrGaugeChart(pivotData: any, opts: any, isDynamicGoal?: any): any;
|
|
5
|
+
|
|
6
|
+
export namespace DrGaugeChart {
|
|
7
|
+
let highchartsRenderer: any;
|
|
8
|
+
function getOptions(pivotData: any, opts: any, isDynamicGoal?: any): any;
|
|
9
|
+
function formatValue(data_type: any, number_format: any, value: any, widget_values_format: any): any;
|
|
10
|
+
function getTypeOptions(type: any, existing_options: any): any;
|
|
11
|
+
function ptCreateChartDrawData(pivotData: any, colors: any, onlyNumbers: any, isUniqueVals: any, additionOptions: any, opts: any, chartOptions: any): any;
|
|
12
|
+
function getAggregation(opts: any, aggfunc: any, base: any): any;
|
|
13
|
+
function getValue(pivotData: any, opts: any, isDynamicGoal?: boolean, isGoal?: boolean): any;
|
|
14
|
+
function getGoalTitleText(options: any): string;
|
|
15
|
+
function dynamicGoalFeatureEnabled(): boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const GAUGE_OPTIONS_DEFAULT: any;
|
|
@@ -2,6 +2,23 @@ const _ = require('lodash');
|
|
|
2
2
|
const { DrChartTooltip } = require("../dr_chart_tooltip");
|
|
3
3
|
const helpers = require("../dr-renderer-helpers");
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} DrGaugeChartInstance
|
|
7
|
+
* @property {function(): any} render
|
|
8
|
+
* @property {function(any, any, any, any): any} formatValue
|
|
9
|
+
* @property {function(any, any): void} setGoal
|
|
10
|
+
* @property {function(): any} configChart
|
|
11
|
+
* @property {any} options
|
|
12
|
+
* @property {any} goal
|
|
13
|
+
* @property {any} value
|
|
14
|
+
* @property {any} format
|
|
15
|
+
* @property {any} aggregation
|
|
16
|
+
* @property {any} plotBands
|
|
17
|
+
* @property {any} ticks
|
|
18
|
+
* @property {any} max
|
|
19
|
+
* @property {any} min
|
|
20
|
+
*/
|
|
21
|
+
|
|
5
22
|
const GAUGE_OPTIONS_DEFAULT = {
|
|
6
23
|
gauge: {
|
|
7
24
|
background: "#fff",
|
|
@@ -51,6 +68,14 @@ const GAUGE_OPTIONS_DEFAULT = {
|
|
|
51
68
|
],
|
|
52
69
|
};
|
|
53
70
|
|
|
71
|
+
/**
|
|
72
|
+
* DrGaugeChart constructor
|
|
73
|
+
* @constructor
|
|
74
|
+
* @param {any} pivotData
|
|
75
|
+
* @param {any} opts
|
|
76
|
+
* @param {any} isDynamicGoal
|
|
77
|
+
* @returns {DrGaugeChartInstance}
|
|
78
|
+
*/
|
|
54
79
|
function DrGaugeChart(pivotData, opts, isDynamicGoal) {
|
|
55
80
|
this.render = function () {
|
|
56
81
|
return DrGaugeChart.highchartsRenderer.ptCreateElementAndDraw(this.configChart(), opts);
|
|
@@ -528,6 +553,12 @@ function DrGaugeChart(pivotData, opts, isDynamicGoal) {
|
|
|
528
553
|
return helpers.clamp(min - correction, value, max + correction);
|
|
529
554
|
};
|
|
530
555
|
|
|
556
|
+
/**
|
|
557
|
+
* Sets the goal for the gauge chart.
|
|
558
|
+
* @param {any} pivotData - The pivot data
|
|
559
|
+
* @param {any} opts - Options
|
|
560
|
+
* @returns {void}
|
|
561
|
+
*/
|
|
531
562
|
this.setGoal = function (pivotData, opts) {
|
|
532
563
|
if (isDynamicGoal) {
|
|
533
564
|
this.options.goal = {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function capitalize(string: any): string;
|
|
2
|
+
export function clamp(min: any, v: any, max: any): number;
|
|
3
|
+
export function isNumber(n: any): boolean;
|
|
4
|
+
export function mergeDeep(target: any, ...sources: any[]): any;
|
|
5
|
+
export function removeSVGTextCorrection(svgEl: any, corr?: string): any;
|
|
6
|
+
export function disableLegendInteractionIfRequired(chartOptions: any, additionOptions: any): void;
|
|
7
|
+
export function isShowingEmptyValues(additionOptions: any): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Waits for an element to appear in the DOM and executes a callback when found.
|
|
10
|
+
* If the element already exists, the callback is executed immediately.
|
|
11
|
+
* Otherwise, uses MutationObserver to watch for DOM changes until the element appears.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} selector - CSS selector string to identify the target element
|
|
14
|
+
* @param {function(Element): void} callback - Function to execute when the element is found, receives the element as parameter
|
|
15
|
+
* @returns {void}
|
|
16
|
+
*/
|
|
17
|
+
export function onElementReady(selector: string, callback: (arg0: Element) => void): void;
|
|
18
|
+
export const DELIMER: " , ";
|
|
@@ -45,8 +45,8 @@ function mergeDeep(target, ...sources) {
|
|
|
45
45
|
|
|
46
46
|
function removeSVGTextCorrection(svgEl, corr = 'yCorr') {
|
|
47
47
|
Object.defineProperty(svgEl, corr, {
|
|
48
|
-
set: function() {},
|
|
49
|
-
get: function() {
|
|
48
|
+
set: function () { },
|
|
49
|
+
get: function () {
|
|
50
50
|
return 0;
|
|
51
51
|
}
|
|
52
52
|
});
|
package/src/dr_pivottable.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const { DR_SCENARIO, getSqAggregator } = require('./smart_queries_helper');
|
|
2
2
|
const { DELIMER } = require('./dr-renderer-helpers');
|
|
3
3
|
const { TooMuchDataError } = require('./errors');
|
|
4
|
+
const freezePanes = require('./pivot-table/freeze-panes');
|
|
5
|
+
const _ = require('lodash');
|
|
4
6
|
|
|
5
7
|
let initDRPivotTable = function($, window, document) {
|
|
6
8
|
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
|
7
9
|
hasProp = {}.hasOwnProperty;
|
|
8
10
|
|
|
9
|
-
var DRPivotData,
|
|
11
|
+
var DRPivotData, SubtotalRenderer, getFormattedNumber, NovixRenderer;
|
|
10
12
|
const newTableColors = ['rgb(127, 196, 255)', 'rgb(200, 243,243)', 'rgb(247, 161, 173)', 'rgb(255, 237, 178)', 'rgb(221, 239, 255)',
|
|
11
13
|
'rgb(171, 216, 255)', 'rgb(174, 231, 220)', 'rgb(227, 255, 236)', 'rgb(162, 215, 227)', 'rgb(223, 239, 236)'];
|
|
12
14
|
|
|
@@ -195,36 +197,6 @@ let initDRPivotTable = function($, window, document) {
|
|
|
195
197
|
}
|
|
196
198
|
};
|
|
197
199
|
|
|
198
|
-
processKey = function(record, totals, keys, attrs, containsAverage, containsOthers, getAggregator) {
|
|
199
|
-
var addKey, attr, flatKey, k, key, len, ref;
|
|
200
|
-
key = [];
|
|
201
|
-
addKey = false;
|
|
202
|
-
for (k = 0, len = attrs.length; k < len; k++) {
|
|
203
|
-
attr = attrs[k];
|
|
204
|
-
key.push((ref = record[attr]) != null ? ref : "null");
|
|
205
|
-
flatKey = key.join(DELIMER);
|
|
206
|
-
if (!totals[flatKey]) {
|
|
207
|
-
totals[flatKey] = getAggregator(key.slice());
|
|
208
|
-
addKey = true;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (containsAverage || containsOthers) {
|
|
212
|
-
if (containsAverage && !containsOthers && key[0] === 'DR_Average') {
|
|
213
|
-
totals[flatKey].push(record);
|
|
214
|
-
}
|
|
215
|
-
if (containsOthers && !containsAverage && key[0] === 'DR_Others') {
|
|
216
|
-
totals[flatKey].push(record);
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
totals[flatKey].push(record);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
if (addKey) {
|
|
223
|
-
keys.push(key);
|
|
224
|
-
}
|
|
225
|
-
return key;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
200
|
DRPivotData.prototype.getAttrsKeys = function(record, attrs) {
|
|
229
201
|
const keys = [];
|
|
230
202
|
for (let k = 0; k < attrs.length; k++) {
|
|
@@ -375,9 +347,12 @@ let initDRPivotTable = function($, window, document) {
|
|
|
375
347
|
|
|
376
348
|
resultsArr.push($.pivotUtilities.novix_renderers["Pivot Table"](pvtData, opts));
|
|
377
349
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
350
|
+
resultsArr.destroy = function() {
|
|
351
|
+
var container = opts.$el ? opts.$el.find(".widget-id-" + opts.widgetId).get(0) : null;
|
|
352
|
+
if (container && typeof container.destroy === 'function') {
|
|
353
|
+
container.destroy();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
381
356
|
|
|
382
357
|
return resultsArr;
|
|
383
358
|
} else {
|
|
@@ -399,20 +374,16 @@ let initDRPivotTable = function($, window, document) {
|
|
|
399
374
|
|
|
400
375
|
SubtotalRenderer = function(pivotData, opts, charttype) {
|
|
401
376
|
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;
|
|
402
|
-
var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors,
|
|
377
|
+
var createTotalValsBolder, createGrandTotalBolder, getHeaderColorProperties, colorizeRowLabelHeaders, colorizeTableIfNeed, valueNoDashes, getColorsWithOffsetForTable, offsetColors, removeRowHeaderNullValue;
|
|
403
378
|
var getAdditionalAggregation, buildAdditionalHeaderCols, buildAdditionalHeaderRows, buildAdditionalColValues, buildAdditionalRowValues, buildAdditionalRowTotals, buildAdditionalColTotals;
|
|
404
379
|
var additionalFieldsCol, additionalFieldsRow, additionalFieldsList;
|
|
405
380
|
var getExistingAggregator;
|
|
406
381
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
X: horizontalFreezePaneClass,
|
|
413
|
-
Y: verticalFreezePaneClass,
|
|
414
|
-
XY: axisFreezePaneClass,
|
|
415
|
-
}
|
|
382
|
+
const freezePanesOptions = freezePanes.parseOptions(opts.chartOptions.table_options);
|
|
383
|
+
const freezePanesClasses = freezePanes.getClassStrings(freezePanesOptions);
|
|
384
|
+
const horizontalFreezePaneClass = freezePanesClasses.horizontal;
|
|
385
|
+
const verticalFreezePaneClass = freezePanesClasses.vertical;
|
|
386
|
+
const axisFreezePaneClass = freezePanesClasses.axis;
|
|
416
387
|
|
|
417
388
|
additionalFieldsCol = [];
|
|
418
389
|
additionalFieldsRow = [];
|
|
@@ -2259,32 +2230,6 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2259
2230
|
}
|
|
2260
2231
|
};
|
|
2261
2232
|
|
|
2262
|
-
handleFreezePanesScroll = function(freezableElements) {
|
|
2263
|
-
return function(event) {
|
|
2264
|
-
if (event.target.dataset.canFreezePanes) return;
|
|
2265
|
-
|
|
2266
|
-
const wrapper = event.target;
|
|
2267
|
-
|
|
2268
|
-
const translateY = `translate(0px, ${wrapper.scrollTop}px)`;
|
|
2269
|
-
const translateX = `translate(${wrapper.scrollLeft}px, 0px)`;
|
|
2270
|
-
const translateXY = `translate(${wrapper.scrollLeft}px, ${wrapper.scrollTop}px)`;
|
|
2271
|
-
|
|
2272
|
-
_.forEach(freezableElements, function (element) {
|
|
2273
|
-
let currentTranslate = translateY;
|
|
2274
|
-
currentTranslate = element.className.includes(elementToTransform.X) ? translateX : currentTranslate;
|
|
2275
|
-
currentTranslate = element.className.includes(elementToTransform.XY) ? translateXY : currentTranslate;
|
|
2276
|
-
element.style.transform = currentTranslate;
|
|
2277
|
-
});
|
|
2278
|
-
}
|
|
2279
|
-
};
|
|
2280
|
-
|
|
2281
|
-
selectFreezableElements = function(wrapper) {
|
|
2282
|
-
const selectString =_.map(_.values(elementToTransform), function (item) {
|
|
2283
|
-
return `.${item.replace(' ', '')}`;
|
|
2284
|
-
}).join(',');
|
|
2285
|
-
return Array.from(wrapper.querySelectorAll(selectString));
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
2233
|
main = function(rowAttrs, rowKeys, colAttrs, colKeys, pivotData) {
|
|
2289
2234
|
if (pivotData.isSmartQueriesEnabled) {
|
|
2290
2235
|
rowKeys = rowKeys.filter(rowKey => !rowKey.includes(DR_SCENARIO.SQ_Actuals));
|
|
@@ -2429,19 +2374,31 @@ let initDRPivotTable = function($, window, document) {
|
|
|
2429
2374
|
resultsArr.push(subTitle);
|
|
2430
2375
|
}
|
|
2431
2376
|
|
|
2432
|
-
|
|
2377
|
+
const tableContainer = document.createElement("div");
|
|
2433
2378
|
tableContainer.className = "pivot-div";
|
|
2379
|
+
tableContainer.id = _.uniqueId("pivottable_");
|
|
2434
2380
|
tableContainer.appendChild(result);
|
|
2435
|
-
if (opts.chartOptions.table_options.freeze_panes) {
|
|
2436
|
-
tableContainer.onscroll = handleFreezePanesScroll(selectFreezableElements(tableContainer));
|
|
2437
|
-
}
|
|
2438
2381
|
resultsArr.push(tableContainer);
|
|
2439
2382
|
|
|
2440
|
-
|
|
2383
|
+
const wrapper = document.createElement("div");
|
|
2441
2384
|
wrapper.className = "pivot-wrapper";
|
|
2442
2385
|
|
|
2443
2386
|
$(wrapper).append(resultsArr);
|
|
2444
2387
|
|
|
2388
|
+
let freezePanesResult = null;
|
|
2389
|
+
if (freezePanesOptions.enabled) {
|
|
2390
|
+
freezePanesResult = freezePanes.initialize(tableContainer, freezePanesOptions, {
|
|
2391
|
+
rowAttrsLength: rowAttrs.length
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
wrapper.destroy = function() {
|
|
2396
|
+
if (freezePanesResult && typeof freezePanesResult.destroy === 'function') {
|
|
2397
|
+
freezePanesResult.destroy();
|
|
2398
|
+
freezePanesResult = null;
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2401
|
+
|
|
2445
2402
|
return wrapper;
|
|
2446
2403
|
};
|
|
2447
2404
|
return main(rowAttrs, rowKeys, colAttrs, colKeys, pivotData);
|
package/src/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {Object} HighChartsRenderer
|
|
3
|
-
* @property {(rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) =>
|
|
3
|
+
* @property {(rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => TableRenderResult} rhPivotViewV2
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} PivotUtilities
|
|
@@ -24,6 +24,23 @@
|
|
|
24
24
|
/**
|
|
25
25
|
* @typedef {Record<string, Record<string, number | string> | number | string>[]} Rows - BE data response
|
|
26
26
|
*/
|
|
27
|
+
/**
|
|
28
|
+
* Interface for objects with a destroy cleanup method
|
|
29
|
+
* @typedef {Object} Destroyable
|
|
30
|
+
* @property {() => void} destroy - Cleanup method to release resources
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* HTMLElement enriched with library cleanup method
|
|
34
|
+
* @typedef {HTMLElement & Destroyable} DestroyableHTMLElement
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Array enriched with library cleanup method (used by NovixRenderer Handsontable path)
|
|
38
|
+
* @typedef {Array<any> & Destroyable} DestroyableArray
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Result from table rendering - can be a destroyable element, array, or string
|
|
42
|
+
* @typedef {DestroyableHTMLElement | DestroyableArray | string} TableRenderResult
|
|
43
|
+
*/
|
|
27
44
|
export class GraphTableRenderer {
|
|
28
45
|
/**
|
|
29
46
|
*
|
|
@@ -52,13 +69,28 @@ export class GraphTableRenderer {
|
|
|
52
69
|
* @returns {any | null}
|
|
53
70
|
*/
|
|
54
71
|
hcInstance(): any | null;
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Renders table view of the data
|
|
74
|
+
* @param {any} [widget] - Widget configuration
|
|
75
|
+
* @returns {TableRenderResult} - Render result with destroy method for cleanup
|
|
76
|
+
*/
|
|
77
|
+
renderTable(widget?: any): TableRenderResult;
|
|
78
|
+
renderChart(widget?: null): TableRenderResult;
|
|
79
|
+
/**
|
|
80
|
+
* Destroys the renderer instance and cleans up all resources.
|
|
81
|
+
* This includes:
|
|
82
|
+
* - Destroying the Highcharts instance (if exists)
|
|
83
|
+
* - Calling destroy on table result (freeze panes observers, Handsontable instances, etc.)
|
|
84
|
+
* - Disposing the pivot model
|
|
85
|
+
* - Resetting internal state
|
|
86
|
+
* @returns {void}
|
|
87
|
+
*/
|
|
88
|
+
destroy(): void;
|
|
57
89
|
#private;
|
|
58
90
|
}
|
|
59
91
|
export default GraphTableRenderer;
|
|
60
92
|
export type HighChartsRenderer = {
|
|
61
|
-
rhPivotViewV2: (rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) =>
|
|
93
|
+
rhPivotViewV2: (rows: Rows, options: GTROptions | null, isTable: boolean, widget: any, pivotModel?: PivotModel) => TableRenderResult;
|
|
62
94
|
};
|
|
63
95
|
export type PivotUtilities = {
|
|
64
96
|
getPivotDataModel: (rows: Rows, options: GTROptions) => PivotModel;
|
|
@@ -77,3 +109,24 @@ export type GTROptions = {
|
|
|
77
109
|
* - BE data response
|
|
78
110
|
*/
|
|
79
111
|
export type Rows = Record<string, Record<string, number | string> | number | string>[];
|
|
112
|
+
/**
|
|
113
|
+
* Interface for objects with a destroy cleanup method
|
|
114
|
+
*/
|
|
115
|
+
export type Destroyable = {
|
|
116
|
+
/**
|
|
117
|
+
* - Cleanup method to release resources
|
|
118
|
+
*/
|
|
119
|
+
destroy: () => void;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* HTMLElement enriched with library cleanup method
|
|
123
|
+
*/
|
|
124
|
+
export type DestroyableHTMLElement = HTMLElement & Destroyable;
|
|
125
|
+
/**
|
|
126
|
+
* Array enriched with library cleanup method (used by NovixRenderer Handsontable path)
|
|
127
|
+
*/
|
|
128
|
+
export type DestroyableArray = Array<any> & Destroyable;
|
|
129
|
+
/**
|
|
130
|
+
* Result from table rendering - can be a destroyable element, array, or string
|
|
131
|
+
*/
|
|
132
|
+
export type TableRenderResult = DestroyableHTMLElement | DestroyableArray | string;
|