pace-chart-lib 1.0.1 → 1.0.3
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/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +76 -38
- package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +4 -2
- package/dist/{components → Components}/Charts/Core/CommonFunctions.d.ts +3 -1
- package/dist/{components → Components}/Charts/Core/DefaultProperties.types.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/pace-chart-lib.es.js +54619 -0
- package/dist/pace-chart-lib.umd.js +54622 -0
- package/dist/vite.svg +1 -0
- package/package.json +1 -1
- package/dist/Services/ErrorLog.js +0 -3
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +0 -496
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +0 -491
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +0 -517
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +0 -553
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +0 -517
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +0 -553
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -4909
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +0 -49
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +0 -486
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +0 -418
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +0 -1013
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +0 -478
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +0 -451
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +0 -533
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +0 -512
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +0 -530
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +0 -512
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +0 -12
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +0 -9
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +0 -479
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +0 -478
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +0 -473
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +0 -465
- package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -451
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +0 -554
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +0 -510
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +0 -507
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +0 -393
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +0 -606
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -815
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +0 -32
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +0 -15021
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +0 -391
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +0 -367
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +0 -570
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +0 -212
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +0 -401
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +0 -313
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +0 -719
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +0 -807
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +0 -514
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +0 -282
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +0 -207
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +0 -476
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +0 -420
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +0 -106
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +0 -507
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +0 -246
- package/dist/components/Charts/Core/Common.type.d.ts +0 -0
- package/dist/components/Charts/Core/Common.type.js +0 -0
- package/dist/components/Charts/Core/Common.types.js +0 -133
- package/dist/components/Charts/Core/CommonFunctions.js +0 -1782
- package/dist/components/Charts/Core/DefaultChartDataProperties.js +0 -64
- package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
- package/dist/components/Charts/Core/DefaultProperties.js +0 -0
- package/dist/components/Charts/Core/DefaultProperties.type.d.ts +0 -586
- package/dist/components/Charts/Core/DefaultProperties.type.js +0 -585
- package/dist/components/Charts/Core/DefaultProperties.types.js +0 -592
- package/dist/index.js +0 -40
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -0
- /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/NormalizedStackLineChart.d.ts +0 -0
- /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/StackLineChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/Core/Common.types.d.ts +0 -0
- /package/dist/{components → Components}/Charts/Core/DefaultChartDataProperties.d.ts +0 -0
|
@@ -1,606 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//#region Imports
|
|
3
|
-
import * as d3 from "d3";
|
|
4
|
-
import { useEffect, useRef } from "react";
|
|
5
|
-
import { logError } from "../../../../Services/ErrorLog";
|
|
6
|
-
import { staticLegendShape } from "../../Core/Common.types";
|
|
7
|
-
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOnMouseMove } from "../../Core/CommonFunctions";
|
|
8
|
-
import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, getStackedData, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight } from "../ChartsWithAxisFunctions";
|
|
9
|
-
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
10
|
-
const WaterfallChart = ({ isDateType, formatOptions, data, }) => {
|
|
11
|
-
// adding variables as per requirement
|
|
12
|
-
const chartId = crypto.randomUUID?.();
|
|
13
|
-
let columnWidth = 0; // coz line chartO
|
|
14
|
-
let colorScale;
|
|
15
|
-
const chartType = actualChartTypes.waterfall;
|
|
16
|
-
const svgRef = useRef();
|
|
17
|
-
const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
|
|
18
|
-
const dimensionList = data.DimensionList;
|
|
19
|
-
const barChart = false;
|
|
20
|
-
const isSecondaryAxisDrawn = false;
|
|
21
|
-
const isNormalizedChart = false;
|
|
22
|
-
let isPrimaryAxisDrawn = true;
|
|
23
|
-
let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
|
|
24
|
-
let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
|
|
25
|
-
let secondaryCustomYaxisMinValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMinText);
|
|
26
|
-
let secondaryCustomYaxisMaxValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMaxText);
|
|
27
|
-
let margin;
|
|
28
|
-
let yLabel;
|
|
29
|
-
let xLabel;
|
|
30
|
-
let yTitle;
|
|
31
|
-
let xTitle;
|
|
32
|
-
let dimensionHeightWidthArray;
|
|
33
|
-
let chartTitleHeight;
|
|
34
|
-
let secondaryAxisTitleWidth;
|
|
35
|
-
let legendMargin;
|
|
36
|
-
let secondaryYLabel;
|
|
37
|
-
let maxNumberForPrimaryAxis;
|
|
38
|
-
let maxNumberForSecondaryAxis;
|
|
39
|
-
let innerWidth;
|
|
40
|
-
let innerHeight;
|
|
41
|
-
let width;
|
|
42
|
-
let height;
|
|
43
|
-
let dataTable;
|
|
44
|
-
let dataTableHeight;
|
|
45
|
-
let svg;
|
|
46
|
-
let gTag;
|
|
47
|
-
let yScaleLeft;
|
|
48
|
-
let yScaleRight;
|
|
49
|
-
let xScale;
|
|
50
|
-
let xScaleForLegends;
|
|
51
|
-
let seriesLabels;
|
|
52
|
-
let calculatedRange;
|
|
53
|
-
let seriesLabelWidth;
|
|
54
|
-
let yAxisLeft;
|
|
55
|
-
let xAxis;
|
|
56
|
-
let yAxisRight;
|
|
57
|
-
let filteredDimension;
|
|
58
|
-
let filteredData = [];
|
|
59
|
-
let waterFallData = [];
|
|
60
|
-
let stackTotalData;
|
|
61
|
-
let scrollPosition = 0;
|
|
62
|
-
const visibleBars = 2;
|
|
63
|
-
let chartJSON = {
|
|
64
|
-
dimensionList: dimensionList,
|
|
65
|
-
chartType: chartType,
|
|
66
|
-
chartData: [],
|
|
67
|
-
formatOptions: formatOptions,
|
|
68
|
-
legendList: [],
|
|
69
|
-
secondaryAxisDrawn: false,
|
|
70
|
-
yMaxLeft: 0,
|
|
71
|
-
yMaxRight: 0,
|
|
72
|
-
yMinLeft: 0,
|
|
73
|
-
yMinRight: 0,
|
|
74
|
-
hideZeroValues: false,
|
|
75
|
-
formattedDimensionListMap: new Map(),
|
|
76
|
-
};
|
|
77
|
-
//#region UseEffect
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
try {
|
|
80
|
-
createWaterfallChart();
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
logError("WaterfallChart", "createWaterfallChart", error);
|
|
84
|
-
}
|
|
85
|
-
}, [formatOptions]);
|
|
86
|
-
//#endregion
|
|
87
|
-
const createWaterfallChart = () => {
|
|
88
|
-
({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
|
|
89
|
-
preProcessChartData(); // preaparing data related to chart creation
|
|
90
|
-
// Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
|
|
91
|
-
({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } = customYscaleLabelFormatting(
|
|
92
|
-
// for calculating primary/secondary axis max number so that we can calculate margin accordinglt
|
|
93
|
-
formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
|
|
94
|
-
({
|
|
95
|
-
margin,
|
|
96
|
-
yLabel,
|
|
97
|
-
xLabel,
|
|
98
|
-
yTitle,
|
|
99
|
-
xTitle,
|
|
100
|
-
dimensionHeightWidthArray,
|
|
101
|
-
chartTitleHeight,
|
|
102
|
-
secondaryAxisTitleWidth,
|
|
103
|
-
legendMargin,
|
|
104
|
-
secondaryYLabel,
|
|
105
|
-
} = marginCalculation(
|
|
106
|
-
// for all margin related calculations
|
|
107
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
108
|
-
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
109
|
-
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
110
|
-
// calculations for data tables
|
|
111
|
-
formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
|
|
112
|
-
initSvg(
|
|
113
|
-
// for svg creation
|
|
114
|
-
svg, width, height, formatOptions);
|
|
115
|
-
gTag = initChartArea(svg, margin); // creating chart area
|
|
116
|
-
initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
|
|
117
|
-
initScale();
|
|
118
|
-
initAxis();
|
|
119
|
-
initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
|
|
120
|
-
// initYaxisRight(
|
|
121
|
-
// gTag,
|
|
122
|
-
// formatOptions,
|
|
123
|
-
// dataTableHeight,
|
|
124
|
-
// secondaryYLabel,
|
|
125
|
-
// yAxisRight,
|
|
126
|
-
// innerHeight,
|
|
127
|
-
// innerWidth
|
|
128
|
-
// );
|
|
129
|
-
horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
|
|
130
|
-
if (formatOptions.dataTableProperties &&
|
|
131
|
-
formatOptions.dataTableProperties.dataTable) {
|
|
132
|
-
if (formatOptions.xAxisLabel.xAxisPosition != "1")
|
|
133
|
-
formatOptions.xAxisLabel.xAxisLabelVisibility = false;
|
|
134
|
-
addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, columnWidth, yScaleLeft, xScale, xScaleForLegends, undefined, undefined, dataTableHeight, chartType, formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
|
|
135
|
-
}
|
|
136
|
-
setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
|
|
137
|
-
yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
|
|
138
|
-
yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
|
|
139
|
-
setChartTitle(svg, formatOptions, width, chartTitleHeight);
|
|
140
|
-
drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, staticLegendShape.rectangle);
|
|
141
|
-
};
|
|
142
|
-
const preProcessChartData = () => {
|
|
143
|
-
const allChartData = [];
|
|
144
|
-
let formatedDimensionList = [];
|
|
145
|
-
seriesData.forEach((series) => {
|
|
146
|
-
series.data.forEach((point) => {
|
|
147
|
-
allChartData.push(point);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
151
|
-
if (!formatOptions.plotArea.fitChart) {
|
|
152
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
filteredDimension = chartJSON.dimensionList;
|
|
156
|
-
}
|
|
157
|
-
if (formatOptions.plotArea.hideZeroValues) {
|
|
158
|
-
chartJSON.hideZeroValues = true;
|
|
159
|
-
}
|
|
160
|
-
let tempWaterfallChartData = generateWaterFallData();
|
|
161
|
-
// update data if Up/Down < 1.0 * e-9
|
|
162
|
-
let tempData = JSON.parse(JSON.stringify(tempWaterfallChartData));
|
|
163
|
-
tempWaterfallChartData.forEach(data => {
|
|
164
|
-
if (!data.Dimension && ((data.Up < 1e-9 && data.Up !== 0) || (data.Down < 1e-9 && data.Down !== 0))) {
|
|
165
|
-
let index = tempData.findIndex(dta => dta.Legend === data.Legend);
|
|
166
|
-
index !== -1 && tempData.splice(index, 1);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
tempWaterfallChartData = tempData;
|
|
170
|
-
tempWaterfallChartData.forEach((d) => d.dimension ? chartJSON.legendList.push(d.dimension) : chartJSON.legendList.push(d.legend));
|
|
171
|
-
waterFallData = d3.stack().keys(["base", "dimensionTotal", "up", "down"])(tempWaterfallChartData);
|
|
172
|
-
let tempArrayToFindYMax = [];
|
|
173
|
-
let tempDimensionList = [];
|
|
174
|
-
waterFallData.forEach(key => {
|
|
175
|
-
key.key == "base" ? (key["opacity"] = 0) : (key["opacity"] = 1);
|
|
176
|
-
key.forEach(data => tempArrayToFindYMax.push(data));
|
|
177
|
-
if (!tempDimensionList.includes(key.dimension) && key.dimensionTotal === 0 && key.total === 0)
|
|
178
|
-
tempDimensionList.push(key.dimension);
|
|
179
|
-
});
|
|
180
|
-
chartJSON.yMaxLeft = d3.max(tempArrayToFindYMax, (d) => d[1]);
|
|
181
|
-
chartJSON.yMinLeft = d3.min(tempArrayToFindYMax, (d) => d[1]);
|
|
182
|
-
if (formatOptions.xAxisLabel.hideZeroValues) {
|
|
183
|
-
if (tempDimensionList.length > 0) {
|
|
184
|
-
tempDimensionList.forEach(dimension => {
|
|
185
|
-
chartJSON.legendList = chartJSON.legendList.filter(dim => dim !== dimension);
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
chartJSON.dimensionList = chartJSON.legendList;
|
|
189
|
-
}
|
|
190
|
-
// Apply formatted dimensions
|
|
191
|
-
formatedDimensionList = isDateType
|
|
192
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
193
|
-
: chartJSON.dimensionList;
|
|
194
|
-
getFormattedDimensionList(tempWaterfallChartData);
|
|
195
|
-
};
|
|
196
|
-
const getFormattedDimensionList = (tempWaterfallChartData) => {
|
|
197
|
-
try {
|
|
198
|
-
let tempDimensionList = [];
|
|
199
|
-
let tempDimensionListWithIndex = [];
|
|
200
|
-
let tempformatedDimensionList = [];
|
|
201
|
-
tempWaterfallChartData && tempWaterfallChartData.forEach((d, i) => {
|
|
202
|
-
if (d.dimension) {
|
|
203
|
-
tempDimensionList.push(d.dimension);
|
|
204
|
-
tempDimensionListWithIndex.push({ dimension: d.dimension, chartDataIndex: i, selfIndex: tempDimensionListWithIndex.length });
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
if (isDateType) {
|
|
208
|
-
tempformatedDimensionList = setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
tempformatedDimensionList = tempDimensionList;
|
|
212
|
-
}
|
|
213
|
-
let formatedDimensionList = JSON.parse(JSON.stringify(chartJSON.legendList));
|
|
214
|
-
tempDimensionListWithIndex.forEach((listItem, i) => {
|
|
215
|
-
formatedDimensionList[listItem.chartDataIndex] = tempformatedDimensionList[listItem.selfIndex];
|
|
216
|
-
});
|
|
217
|
-
chartJSON.legendList.forEach((d, i) => {
|
|
218
|
-
chartJSON.formattedDimensionListMap.set(d, formatedDimensionList[i]);
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
throw error;
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
const initScale = () => {
|
|
226
|
-
// rounding the ymin & ymax
|
|
227
|
-
let yAxisLabelArray = responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray;
|
|
228
|
-
chartJSON.yMaxLeft = yAxisLabelArray[yAxisLabelArray.length - 1];
|
|
229
|
-
chartJSON.yMinLeft = yAxisLabelArray[0];
|
|
230
|
-
if (isPrimaryAxisDrawn) {
|
|
231
|
-
yScaleLeft = d3
|
|
232
|
-
.scaleLinear()
|
|
233
|
-
.domain([
|
|
234
|
-
chartJSON.yMinLeft >= 0 ?
|
|
235
|
-
customYaxisMinValue !== undefined &&
|
|
236
|
-
!Number.isNaN(customYaxisMinValue)
|
|
237
|
-
? customYaxisMinValue : 0
|
|
238
|
-
: chartJSON.yMinLeft < 0
|
|
239
|
-
? chartJSON.yMinLeft * 1.1
|
|
240
|
-
: chartJSON.yMinLeft * 0.9,
|
|
241
|
-
chartJSON.yMaxLeft <= 0
|
|
242
|
-
? 0
|
|
243
|
-
: customYaxisMaxValue !== undefined &&
|
|
244
|
-
!Number.isNaN(customYaxisMaxValue)
|
|
245
|
-
? customYaxisMaxValue
|
|
246
|
-
: chartJSON.yMaxLeft * 1.1,
|
|
247
|
-
])
|
|
248
|
-
.range([
|
|
249
|
-
dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
|
|
250
|
-
0,
|
|
251
|
-
]);
|
|
252
|
-
}
|
|
253
|
-
calculatedRange = [0, innerWidth];
|
|
254
|
-
if (formatOptions.seriesLabel.seriesLabelVisibility) {
|
|
255
|
-
let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn);
|
|
256
|
-
seriesLabels = labelObj.labelArray;
|
|
257
|
-
formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
|
|
258
|
-
(seriesLabelWidth = labelObj.heightWidth[0]);
|
|
259
|
-
formatOptions.seriesLabel.seriesLabelPosition == "Right"
|
|
260
|
-
? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
|
|
261
|
-
: (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
|
|
262
|
-
}
|
|
263
|
-
getXScale();
|
|
264
|
-
};
|
|
265
|
-
const getXScale = () => {
|
|
266
|
-
columnWidth =
|
|
267
|
-
(0.51 + (0.61 * (100 - parseFloat(formatOptions.plotArea.plotAreaGapWidth))) / 100) *
|
|
268
|
-
(innerWidth / chartJSON.legendList.length);
|
|
269
|
-
xScale = d3
|
|
270
|
-
.scaleBand()
|
|
271
|
-
.domain(chartJSON.legendList)
|
|
272
|
-
.range(calculatedRange)
|
|
273
|
-
.padding(0.4);
|
|
274
|
-
};
|
|
275
|
-
const initAxis = () => {
|
|
276
|
-
getXAxis();
|
|
277
|
-
if (isPrimaryAxisDrawn) {
|
|
278
|
-
yAxisLeft = d3
|
|
279
|
-
.axisLeft(yScaleLeft)
|
|
280
|
-
.tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
|
|
281
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
282
|
-
? formatOptions.plotArea.gridLinesHorizontal
|
|
283
|
-
? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
|
|
284
|
-
: 0
|
|
285
|
-
: 0)
|
|
286
|
-
.tickValues(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray)
|
|
287
|
-
.ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).customTickValue ??
|
|
288
|
-
(dataTableHeight > 0
|
|
289
|
-
? (innerHeight - dataTableHeight) / 30
|
|
290
|
-
: innerHeight / 30))
|
|
291
|
-
.tickSizeOuter(0);
|
|
292
|
-
}
|
|
293
|
-
colorScale = d3.scaleOrdinal().range([
|
|
294
|
-
"#E25A42",
|
|
295
|
-
formatOptions.plotArea.totalColor,
|
|
296
|
-
formatOptions.plotArea.positiveColor,
|
|
297
|
-
formatOptions.plotArea.negativeColor,
|
|
298
|
-
]);
|
|
299
|
-
};
|
|
300
|
-
const getXAxis = () => {
|
|
301
|
-
xAxis = d3
|
|
302
|
-
.axisBottom(xScale)
|
|
303
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
304
|
-
? formatOptions.plotArea.gridLinesVertical
|
|
305
|
-
? formatOptions.plotArea.gridLinesVertical
|
|
306
|
-
? -(dataTableHeight > 0
|
|
307
|
-
? innerHeight - dataTableHeight
|
|
308
|
-
: innerHeight)
|
|
309
|
-
: parseFloat(formatOptions.plotArea.ticksHeight) *
|
|
310
|
-
((dataTableHeight > 0
|
|
311
|
-
? innerHeight - dataTableHeight
|
|
312
|
-
: innerHeight) /
|
|
313
|
-
100) *
|
|
314
|
-
(formatOptions.xAxisLabel.xAxisPosition == "1" ? 1 : -1)
|
|
315
|
-
: 0
|
|
316
|
-
: 0)
|
|
317
|
-
.tickSizeOuter(0)
|
|
318
|
-
.tickValues(responsiveXaxisLabel(chartJSON.legendList, innerWidth));
|
|
319
|
-
};
|
|
320
|
-
const getChartType = (lineData) => {
|
|
321
|
-
let totalStackData;
|
|
322
|
-
waterFallData.forEach((K, j) => K.forEach((d) => (d["key"] = K.key)));
|
|
323
|
-
if (stackTotalData) {
|
|
324
|
-
let stackDataLegendList = filteredData.map(name => name.legend);
|
|
325
|
-
// chartJSON.legendList = stackDataLegendList;
|
|
326
|
-
totalStackData = d3.stack().keys(stackDataLegendList)(stackTotalData);
|
|
327
|
-
totalStackData.forEach((d, i) => {
|
|
328
|
-
totalStackData[i]["color"] = filteredData[i].properties.color;
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
totalStackData && totalStackData.forEach(data => {
|
|
332
|
-
data.forEach(j => {
|
|
333
|
-
j["Key"] = data.key;
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
// Bind dummy data to ensure a single group is created
|
|
337
|
-
// Step 1: Loop over the two passes (0 and 1)
|
|
338
|
-
[0, 1].forEach(k => {
|
|
339
|
-
if (k === 1)
|
|
340
|
-
waterFallData = totalStackData;
|
|
341
|
-
if (waterFallData) {
|
|
342
|
-
// OUTER JOIN: parent group for the full waterfall chart
|
|
343
|
-
let parentGroup = gTag
|
|
344
|
-
.selectAll(`.parentGroup-${k}`)
|
|
345
|
-
.data([null]); // dummy single-element array
|
|
346
|
-
parentGroup = parentGroup
|
|
347
|
-
.enter()
|
|
348
|
-
.append("g")
|
|
349
|
-
.attr("class", `parentGroup parentGroup-${k}`)
|
|
350
|
-
.merge(parentGroup);
|
|
351
|
-
// INNER JOIN: join to each bar stack group
|
|
352
|
-
let barGroups = parentGroup
|
|
353
|
-
.selectAll(`.bar-group-${k}`)
|
|
354
|
-
.data(waterFallData);
|
|
355
|
-
const barGroupsEnter = barGroups
|
|
356
|
-
.enter()
|
|
357
|
-
.append("g")
|
|
358
|
-
.attr("class", `bar-group-${k}`)
|
|
359
|
-
.attr("fill", d => d.color ? d.color : colorScale(d.key) !== "#ffffff" ? colorScale(d.key) : "none")
|
|
360
|
-
.attr("opacity", d => d.opacity);
|
|
361
|
-
barGroups = barGroupsEnter.merge(barGroups);
|
|
362
|
-
// JOIN rects inside each bar group
|
|
363
|
-
let rects = barGroups
|
|
364
|
-
.selectAll("rect")
|
|
365
|
-
.data(d => d, d => d.key || d.Key);
|
|
366
|
-
const rectsEnter = rects
|
|
367
|
-
.enter()
|
|
368
|
-
.append("rect")
|
|
369
|
-
.attr("class", "rect")
|
|
370
|
-
.attr("class", d => d.key ? d.key.replace(/ /g, "-") : d.Key.replace(/ /g, "-"))
|
|
371
|
-
.attr("x", d => xScale(d.data.dimension || d.data.legend))
|
|
372
|
-
.attr("y", d => d[1] ? yScaleLeft(d[1]) : 0)
|
|
373
|
-
.attr("height", d => d[1] ? (yScaleLeft(d[0]) - yScaleLeft(d[1])) : 0)
|
|
374
|
-
.attr("width", xScale.bandwidth())
|
|
375
|
-
.attr("visibility", d => k === 0 && d.data.dimension && stackTotalData ? "hidden" : "visible")
|
|
376
|
-
.style("shape-rendering", "crispEdges")
|
|
377
|
-
.on("mousemove", (event, d) => {
|
|
378
|
-
showTooltipOnMouseMove([
|
|
379
|
-
{
|
|
380
|
-
key: d.key === "dimensionTotal" ? "Dimension" : formatOptions.xAxisTitle.xAxisTitleText,
|
|
381
|
-
value: chartJSON.formattedDimensionListMap.get(d.data.dimension),
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
key: formatOptions.yAxisTitle.yAxisTitleText,
|
|
385
|
-
value: (d.key === "up" ? "+" : d.key === "down" ? "-" : "") +
|
|
386
|
-
getNumberWithFormat(d.key === "dimensionTotal" ? d.data.dimensionTotal : d[1] - d[0], formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision),
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
key: "Legend",
|
|
390
|
-
value: d.Key
|
|
391
|
-
? d.Key.includes("~$~")
|
|
392
|
-
? d.Key.split("~$~")[1]
|
|
393
|
-
: d.Key
|
|
394
|
-
: d.data.legend
|
|
395
|
-
? d.data.legend.includes("~$~")
|
|
396
|
-
? d.data.legend.split("~$~")[1]
|
|
397
|
-
: d.data.legend
|
|
398
|
-
: "Total",
|
|
399
|
-
},
|
|
400
|
-
], formatOptions);
|
|
401
|
-
})
|
|
402
|
-
.on("mouseout", () => {
|
|
403
|
-
hideTooltipOnMouseOut();
|
|
404
|
-
});
|
|
405
|
-
rects.exit().remove();
|
|
406
|
-
rects = rectsEnter.merge(rects);
|
|
407
|
-
// // LABELS (if enabled)
|
|
408
|
-
if (formatOptions.plotArea.plotAreaDataLabel == "2" && k != 1) {
|
|
409
|
-
const textGroups = barGroups
|
|
410
|
-
.selectAll("text")
|
|
411
|
-
.data(d => d);
|
|
412
|
-
const textEnter = textGroups
|
|
413
|
-
.enter()
|
|
414
|
-
.append("text")
|
|
415
|
-
.text(d => getNumberWithFormat(d[1] - d[0], formatOptions.plotArea.plotAreaDisplayUnits, formatOptions.plotArea.dataLabelNumberFormat, formatOptions.plotArea.dataLabelDecimalPrecision))
|
|
416
|
-
.attr("x", d => xScale(d.data.dimension || d.data.legend) + columnWidth / 2)
|
|
417
|
-
.attr("y", d => d[1] ? yScaleLeft(d[1]) - 15 : 0)
|
|
418
|
-
.style("font-size", "11px")
|
|
419
|
-
.attr("text-anchor", "middle")
|
|
420
|
-
.attr("visibility", d => (d[1] - d[0]) !== 0 && yScaleLeft(d[1]) ? "visible" : "hidden");
|
|
421
|
-
textGroups.exit().remove();
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
};
|
|
426
|
-
const setSVGContainer = (margin) => {
|
|
427
|
-
innerWidth = width - margin.left - margin.right;
|
|
428
|
-
innerHeight = height - margin.bottom - margin.top;
|
|
429
|
-
};
|
|
430
|
-
const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
|
|
431
|
-
if (!formatOptions.plotArea.fitChart) {
|
|
432
|
-
// Scrollbar parameters
|
|
433
|
-
const scrollMax = seriesData[0].data.length - visibleBars;
|
|
434
|
-
// Scrollbar track & handle
|
|
435
|
-
const scrollbarY = height - 20;
|
|
436
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
437
|
-
getXScale();
|
|
438
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
439
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
440
|
-
getXAxis();
|
|
441
|
-
svg
|
|
442
|
-
.append("rect")
|
|
443
|
-
.attr("x", margin.left)
|
|
444
|
-
.attr("y", scrollbarY)
|
|
445
|
-
.attr("width", innerWidth)
|
|
446
|
-
.attr("height", 8)
|
|
447
|
-
.attr("fill", "#ddd")
|
|
448
|
-
.attr("rx", 4);
|
|
449
|
-
const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
|
|
450
|
-
const handle = svg
|
|
451
|
-
.append("rect")
|
|
452
|
-
.attr("x", margin.left)
|
|
453
|
-
.attr("y", scrollbarY)
|
|
454
|
-
.attr("width", handleWidth)
|
|
455
|
-
.attr("height", 8)
|
|
456
|
-
.attr("fill", "#999")
|
|
457
|
-
.attr("rx", 4)
|
|
458
|
-
.style("cursor", "ew-resize")
|
|
459
|
-
.call(d3.drag().on("drag", (event) => {
|
|
460
|
-
let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
|
|
461
|
-
handle.attr("x", x);
|
|
462
|
-
scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
|
|
463
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
464
|
-
getXScale();
|
|
465
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
466
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
467
|
-
getXAxis();
|
|
468
|
-
drawColumnChart();
|
|
469
|
-
}));
|
|
470
|
-
svg.on("wheel", (event) => {
|
|
471
|
-
event.preventDefault();
|
|
472
|
-
const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
|
|
473
|
-
? event.deltaX
|
|
474
|
-
: event.deltaY;
|
|
475
|
-
scrollPosition += scrollDelta > 0 ? 1 : -1;
|
|
476
|
-
scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
|
|
477
|
-
const x = margin.left +
|
|
478
|
-
((innerWidth - handleWidth) * scrollPosition) / scrollMax;
|
|
479
|
-
handle.attr("x", x);
|
|
480
|
-
getXScale();
|
|
481
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
482
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
483
|
-
getXAxis();
|
|
484
|
-
drawColumnChart();
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
drawColumnChart();
|
|
488
|
-
};
|
|
489
|
-
const drawColumnChart = () => {
|
|
490
|
-
getChartType(filteredData);
|
|
491
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, chartJSON.legendList);
|
|
492
|
-
// commonAnnotations(
|
|
493
|
-
// seriesData,
|
|
494
|
-
// xScale,
|
|
495
|
-
// yScaleLeft,
|
|
496
|
-
// yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
497
|
-
// margin,
|
|
498
|
-
// d3Annotation,
|
|
499
|
-
// [], //labelExcludeList,
|
|
500
|
-
// [], //individualLabelColor,
|
|
501
|
-
// [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
|
|
502
|
-
// formatOptions,
|
|
503
|
-
// chartType,
|
|
504
|
-
// height,
|
|
505
|
-
// width,
|
|
506
|
-
// innerWidth,
|
|
507
|
-
// filteredDimension,
|
|
508
|
-
// innerHeight,
|
|
509
|
-
// chartId,
|
|
510
|
-
// svg,
|
|
511
|
-
// xScaleForLegends,
|
|
512
|
-
// columnWidth
|
|
513
|
-
// );
|
|
514
|
-
};
|
|
515
|
-
const generateWaterFallData = () => {
|
|
516
|
-
try {
|
|
517
|
-
if (seriesData.length < 1)
|
|
518
|
-
return [];
|
|
519
|
-
if (chartJSON.dimensionList.length < 2)
|
|
520
|
-
return [];
|
|
521
|
-
let tempWaterFallData = [];
|
|
522
|
-
let dataRequiredForWaterfall = []; //JSON.parse(JSON.stringify(chartData));
|
|
523
|
-
let dataRequiredForStackTotal = []; //JSON.parse(JSON.stringify(chartData));
|
|
524
|
-
let seriesSlice = "";
|
|
525
|
-
if (seriesSlice.length > 1) {
|
|
526
|
-
// seriesSlice.forEach(key => {
|
|
527
|
-
let tempSliceArr = seriesSlice;
|
|
528
|
-
seriesData.forEach(entry => {
|
|
529
|
-
if (tempSliceArr === entry.properties.currentLegend) {
|
|
530
|
-
dataRequiredForWaterfall.push(entry);
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
dataRequiredForStackTotal.push(entry);
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
if (dataRequiredForWaterfall.length > 0) {
|
|
538
|
-
filteredData = dataRequiredForWaterfall;
|
|
539
|
-
}
|
|
540
|
-
let sum = 0;
|
|
541
|
-
let tempC = 0;
|
|
542
|
-
for (let i = 0; i < filteredData.length; ++i) {
|
|
543
|
-
sum = sum + filteredData[i].data[0].value;
|
|
544
|
-
}
|
|
545
|
-
let str = "";
|
|
546
|
-
for (let j = 1; j < filteredDimension.length; ++j) {
|
|
547
|
-
let waterFallArr1 = {};
|
|
548
|
-
waterFallArr1["dimension"] = filteredDimension[j - 1]; //2013
|
|
549
|
-
waterFallArr1["total"] = sum;
|
|
550
|
-
waterFallArr1["base"] = 0;
|
|
551
|
-
waterFallArr1["dimensionTotal"] = sum;
|
|
552
|
-
waterFallArr1["up"] = 0;
|
|
553
|
-
waterFallArr1["down"] = 0;
|
|
554
|
-
tempWaterFallData.push(waterFallArr1);
|
|
555
|
-
for (let k = 0; k < filteredData.length; ++k) {
|
|
556
|
-
let waterFallArr = {};
|
|
557
|
-
for (let x = 0; x < k; x++) {
|
|
558
|
-
str = str + " ";
|
|
559
|
-
}
|
|
560
|
-
tempC =
|
|
561
|
-
filteredData[k].data[j].value -
|
|
562
|
-
filteredData[k].data[j - 1].value;
|
|
563
|
-
if (tempC !== 0) {
|
|
564
|
-
waterFallArr["legend"] =
|
|
565
|
-
str + filteredData[k].properties.legend;
|
|
566
|
-
waterFallArr["dimensionTotal"] = 0;
|
|
567
|
-
if (tempC < 0) {
|
|
568
|
-
waterFallArr["base"] = sum + tempC;
|
|
569
|
-
waterFallArr["down"] = -tempC;
|
|
570
|
-
waterFallArr["up"] = 0;
|
|
571
|
-
waterFallArr["total"] = sum - tempC;
|
|
572
|
-
}
|
|
573
|
-
else {
|
|
574
|
-
waterFallArr["base"] = sum;
|
|
575
|
-
waterFallArr["down"] = 0;
|
|
576
|
-
waterFallArr["up"] = tempC;
|
|
577
|
-
waterFallArr["total"] = sum + tempC;
|
|
578
|
-
}
|
|
579
|
-
sum = sum + tempC;
|
|
580
|
-
tempWaterFallData.push(waterFallArr);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
// }
|
|
584
|
-
}
|
|
585
|
-
//last dimension entry
|
|
586
|
-
let waterFallArr2 = {};
|
|
587
|
-
waterFallArr2["dimension"] = filteredDimension[filteredDimension.length - 1];
|
|
588
|
-
waterFallArr2["dimensionTotal"] = sum;
|
|
589
|
-
waterFallArr2["base"] = 0;
|
|
590
|
-
waterFallArr2["total"] = sum;
|
|
591
|
-
waterFallArr2["up"] = 0;
|
|
592
|
-
waterFallArr2["down"] = 0;
|
|
593
|
-
tempWaterFallData.push(waterFallArr2);
|
|
594
|
-
if (dataRequiredForStackTotal.length > 0) {
|
|
595
|
-
filteredData = dataRequiredForStackTotal;
|
|
596
|
-
stackTotalData = getStackedData(filteredDimension, dataRequiredForStackTotal, false);
|
|
597
|
-
}
|
|
598
|
-
return tempWaterFallData;
|
|
599
|
-
}
|
|
600
|
-
catch (error) {
|
|
601
|
-
throw error;
|
|
602
|
-
}
|
|
603
|
-
};
|
|
604
|
-
return (_jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, style: { width: "100%", height: "100%" } })] }));
|
|
605
|
-
};
|
|
606
|
-
export default WaterfallChart;
|
|
File without changes
|
|
File without changes
|