pace-chart-lib 0.0.7 → 0.0.8

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.
Files changed (150) hide show
  1. package/README.md +10 -10
  2. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +46 -0
  3. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +2285 -0
  4. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +169 -0
  5. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +47 -0
  6. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +4 -0
  7. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.js +403 -0
  8. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  9. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -0
  10. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  11. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  12. package/dist/Components1/Charts/Core/Common.type.d.ts +8 -0
  13. package/dist/Components1/Charts/Core/Common.type.js +9 -0
  14. package/dist/Components1/Charts/Core/CommonFunctions.d.ts +12 -0
  15. package/dist/Components1/Charts/Core/CommonFunctions.js +512 -0
  16. package/dist/Components1/Charts/Core/DefaultProperties.d.ts +586 -0
  17. package/dist/Components1/Charts/Core/DefaultProperties.js +585 -0
  18. package/dist/Services/ErrorLog.d.ts +1 -0
  19. package/dist/Services/ErrorLog.js +3 -0
  20. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +4 -0
  21. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +497 -0
  22. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +4 -0
  23. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +491 -0
  24. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +4 -0
  25. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +520 -0
  26. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +4 -0
  27. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +553 -0
  28. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +4 -0
  29. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +519 -0
  30. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +4 -0
  31. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +553 -0
  32. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +12 -0
  33. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +9 -0
  34. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +623 -0
  35. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +4897 -0
  36. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
  37. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
  38. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +173 -0
  39. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +49 -0
  40. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +4 -0
  41. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +486 -0
  42. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +4 -0
  43. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +498 -0
  44. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +4 -0
  45. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +417 -0
  46. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +4 -0
  47. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +1014 -0
  48. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +4 -0
  49. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +479 -0
  50. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +4 -0
  51. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +451 -0
  52. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +4 -0
  53. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +535 -0
  54. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.d.ts +4 -0
  55. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +512 -0
  56. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +4 -0
  57. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +532 -0
  58. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.d.ts +4 -0
  59. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +512 -0
  60. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +12 -0
  61. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +9 -0
  62. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +4 -0
  63. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +498 -0
  64. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +4 -0
  65. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +498 -0
  66. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +4 -0
  67. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +479 -0
  68. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +4 -0
  69. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +479 -0
  70. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +4 -0
  71. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +474 -0
  72. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +4 -0
  73. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +464 -0
  74. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
  75. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
  76. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +4 -0
  77. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +452 -0
  78. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +4 -0
  79. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +554 -0
  80. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +4 -0
  81. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +513 -0
  82. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +4 -0
  83. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +508 -0
  84. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +4 -0
  85. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +395 -0
  86. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +4 -0
  87. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +608 -0
  88. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
  89. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
  90. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +92 -0
  91. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +815 -0
  92. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  93. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  94. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +108 -0
  95. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +32 -0
  96. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +26 -0
  97. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +15021 -0
  98. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +4 -0
  99. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +391 -0
  100. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +4 -0
  101. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +367 -0
  102. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +4 -0
  103. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +569 -0
  104. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +3 -0
  105. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +212 -0
  106. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +3 -0
  107. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +401 -0
  108. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +4 -0
  109. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +313 -0
  110. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +4 -0
  111. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +719 -0
  112. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +4 -0
  113. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +807 -0
  114. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +3 -0
  115. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +514 -0
  116. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +4 -0
  117. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +282 -0
  118. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +4 -0
  119. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +207 -0
  120. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +4 -0
  121. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +476 -0
  122. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +4 -0
  123. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +420 -0
  124. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +10 -0
  125. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +106 -0
  126. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +3 -0
  127. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +507 -0
  128. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +3 -0
  129. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +246 -0
  130. package/dist/components/Charts/Core/Common.type.d.ts +0 -0
  131. package/dist/components/Charts/Core/Common.type.js +0 -0
  132. package/dist/components/Charts/Core/Common.types.d.ts +369 -0
  133. package/dist/components/Charts/Core/Common.types.js +133 -0
  134. package/dist/components/Charts/Core/CommonFunctions.d.ts +236 -0
  135. package/dist/components/Charts/Core/CommonFunctions.js +1778 -0
  136. package/dist/components/Charts/Core/DefaultChartDataProperties.d.ts +65 -0
  137. package/dist/components/Charts/Core/DefaultChartDataProperties.js +64 -0
  138. package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
  139. package/dist/components/Charts/Core/DefaultProperties.js +0 -0
  140. package/dist/components/Charts/Core/DefaultProperties.type.d.ts +586 -0
  141. package/dist/components/Charts/Core/DefaultProperties.type.js +585 -0
  142. package/dist/components/Charts/Core/DefaultProperties.types.d.ts +592 -0
  143. package/dist/components/Charts/Core/DefaultProperties.types.js +592 -0
  144. package/dist/index.d.ts +34 -2
  145. package/dist/index.js +40 -2
  146. package/package.json +40 -29
  147. package/dist/components/charts/linechart/LineChart.d.ts +0 -12
  148. package/dist/components/charts/linechart/LineChart.js +0 -5
  149. /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.d.ts +0 -0
  150. /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.js +0 -0
