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,393 +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 * as d3Annotation from "d3-svg-annotation";
|
|
5
|
-
import { useEffect, useRef } from "react";
|
|
6
|
-
import { logError } from "../../../../Services/ErrorLog";
|
|
7
|
-
import { staticLegendShape } from "../../Core/Common.types";
|
|
8
|
-
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOnMouseMove } from "../../Core/CommonFunctions";
|
|
9
|
-
import { addDataTable, commonAnnotations, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxisBar, initYaxisBar, marginCalculation, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight } from "../ChartsWithAxisFunctions";
|
|
10
|
-
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
11
|
-
const TornadoChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
|
-
// adding variables as per requirement
|
|
13
|
-
const chartId = crypto.randomUUID();
|
|
14
|
-
let columnWidth = 0; // coz line chartO
|
|
15
|
-
const chartType = actualChartTypes.tornadoChart;
|
|
16
|
-
const svgRef = useRef();
|
|
17
|
-
const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
|
|
18
|
-
const dimensionList = data.DimensionList;
|
|
19
|
-
const barChart = true;
|
|
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 isSensitivityChart = false;
|
|
60
|
-
let scrollPosition = 0;
|
|
61
|
-
const visibleBars = 2;
|
|
62
|
-
let chartJSON = {
|
|
63
|
-
dimensionList: dimensionList,
|
|
64
|
-
chartType: chartType,
|
|
65
|
-
chartData: [],
|
|
66
|
-
formatOptions: formatOptions,
|
|
67
|
-
legendList: [],
|
|
68
|
-
secondaryAxisDrawn: false,
|
|
69
|
-
yMaxLeft: 0,
|
|
70
|
-
yMaxRight: 0,
|
|
71
|
-
yMinLeft: 0,
|
|
72
|
-
yMinRight: 0,
|
|
73
|
-
hideZeroValues: false,
|
|
74
|
-
formattedDimensionListMap: new Map(),
|
|
75
|
-
};
|
|
76
|
-
//#region UseEffect
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
try {
|
|
79
|
-
createTornadoChart();
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
logError("Tornadochart", "createTornadoChart", error);
|
|
83
|
-
}
|
|
84
|
-
}, [formatOptions]);
|
|
85
|
-
//#endregion
|
|
86
|
-
const createTornadoChart = () => {
|
|
87
|
-
({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
|
|
88
|
-
preProcessChartData(); // preaparing data related to chart creation
|
|
89
|
-
// Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
|
|
90
|
-
({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } = customYscaleLabelFormatting(
|
|
91
|
-
// for calculating primary/secondary axis max number so that we can calculate margin accordinglt
|
|
92
|
-
formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
|
|
93
|
-
({
|
|
94
|
-
margin,
|
|
95
|
-
yLabel,
|
|
96
|
-
xLabel,
|
|
97
|
-
yTitle,
|
|
98
|
-
xTitle,
|
|
99
|
-
dimensionHeightWidthArray,
|
|
100
|
-
chartTitleHeight,
|
|
101
|
-
secondaryAxisTitleWidth,
|
|
102
|
-
legendMargin,
|
|
103
|
-
secondaryYLabel,
|
|
104
|
-
} = marginCalculation(
|
|
105
|
-
// for all margin related calculations
|
|
106
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
107
|
-
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
108
|
-
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
109
|
-
// calculations for data tables
|
|
110
|
-
formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
|
|
111
|
-
initSvg(
|
|
112
|
-
// for svg creation
|
|
113
|
-
svg, width, height, formatOptions);
|
|
114
|
-
gTag = initChartArea(svg, margin); // creating chart area
|
|
115
|
-
initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
|
|
116
|
-
initScale();
|
|
117
|
-
initAxis();
|
|
118
|
-
initYaxisBar(formatOptions, gTag, yLabel, innerHeight, innerWidth, yAxisLeft, yAxisRight, xScale, chartJSON.yMaxLeft, chartJSON.dimensionList, chartType, isDateType, width, dimensionHeightWidthArray, columnWidth);
|
|
119
|
-
horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
|
|
120
|
-
if (formatOptions.dataTableProperties &&
|
|
121
|
-
formatOptions.dataTableProperties.dataTable) {
|
|
122
|
-
if (formatOptions.xAxisLabel.xAxisPosition != "1")
|
|
123
|
-
formatOptions.xAxisLabel.xAxisLabelVisibility = false;
|
|
124
|
-
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);
|
|
125
|
-
}
|
|
126
|
-
setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
|
|
127
|
-
yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
|
|
128
|
-
yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
|
|
129
|
-
setChartTitle(svg, formatOptions, width, chartTitleHeight);
|
|
130
|
-
drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, staticLegendShape.rectangle);
|
|
131
|
-
};
|
|
132
|
-
const preProcessChartData = () => {
|
|
133
|
-
const allChartData = [];
|
|
134
|
-
const legendList = [];
|
|
135
|
-
let formatedDimensionList = [];
|
|
136
|
-
let firstMeasure = "";
|
|
137
|
-
let yMaxLeft = 0;
|
|
138
|
-
// let yMinLeft = Infinity;
|
|
139
|
-
let yMaxRight = -Infinity;
|
|
140
|
-
// let yMinRight = Infinity;
|
|
141
|
-
seriesData.forEach((series) => {
|
|
142
|
-
legendList.push(series.legend);
|
|
143
|
-
series.data.forEach((point) => {
|
|
144
|
-
if (series.properties.currentMeasure === firstMeasure) {
|
|
145
|
-
point.value = -point.value; // Invert value for left axis
|
|
146
|
-
}
|
|
147
|
-
allChartData.push(point);
|
|
148
|
-
});
|
|
149
|
-
let measuresArray = series.data.map((d) => d.value);
|
|
150
|
-
if (series.properties.currentMeasure === firstMeasure) {
|
|
151
|
-
yMaxLeft = Math.min(yMaxLeft, Math.min(...measuresArray));
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
yMaxRight = Math.max(yMaxRight, Math.max(...measuresArray));
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
chartJSON.chartData = allChartData;
|
|
158
|
-
chartJSON.legendList = legendList;
|
|
159
|
-
chartJSON.yMaxLeft = yMaxLeft;
|
|
160
|
-
// chartJSON.yMinLeft = yMinLeft > 0 ? 0 : yMinLeft;
|
|
161
|
-
chartJSON.yMaxRight = yMaxRight;
|
|
162
|
-
// chartJSON.yMinRight = yMinRight;
|
|
163
|
-
// Apply formatted dimensions
|
|
164
|
-
formatedDimensionList = isDateType
|
|
165
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
166
|
-
: chartJSON.dimensionList;
|
|
167
|
-
chartJSON.dimensionList.forEach((dim, i) => {
|
|
168
|
-
chartJSON.formattedDimensionListMap.set(dim, formatedDimensionList[i]);
|
|
169
|
-
});
|
|
170
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
171
|
-
if (!formatOptions.plotArea.fitChart) {
|
|
172
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
filteredDimension = chartJSON.dimensionList;
|
|
176
|
-
}
|
|
177
|
-
if (formatOptions.plotArea.hideZeroValues) {
|
|
178
|
-
chartJSON.hideZeroValues = true;
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
const initScale = () => {
|
|
182
|
-
columnWidth =
|
|
183
|
-
(0.51 + (0.61 * (100 - parseFloat(formatOptions.plotArea.plotAreaGapWidth))) / 100) *
|
|
184
|
-
(innerHeight / filteredDimension.length);
|
|
185
|
-
let right = false;
|
|
186
|
-
let left = false;
|
|
187
|
-
let maxValue;
|
|
188
|
-
if (chartJSON.yMaxLeft > chartJSON.yMaxRight) {
|
|
189
|
-
maxValue = chartJSON.yMaxLeft;
|
|
190
|
-
right = true;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
maxValue = chartJSON.yMaxRight;
|
|
194
|
-
left = true;
|
|
195
|
-
}
|
|
196
|
-
let adjustedPosition = formatOptions.annotation.annotationVisibility != "5" && formatOptions.annotation.annotationPosition == "1" ? 20 : 0;
|
|
197
|
-
let scaleFactor = formatOptions.annotation.annotationVisibility != "5" ? ((chartJSON.yMaxLeft / maxValue) !== 1 ? Math.abs(chartJSON.yMaxLeft / maxValue) * 100 < 10 ? 3 : 0 : Math.abs(chartJSON.yMaxRight / maxValue) * 100 < 10 ? 3 : 0) : 0; // scale difference in X scale
|
|
198
|
-
// rounding the ymin & ymax
|
|
199
|
-
let yAxisLabelArray = responsiveYaxisLabel(chartJSON.yMaxRight, chartJSON.yMaxLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue, barChart, innerWidth).yAxisLabelArray;
|
|
200
|
-
chartJSON.yMaxLeft = yAxisLabelArray[0];
|
|
201
|
-
xScaleForLegends = d3
|
|
202
|
-
.scaleLinear()
|
|
203
|
-
.domain([chartJSON.yMaxLeft * (1.2 + (left ? scaleFactor : 0)), chartJSON.yMaxRight * (1.2 + (right ? scaleFactor : 0))])
|
|
204
|
-
.range([adjustedPosition, innerWidth - adjustedPosition]);
|
|
205
|
-
xScale = xScaleForLegends;
|
|
206
|
-
calculatedRange = [0, innerWidth];
|
|
207
|
-
getXScale();
|
|
208
|
-
};
|
|
209
|
-
const getXScale = () => {
|
|
210
|
-
yScaleLeft = d3.scaleBand()
|
|
211
|
-
.domain(chartJSON.dimensionList)
|
|
212
|
-
.range([innerHeight, 0])
|
|
213
|
-
.padding(0.35);
|
|
214
|
-
};
|
|
215
|
-
const initAxis = () => {
|
|
216
|
-
getXAxis();
|
|
217
|
-
// if (isPrimaryAxisDrawn) {
|
|
218
|
-
yAxisLeft = d3.axisLeft(yScaleLeft)
|
|
219
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
220
|
-
? formatOptions.plotArea.gridLinesHorizontal
|
|
221
|
-
? -(innerWidth - xScaleForLegends(0))
|
|
222
|
-
: 0
|
|
223
|
-
: 0)
|
|
224
|
-
.tickSizeOuter(0)
|
|
225
|
-
.tickValues(responsiveXaxisLabel(chartJSON.dimensionList, innerWidth));
|
|
226
|
-
yAxisRight = d3.axisRight(yScaleLeft)
|
|
227
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
228
|
-
? formatOptions.plotArea.gridLinesHorizontal
|
|
229
|
-
? -xScaleForLegends(0)
|
|
230
|
-
: 0
|
|
231
|
-
: 0)
|
|
232
|
-
.tickSizeOuter(0)
|
|
233
|
-
.tickValues(responsiveXaxisLabel(chartJSON.dimensionList, innerWidth));
|
|
234
|
-
// }
|
|
235
|
-
};
|
|
236
|
-
const getXAxis = () => {
|
|
237
|
-
xAxis = d3
|
|
238
|
-
.axisBottom(xScaleForLegends)
|
|
239
|
-
.tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision, true))
|
|
240
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
241
|
-
? formatOptions.plotArea.gridLinesVertical
|
|
242
|
-
? formatOptions.plotArea.ticksHeight == "100"
|
|
243
|
-
? -innerHeight
|
|
244
|
-
: -formatOptions.plotArea.ticksHeight * (innerHeight / 100)
|
|
245
|
-
: 0
|
|
246
|
-
: 0)
|
|
247
|
-
.tickValues(responsiveYaxisLabel(chartJSON.yMaxRight, chartJSON.yMaxLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue, barChart, innerWidth).yAxisLabelArray)
|
|
248
|
-
.ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue, barChart, innerWidth).customTickValue ??
|
|
249
|
-
(dataTableHeight > 0
|
|
250
|
-
? (innerWidth - dataTableHeight) / 30
|
|
251
|
-
: innerWidth / 30))
|
|
252
|
-
.tickSizeOuter(0);
|
|
253
|
-
};
|
|
254
|
-
const getChartType = (lineData) => {
|
|
255
|
-
// let barData = [];
|
|
256
|
-
// filteredData.forEach(d => {
|
|
257
|
-
// d.data.forEach(k => {
|
|
258
|
-
// barData.push(k)
|
|
259
|
-
// })
|
|
260
|
-
// })
|
|
261
|
-
let sensitivityData = [];
|
|
262
|
-
if (isSensitivityChart) {
|
|
263
|
-
// barData.forEach((data, i) => {
|
|
264
|
-
// data.data.forEach((cdata) => {
|
|
265
|
-
// let tempObj = {
|
|
266
|
-
// "Dimension": data.Dimension,
|
|
267
|
-
// "data": [cdata]
|
|
268
|
-
// }
|
|
269
|
-
// sensitivityData.push(tempObj);
|
|
270
|
-
// })
|
|
271
|
-
// })
|
|
272
|
-
// barData = sensitivityData;
|
|
273
|
-
}
|
|
274
|
-
let positiveBarColor = formatOptions.plotArea.plotAreaCalculatedHigh;
|
|
275
|
-
let negativeBarColor = formatOptions.plotArea.plotAreaCalculatedLow;
|
|
276
|
-
gTag
|
|
277
|
-
.append("g")
|
|
278
|
-
.attr("class", "parentGroup")
|
|
279
|
-
.selectAll("#scaling-svg" + chartId + " .rect")
|
|
280
|
-
.data(filteredData)
|
|
281
|
-
.enter()
|
|
282
|
-
.append("g")
|
|
283
|
-
//.attr("fill", (d) => d.data[0].color !== "#ffffff" ? d.data[0].color : "none")
|
|
284
|
-
.attr("class", (d) => isSensitivityChart ? (d.data[0].value > 0 ? "Calculated High(+ve)".replace(/ /g, "-") : "Calculated Low(-ve)".replace(/ /g, "-")) : d.data[0].legend.replace(/ /g, "-"))
|
|
285
|
-
.selectAll("rect")
|
|
286
|
-
.data(d => d.data.map(child => ({
|
|
287
|
-
...child,
|
|
288
|
-
parentProperties: d.properties
|
|
289
|
-
})))
|
|
290
|
-
.enter()
|
|
291
|
-
.append("rect")
|
|
292
|
-
.attr("class", "rect")
|
|
293
|
-
.attr("y", (d) => d.dimension ? yScaleLeft(d.dimension) : yScaleLeft("defaultEntry"))
|
|
294
|
-
.attr("x", (d) => xScale(Math.min(0, d.value)))
|
|
295
|
-
.attr("stroke-dasharray", (d) => d.stackBorderStyle == 2 ? "5,3" : "0")
|
|
296
|
-
.attr("stroke-width", (d) => d.stackBorderWidth + "px")
|
|
297
|
-
.attr("stroke", (d) => (d.stackBorderStyle == 0) ? "none" : formatOptions.column.stackBorderVisibility ? d.stackBorderColor : "none")
|
|
298
|
-
// .style("clip-path", "inset(0px) fill-box")
|
|
299
|
-
.style("shape-rendering", "crispEdges")
|
|
300
|
-
.attr("width", (d) => d.value ? Math.abs(xScale(d.value) - xScale(0)) : 0)
|
|
301
|
-
.attr("height", yScaleLeft.bandwidth())
|
|
302
|
-
.style("fill", d => isSensitivityChart ? (d.value > 0 ? (positiveBarColor !== "#ffffff" ? positiveBarColor : "none")
|
|
303
|
-
: (negativeBarColor !== "#ffffff" ? negativeBarColor : "none")) : d.parentProperties.color)
|
|
304
|
-
.attr("opacity", 1)
|
|
305
|
-
.on("mousemove", (event, d) => {
|
|
306
|
-
showTooltipOnMouseMove([
|
|
307
|
-
{ key: "Measure", value: d.legend },
|
|
308
|
-
{ key: "Legend", value: d.dimension, },
|
|
309
|
-
{
|
|
310
|
-
key: "Value", value: (d.value < 0 ? getNumberWithFormat(-d.value, formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision, true) :
|
|
311
|
-
getNumberWithFormat(d.value, formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision, true))
|
|
312
|
-
},
|
|
313
|
-
], formatOptions);
|
|
314
|
-
})
|
|
315
|
-
.on("mouseout", () => {
|
|
316
|
-
hideTooltipOnMouseOut();
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
const setSVGContainer = (margin) => {
|
|
320
|
-
innerWidth = width - margin.left - margin.right;
|
|
321
|
-
innerHeight = height - margin.bottom - margin.top;
|
|
322
|
-
};
|
|
323
|
-
const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
|
|
324
|
-
if (!formatOptions.plotArea.fitChart) {
|
|
325
|
-
// Scrollbar parameters
|
|
326
|
-
const scrollMax = seriesData[0].data.length - visibleBars;
|
|
327
|
-
// Scrollbar track & handle
|
|
328
|
-
const scrollbarY = height - 20;
|
|
329
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
330
|
-
getXScale();
|
|
331
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
332
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
333
|
-
getXAxis();
|
|
334
|
-
svg
|
|
335
|
-
.append("rect")
|
|
336
|
-
.attr("x", margin.left)
|
|
337
|
-
.attr("y", scrollbarY)
|
|
338
|
-
.attr("width", innerWidth)
|
|
339
|
-
.attr("height", 8)
|
|
340
|
-
.attr("fill", "#ddd")
|
|
341
|
-
.attr("rx", 4);
|
|
342
|
-
const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
|
|
343
|
-
const handle = svg
|
|
344
|
-
.append("rect")
|
|
345
|
-
.attr("x", margin.left)
|
|
346
|
-
.attr("y", scrollbarY)
|
|
347
|
-
.attr("width", handleWidth)
|
|
348
|
-
.attr("height", 8)
|
|
349
|
-
.attr("fill", "#999")
|
|
350
|
-
.attr("rx", 4)
|
|
351
|
-
.style("cursor", "ew-resize")
|
|
352
|
-
.call(d3.drag().on("drag", (event) => {
|
|
353
|
-
let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
|
|
354
|
-
handle.attr("x", x);
|
|
355
|
-
scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
|
|
356
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
357
|
-
getXScale();
|
|
358
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
359
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
360
|
-
getXAxis();
|
|
361
|
-
drawColumnChart();
|
|
362
|
-
}));
|
|
363
|
-
svg.on("wheel", (event) => {
|
|
364
|
-
event.preventDefault();
|
|
365
|
-
const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
|
|
366
|
-
? event.deltaX
|
|
367
|
-
: event.deltaY;
|
|
368
|
-
scrollPosition += scrollDelta > 0 ? 1 : -1;
|
|
369
|
-
scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
|
|
370
|
-
const x = margin.left +
|
|
371
|
-
((innerWidth - handleWidth) * scrollPosition) / scrollMax;
|
|
372
|
-
handle.attr("x", x);
|
|
373
|
-
getXScale();
|
|
374
|
-
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
375
|
-
filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
376
|
-
getXAxis();
|
|
377
|
-
drawColumnChart();
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
drawColumnChart();
|
|
381
|
-
};
|
|
382
|
-
const drawColumnChart = () => {
|
|
383
|
-
getChartType(filteredData);
|
|
384
|
-
initXaxisBar(formatOptions, gTag, xLabel, innerHeight, innerWidth, xAxis);
|
|
385
|
-
commonAnnotations(filteredData, yScaleLeft, xScale, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
386
|
-
margin, d3Annotation, [], //this.labelExcludeList,
|
|
387
|
-
[], //this.individualLabelColor,
|
|
388
|
-
[], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
|
|
389
|
-
formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg, yScaleLeft, columnWidth, isSensitivityChart, barChart);
|
|
390
|
-
};
|
|
391
|
-
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%" } })] }));
|
|
392
|
-
};
|
|
393
|
-
export default TornadoChart;
|