@@ -0,0 +1,395 @@
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 = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
12
+ // adding variables as per requirement
13
+ let columnWidth = 0; // coz line chartO
14
+ const chartType = actualChartTypes.tornadoChart;
15
+ const svgRef = useRef();
16
+ const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
17
+ const dimensionList = data.DimensionList;
18
+ const barChart = true;
19
+ const isSecondaryAxisDrawn = false;
20
+ const isNormalizedChart = false;
21
+ let isPrimaryAxisDrawn = true;
22
+ let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
23
+ let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
24
+ let secondaryCustomYaxisMinValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMinText);
25
+ let secondaryCustomYaxisMaxValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMaxText);
26
+ let margin;
27
+ let yLabel;
28
+ let xLabel;
29
+ let yTitle;
30
+ let xTitle;
31
+ let dimensionHeightWidthArray;
32
+ let chartTitleHeight;
33
+ let secondaryAxisTitleWidth;
34
+ let legendMargin;
35
+ let secondaryYLabel;
36
+ let maxNumberForPrimaryAxis;
37
+ let maxNumberForSecondaryAxis;
38
+ let innerWidth;
39
+ let innerHeight;
40
+ let width;
41
+ let height;
42
+ let dataTable;
43
+ let dataTableHeight;
44
+ let svg;
45
+ let gTag;
46
+ let yScaleLeft;
47
+ let yScaleRight;
48
+ let xScale;
49
+ let xScaleForLegends;
50
+ let seriesLabels;
51
+ let calculatedRange;
52
+ let seriesLabelWidth;
53
+ let yAxisLeft;
54
+ let xAxis;
55
+ let yAxisRight;
56
+ let filteredDimension;
57
+ let filteredData = [];
58
+ let isSensitivityChart = false;
59
+ let scrollPosition = 0;
60
+ const visibleBars = 2;
61
+ let chartJSON = {
62
+ dimensionList: dimensionList,
63
+ chartType: chartType,
64
+ chartData: [],
65
+ formatOptions: formatOptions,
66
+ legendList: [],
67
+ secondaryAxisDrawn: false,
68
+ yMaxLeft: 0,
69
+ yMaxRight: 0,
70
+ yMinLeft: 0,
71
+ yMinRight: 0,
72
+ hideZeroValues: false,
73
+ formattedDimensionListMap: new Map(),
74
+ };
75
+ //#region UseEffect
76
+ useEffect(() => {
77
+ try {
78
+ createTornadoChart();
79
+ }
80
+ catch (error) {
81
+ logError("Tornadochart", "createTornadoChart", error);
82
+ }
83
+ }, [formatOptions]);
84
+ //#endregion
85
+ const createTornadoChart = () => {
86
+ ({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
87
+ preProcessChartData(); // preaparing data related to chart creation
88
+ // Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
89
+ ({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } = customYscaleLabelFormatting(
90
+ // for calculating primary/secondary axis max number so that we can calculate margin accordinglt
91
+ formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
92
+ ({
93
+ margin,
94
+ yLabel,
95
+ xLabel,
96
+ yTitle,
97
+ xTitle,
98
+ dimensionHeightWidthArray,
99
+ chartTitleHeight,
100
+ secondaryAxisTitleWidth,
101
+ legendMargin,
102
+ secondaryYLabel,
103
+ } = marginCalculation(
104
+ // for all margin related calculations
105
+ width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart));
106
+ setSVGContainer(margin); // for innerWidth/height static width/height
107
+ ({ dataTable, dataTableHeight } = dataTablePreCalculation(
108
+ // calculations for data tables
109
+ formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
110
+ initSvg(
111
+ // for svg creation
112
+ svg, width, height, formatOptions);
113
+ gTag = initChartArea(svg, margin); // creating chart area
114
+ initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
115
+ initScale();
116
+ initAxis();
117
+ initYaxisBar(formatOptions, gTag, yLabel, innerHeight, innerWidth, yAxisLeft, yAxisRight, xScale, chartJSON.yMaxLeft, chartJSON.dimensionList, chartType, xAxisObj[0], width, dimensionHeightWidthArray, columnWidth);
118
+ horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
119
+ if (formatOptions.dataTableProperties &&
120
+ formatOptions.dataTableProperties.dataTable) {
121
+ if (formatOptions.xAxisLabel.xAxisPosition != "1")
122
+ formatOptions.xAxisLabel.xAxisLabelVisibility = false;
123
+ 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);
124
+ }
125
+ setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
126
+ yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
127
+ yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
128
+ setChartTitle(svg, formatOptions, width, chartTitleHeight);
129
+ drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, staticLegendShape.rectangle);
130
+ };
131
+ const preProcessChartData = () => {
132
+ const allChartData = [];
133
+ const legendList = [];
134
+ let formatedDimesionList = [];
135
+ let firstMeasure = yAxisObj[0].name.actualName;
136
+ let yMaxLeft = 0;
137
+ // let yMinLeft = Infinity;
138
+ let yMaxRight = -Infinity;
139
+ // let yMinRight = Infinity;
140
+ seriesData.forEach((series) => {
141
+ legendList.push(series.legend);
142
+ series.data.forEach((point) => {
143
+ if (series.properties.currentMeasure === firstMeasure) {
144
+ point.value = -point.value; // Invert value for left axis
145
+ }
146
+ allChartData.push(point);
147
+ });
148
+ let measuresArray = series.data.map((d) => d.value);
149
+ if (series.properties.currentMeasure === firstMeasure) {
150
+ yMaxLeft = Math.min(yMaxLeft, Math.min(...measuresArray));
151
+ }
152
+ else {
153
+ yMaxRight = Math.max(yMaxRight, Math.max(...measuresArray));
154
+ }
155
+ });
156
+ chartJSON.chartData = allChartData;
157
+ chartJSON.legendList = legendList;
158
+ chartJSON.yMaxLeft = yMaxLeft;
159
+ // chartJSON.yMinLeft = yMinLeft;
160
+ chartJSON.yMaxRight = yMaxRight;
161
+ // chartJSON.yMinRight = yMinRight;
162
+ // Apply formatted dimensions
163
+ let xAxisObject = xAxisObj[0];
164
+ formatedDimesionList =
165
+ (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
166
+ xAxisObject.dataType === "DATE"
167
+ ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d[0])
168
+ : chartJSON.dimensionList;
169
+ chartJSON.dimensionList.forEach((dim, i) => {
170
+ chartJSON.formattedDimensionListMap.set(dim, formatedDimesionList[i]);
171
+ });
172
+ filteredData = JSON.parse(JSON.stringify(seriesData));
173
+ if (!formatOptions.plotArea.fitChart) {
174
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
175
+ }
176
+ else {
177
+ filteredDimension = chartJSON.dimensionList;
178
+ }
179
+ if (formatOptions.plotArea.hideZeroValues) {
180
+ chartJSON.hideZeroValues = true;
181
+ }
182
+ };
183
+ const initScale = () => {
184
+ columnWidth =
185
+ (0.51 + (0.61 * (100 - parseFloat(formatOptions.plotArea.plotAreaGapWidth))) / 100) *
186
+ (innerHeight / filteredDimension.length);
187
+ let right = false;
188
+ let left = false;
189
+ let maxValue;
190
+ if (chartJSON.yMaxLeft > chartJSON.yMaxRight) {
191
+ maxValue = chartJSON.yMaxLeft;
192
+ right = true;
193
+ }
194
+ else {
195
+ maxValue = chartJSON.yMaxRight;
196
+ left = true;
197
+ }
198
+ let adjustedPosition = formatOptions.annotation.annotationVisibility != "5" && formatOptions.annotation.annotationPosition == "1" ? 20 : 0;
199
+ 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
200
+ // rounding the ymin & ymax
201
+ let yAxisLabelArray = responsiveYaxisLabel(chartJSON.yMaxRight, chartJSON.yMaxLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue, barChart, innerWidth).yAxisLabelArray;
202
+ chartJSON.yMaxLeft = yAxisLabelArray[0];
203
+ xScaleForLegends = d3
204
+ .scaleLinear()
205
+ .domain([chartJSON.yMaxLeft * (1.2 + (left ? scaleFactor : 0)), chartJSON.yMaxRight * (1.2 + (right ? scaleFactor : 0))])
206
+ .range([adjustedPosition, innerWidth - adjustedPosition]);
207
+ xScale = xScaleForLegends;
208
+ calculatedRange = [0, innerWidth];
209
+ getXScale();
210
+ };
211
+ const getXScale = () => {
212
+ yScaleLeft = d3.scaleBand()
213
+ .domain(chartJSON.dimensionList)
214
+ .range([innerHeight, 0])
215
+ .padding(0.35);
216
+ };
217
+ const initAxis = () => {
218
+ getXAxis();
219
+ // if (isPrimaryAxisDrawn) {
220
+ yAxisLeft = d3.axisLeft(yScaleLeft)
221
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
222
+ ? formatOptions.plotArea.gridLinesHorizontal
223
+ ? -(innerWidth - xScaleForLegends(0))
224
+ : 0
225
+ : 0)
226
+ .tickSizeOuter(0)
227
+ .tickValues(responsiveXaxisLabel(chartJSON.dimensionList, innerWidth));
228
+ yAxisRight = d3.axisRight(yScaleLeft)
229
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
230
+ ? formatOptions.plotArea.gridLinesHorizontal
231
+ ? -xScaleForLegends(0)
232
+ : 0
233
+ : 0)
234
+ .tickSizeOuter(0)
235
+ .tickValues(responsiveXaxisLabel(chartJSON.dimensionList, innerWidth));
236
+ // }
237
+ };
238
+ const getXAxis = () => {
239
+ xAxis = d3
240
+ .axisBottom(xScaleForLegends)
241
+ .tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision, true))
242
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
243
+ ? formatOptions.plotArea.gridLinesVertical
244
+ ? formatOptions.plotArea.ticksHeight == "100"
245
+ ? -innerHeight
246
+ : -formatOptions.plotArea.ticksHeight * (innerHeight / 100)
247
+ : 0
248
+ : 0)
249
+ .tickValues(responsiveYaxisLabel(chartJSON.yMaxRight, chartJSON.yMaxLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue, barChart, innerWidth).yAxisLabelArray)
250
+ .ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue, barChart, innerWidth).customTickValue ??
251
+ (dataTableHeight > 0
252
+ ? (innerWidth - dataTableHeight) / 30
253
+ : innerWidth / 30))
254
+ .tickSizeOuter(0);
255
+ };
256
+ const getChartType = (lineData) => {
257
+ // let barData = [];
258
+ // filteredData.forEach(d => {
259
+ // d.data.forEach(k => {
260
+ // barData.push(k)
261
+ // })
262
+ // })
263
+ let sensitivityData = [];
264
+ if (isSensitivityChart) {
265
+ // barData.forEach((data, i) => {
266
+ // data.data.forEach((cdata) => {
267
+ // let tempObj = {
268
+ // "Dimension": data.Dimension,
269
+ // "data": [cdata]
270
+ // }
271
+ // sensitivityData.push(tempObj);
272
+ // })
273
+ // })
274
+ // barData = sensitivityData;
275
+ }
276
+ let positiveBarColor = formatOptions.plotArea.plotAreaCalculatedHigh;
277
+ let negativeBarColor = formatOptions.plotArea.plotAreaCalculatedLow;
278
+ gTag
279
+ .append("g")
280
+ .attr("class", "parentGroup")
281
+ .selectAll("#scaling-svg" + chartId + " .rect")
282
+ .data(filteredData)
283
+ .enter()
284
+ .append("g")
285
+ //.attr("fill", (d) => d.data[0].color !== "#ffffff" ? d.data[0].color : "none")
286
+ .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, "-"))
287
+ .selectAll("rect")
288
+ .data(d => d.data.map(child => ({
289
+ ...child,
290
+ parentProperties: d.properties
291
+ })))
292
+ .enter()
293
+ .append("rect")
294
+ .attr("class", "rect")
295
+ .attr("y", (d) => d.dimension ? yScaleLeft(d.dimension) : yScaleLeft("defaultEntry"))
296
+ .attr("x", (d) => xScale(Math.min(0, d.value)))
297
+ .attr("stroke-dasharray", (d) => d.stackBorderStyle == 2 ? "5,3" : "0")
298
+ .attr("stroke-width", (d) => d.stackBorderWidth + "px")
299
+ .attr("stroke", (d) => (d.stackBorderStyle == 0) ? "none" : formatOptions.column.stackBorderVisibility ? d.stackBorderColor : "none")
300
+ // .style("clip-path", "inset(0px) fill-box")
301
+ .style("shape-rendering", "crispEdges")
302
+ .attr("width", (d) => d.value ? Math.abs(xScale(d.value) - xScale(0)) : 0)
303
+ .attr("height", yScaleLeft.bandwidth())
304
+ .style("fill", d => isSensitivityChart ? (d.value > 0 ? (positiveBarColor !== "#ffffff" ? positiveBarColor : "none")
305
+ : (negativeBarColor !== "#ffffff" ? negativeBarColor : "none")) : d.parentProperties.color)
306
+ .attr("opacity", 1)
307
+ .on("mousemove", (event, d) => {
308
+ showTooltipOnMouseMove([
309
+ { key: "Measure", value: d.legend },
310
+ { key: "Legend", value: d.dimension, },
311
+ {
312
+ key: "Value", value: (d.value < 0 ? getNumberWithFormat(-d.value, formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision, true) :
313
+ getNumberWithFormat(d.value, formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision, true))
314
+ },
315
+ ], formatOptions);
316
+ })
317
+ .on("mouseout", () => {
318
+ hideTooltipOnMouseOut();
319
+ });
320
+ };
321
+ const setSVGContainer = (margin) => {
322
+ innerWidth = width - margin.left - margin.right;
323
+ innerHeight = height - margin.bottom - margin.top;
324
+ };
325
+ const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
326
+ if (!formatOptions.plotArea.fitChart) {
327
+ // Scrollbar parameters
328
+ const scrollMax = seriesData[0].data.length - visibleBars;
329
+ // Scrollbar track & handle
330
+ const scrollbarY = height - 20;
331
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
332
+ getXScale();
333
+ filteredData = JSON.parse(JSON.stringify(seriesData));
334
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
335
+ getXAxis();
336
+ svg
337
+ .append("rect")
338
+ .attr("x", margin.left)
339
+ .attr("y", scrollbarY)
340
+ .attr("width", innerWidth)
341
+ .attr("height", 8)
342
+ .attr("fill", "#ddd")
343
+ .attr("rx", 4);
344
+ const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
345
+ const handle = svg
346
+ .append("rect")
347
+ .attr("x", margin.left)
348
+ .attr("y", scrollbarY)
349
+ .attr("width", handleWidth)
350
+ .attr("height", 8)
351
+ .attr("fill", "#999")
352
+ .attr("rx", 4)
353
+ .style("cursor", "ew-resize")
354
+ .call(d3.drag().on("drag", (event) => {
355
+ let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
356
+ handle.attr("x", x);
357
+ scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
358
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
359
+ getXScale();
360
+ filteredData = JSON.parse(JSON.stringify(seriesData));
361
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
362
+ getXAxis();
363
+ drawColumnChart();
364
+ }));
365
+ svg.on("wheel", (event) => {
366
+ event.preventDefault();
367
+ const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
368
+ ? event.deltaX
369
+ : event.deltaY;
370
+ scrollPosition += scrollDelta > 0 ? 1 : -1;
371
+ scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
372
+ const x = margin.left +
373
+ ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
374
+ handle.attr("x", x);
375
+ getXScale();
376
+ filteredData = JSON.parse(JSON.stringify(seriesData));
377
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
378
+ getXAxis();
379
+ drawColumnChart();
380
+ });
381
+ }
382
+ drawColumnChart();
383
+ };
384
+ const drawColumnChart = () => {
385
+ getChartType(filteredData);
386
+ initXaxisBar(formatOptions, gTag, xLabel, innerHeight, innerWidth, xAxis);
387
+ commonAnnotations(filteredData, yScaleLeft, xScale, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
388
+ margin, d3Annotation, [], //this.labelExcludeList,
389
+ [], //this.individualLabelColor,
390
+ [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
391
+ formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg, yScaleLeft, columnWidth, isSensitivityChart, barChart);
392
+ };
393
+ 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%" } })] }));
394
+ };
395
+ export default TornadoChart;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type TChartProps } from "../ChartsWithAxisTypes.types";
3
+ declare const WaterfallChart: React.FC<TChartProps>;
4
+ export default WaterfallChart;