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,520 @@
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, lineMarkers, onHoverMarkerForAreaChartFamily, } from "../../Core/CommonFunctions";
9
+ import { addDataTable, dataTablePreCalculation, drawSeriesLabels, firstFunctionBeforeRender, getCurveType, getStackedData, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, setChartTitle, setDateFormats, setXaxistitle, stacklineAnnotations, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
10
+ import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
11
+ const NormalizedStackAreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
12
+ // adding variables as per requirement
13
+ const barWidth = 0; // coz line chart
14
+ const chartType = actualChartTypes.stackArea100;
15
+ const svgRef = useRef();
16
+ const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
17
+ const dimensionList = data.DimensionList;
18
+ const barChart = false;
19
+ const chartsWithXScrollFlag = true;
20
+ const chartsWithYScrollFlag = false;
21
+ const isSecondaryAxisDrawn = 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 seriesLabels;
51
+ let calculatedRange;
52
+ let seriesLabelWidth;
53
+ let yAxisLeft;
54
+ let xAxis;
55
+ let yAxisRight;
56
+ let filteredDimension;
57
+ let filteredData = [];
58
+ let scrollPosition = 0;
59
+ const visibleBars = 2;
60
+ let stackLineData = [];
61
+ let stackChartData = [];
62
+ const isNormalizedChart = true;
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
+ createNormalizedLinechart();
81
+ }
82
+ catch (error) {
83
+ logError("NormalizedLinechart", "createLineChart", error);
84
+ }
85
+ }, [formatOptions]);
86
+ //#endregion
87
+ const createNormalizedLinechart = () => {
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
+ // const resultCustomYscaleLabelFormatting = customYscaleLabelFormatting(
92
+ // // for calculating primary/secondary axis max number so that we can calculate margin accordinglt
93
+ // formatOptions,
94
+ // chartJSON.yMinLeft,
95
+ // chartJSON.yMaxLeft,
96
+ // chartJSON.yMinRight,
97
+ // chartJSON.yMaxRight
98
+ // );
99
+ // maxNumberForPrimaryAxis =
100
+ // resultCustomYscaleLabelFormatting.maxNumberForPrimaryAxis;
101
+ // maxNumberForSecondaryAxis =
102
+ // resultCustomYscaleLabelFormatting.maxNumberForSecondaryAxis;
103
+ ({
104
+ margin,
105
+ yLabel,
106
+ xLabel,
107
+ yTitle,
108
+ xTitle,
109
+ dimensionHeightWidthArray,
110
+ chartTitleHeight,
111
+ secondaryAxisTitleWidth,
112
+ legendMargin,
113
+ secondaryYLabel,
114
+ } = marginCalculation(
115
+ // for all margin related calculations
116
+ width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart));
117
+ setSVGContainer(margin); // for innerWidth/height static width/height
118
+ ({ dataTable, dataTableHeight } = dataTablePreCalculation(
119
+ // calculations for data tables
120
+ formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
121
+ initSvg(
122
+ // for svg creation
123
+ svg, width, height, formatOptions);
124
+ //d3.select(svgRef.current, width, height);
125
+ gTag = initChartArea(svg, margin); // creating chart area
126
+ initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
127
+ initScale();
128
+ initAxis();
129
+ initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
130
+ // initYaxisRight(
131
+ // gTag,
132
+ // formatOptions,
133
+ // dataTableHeight,
134
+ // secondaryYLabel,
135
+ // yAxisRight,
136
+ // innerHeight,
137
+ // innerWidth,
138
+ // floatingTagG
139
+ // );
140
+ horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
141
+ if (formatOptions.dataTableProperties &&
142
+ formatOptions.dataTableProperties.dataTable) {
143
+ if (formatOptions.xAxisLabel.xAxisPosition != "1")
144
+ formatOptions.xAxisLabel.xAxisLabelVisibility = false;
145
+ addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, barWidth, yScaleLeft, xScale, undefined, undefined, undefined, dataTableHeight, chartType, formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
146
+ }
147
+ setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
148
+ yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
149
+ yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
150
+ setChartTitle(svg, formatOptions, width, chartTitleHeight);
151
+ drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, staticLegendShape.areaWithLine);
152
+ };
153
+ const preProcessChartData = () => {
154
+ const allChartData = [];
155
+ const legendList = [];
156
+ seriesData.forEach((series, index) => {
157
+ // Prefix the legend
158
+ const prefixedLegend = `${index}~$~${series.properties.legend}`;
159
+ series.properties.legend = prefixedLegend;
160
+ legendList.push(prefixedLegend);
161
+ // Flatten data and collect unique dimensions
162
+ for (const point of series.data) {
163
+ allChartData.push(point);
164
+ }
165
+ });
166
+ // Assign the flattened and deduplicated results
167
+ chartJSON.chartData = allChartData;
168
+ chartJSON.legendList = legendList;
169
+ // Deep clone the updated seriesData
170
+ filteredData = JSON.parse(JSON.stringify(seriesData));
171
+ if (!formatOptions.plotArea.fitChart) {
172
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
173
+ filteredData.forEach((series) => {
174
+ series.data = series.data.filter((d) => filteredDimension.includes(d.dimension));
175
+ });
176
+ }
177
+ else {
178
+ filteredDimension = chartJSON.dimensionList;
179
+ }
180
+ // Optional zero hiding flag
181
+ if (formatOptions.plotArea.hideZeroValues) {
182
+ chartJSON.hideZeroValues = true;
183
+ }
184
+ // Prepare stacked data
185
+ const tempStackLineData = getStackedData(chartJSON.dimensionList, seriesData, isNormalizedChart);
186
+ const allStackDataChart = d3
187
+ .stack()
188
+ .keys(chartJSON.legendList)
189
+ .offset(d3.stackOffsetDiverging)(tempStackLineData);
190
+ createStackLineData();
191
+ // Get min value from stack (you manually set yMaxLeft = 1)
192
+ let yMinLeft = Infinity;
193
+ for (const series of allStackDataChart) {
194
+ for (const [start] of series) {
195
+ yMinLeft = Math.min(yMinLeft, start);
196
+ }
197
+ }
198
+ chartJSON.yMinLeft = yMinLeft;
199
+ chartJSON.yMaxLeft = 1; // as per your original override
200
+ // Format dimensions
201
+ const xAxisObject = xAxisObj[0];
202
+ const formatedDimesionList = (xAxisObject.groupBy === "NA" || xAxisObject.groupBy === undefined) &&
203
+ xAxisObject.dataType === "DATE"
204
+ ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d[0])
205
+ : chartJSON.dimensionList;
206
+ // Assign formatted dimension list map (cleanest one-liner)
207
+ chartJSON.formattedDimensionListMap = new Map(chartJSON.dimensionList.map((d, i) => [d, formatedDimesionList[i]]));
208
+ // let secondaryAxisMinValue = 0;
209
+ // let secondaryAxisMaxValue = 0;
210
+ // if (isSecondaryAxisDrawn) {
211
+ // seriesData?.forEach((data) => {
212
+ // if (data.properties.axis == "Secondary") {
213
+ // // isSecondaryAxisDrawn = true;
214
+ // if (
215
+ // secondaryAxisMinValue >
216
+ // d3.min(data.data, (d: TDataPoint) => d.value)
217
+ // ) {
218
+ // secondaryAxisMinValue = d3.min(
219
+ // data.data,
220
+ // (d: TDataPoint) => d.value
221
+ // );
222
+ // }
223
+ // if (
224
+ // secondaryAxisMaxValue <
225
+ // d3.max(data.data, (d: TDataPoint) => d.value)
226
+ // ) {
227
+ // secondaryAxisMaxValue = d3.max(
228
+ // data.data,
229
+ // (d: TDataPoint) => d.value
230
+ // );
231
+ // }
232
+ // }
233
+ // });
234
+ // chartJSON.yMinRight = secondaryAxisMinValue;
235
+ // chartJSON.yMaxRight = secondaryAxisMaxValue;
236
+ // }
237
+ };
238
+ const initScale = () => {
239
+ if (isPrimaryAxisDrawn) {
240
+ yScaleLeft = d3
241
+ .scaleLinear()
242
+ .domain([chartJSON.yMinLeft < 0 ? -1 : 0, 1])
243
+ .range([
244
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
245
+ 0,
246
+ ]);
247
+ }
248
+ if (isSecondaryAxisDrawn) {
249
+ yScaleRight = d3
250
+ .scaleLinear()
251
+ .domain([
252
+ chartJSON.yMinRight >= 0
253
+ ? (secondaryCustomYaxisMinValue ||
254
+ secondaryCustomYaxisMinValue == 0) &&
255
+ !Number.isNaN(secondaryCustomYaxisMinValue)
256
+ ? secondaryCustomYaxisMinValue
257
+ : 0
258
+ : (secondaryCustomYaxisMinValue ||
259
+ secondaryCustomYaxisMinValue == 0) &&
260
+ !Number.isNaN(secondaryCustomYaxisMinValue)
261
+ ? secondaryCustomYaxisMinValue
262
+ : chartJSON.yMinRight * 1.1,
263
+ chartJSON.yMaxRight <= 0
264
+ ? secondaryCustomYaxisMaxValue
265
+ ? secondaryCustomYaxisMaxValue
266
+ : 0
267
+ : secondaryCustomYaxisMaxValue
268
+ ? secondaryCustomYaxisMaxValue
269
+ : chartJSON.yMaxRight * 1.1,
270
+ ])
271
+ .range([
272
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
273
+ 0,
274
+ ]);
275
+ }
276
+ calculatedRange = [0, innerWidth];
277
+ if (formatOptions.seriesLabel.seriesLabelVisibility) {
278
+ let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn, true);
279
+ seriesLabels = labelObj.labelArray;
280
+ formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
281
+ (seriesLabelWidth = labelObj.heightWidth[0]);
282
+ formatOptions.seriesLabel.seriesLabelPosition == "Right"
283
+ ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
284
+ : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
285
+ }
286
+ getXScale();
287
+ };
288
+ const getXScale = () => {
289
+ xScale = d3
290
+ .scalePoint()
291
+ .domain(filteredDimension)
292
+ .range(calculatedRange)
293
+ .padding(0);
294
+ };
295
+ const initAxis = () => {
296
+ getXAxis();
297
+ if (isPrimaryAxisDrawn) {
298
+ yAxisLeft = d3
299
+ .axisLeft(yScaleLeft)
300
+ // .tickFormat((d: number) => //tick format will be always % line 544 with 0 precision
301
+ // getNumberWithFormat(
302
+ // d,
303
+ // formatOptions.yAxisLabel.yAxisDisplayUnits,
304
+ // formatOptions.yAxisLabel.yAxisNumberFormat,
305
+ // formatOptions.yAxisLabel.yAxisLabelDecimalPrecision
306
+ // )
307
+ // )
308
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
309
+ ? formatOptions.plotArea.gridLinesHorizontal
310
+ ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
311
+ : 0
312
+ : 0)
313
+ .ticks(dataTableHeight > 0
314
+ ? (innerHeight - dataTableHeight) / 30
315
+ : innerHeight / 30, "%")
316
+ .tickSizeOuter(0);
317
+ }
318
+ };
319
+ const getXAxis = () => {
320
+ xAxis = d3
321
+ .axisBottom(xScale)
322
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
323
+ ? formatOptions.plotArea.gridLinesVertical
324
+ ? formatOptions.plotArea.gridLinesVertical
325
+ ? -(dataTableHeight > 0
326
+ ? innerHeight - dataTableHeight
327
+ : innerHeight)
328
+ : parseFloat(formatOptions.plotArea.ticksHeight) *
329
+ ((dataTableHeight > 0
330
+ ? innerHeight - dataTableHeight
331
+ : innerHeight) /
332
+ 100) *
333
+ (formatOptions.xAxisLabel.xAxisPosition == "1" ? 1 : -1)
334
+ : 0
335
+ : 0)
336
+ .tickSizeOuter(0)
337
+ .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
338
+ };
339
+ const getChartType = (lineData) => {
340
+ stackChartData.forEach((data, i) => data.forEach((item, position) => {
341
+ lineData[i].data[position][0] = item[0] =
342
+ item.data.total === 0 ? 0 : item[0] / item.data.total;
343
+ lineData[i].data[position][1] = item[1] =
344
+ item.data.total === 0 ? 0 : item[1] / item.data.total;
345
+ }));
346
+ lineData.forEach((lData) => {
347
+ lData.data.forEach((cData) => {
348
+ cData.hideZero = lData.properties.hideZeroValues;
349
+ cData.axis = lData.properties.axis;
350
+ });
351
+ });
352
+ const lineGenerator = d3
353
+ .area()
354
+ .x((d) => xScale(d.data.dimension)
355
+ ? xScale(d.data.dimension)
356
+ : null)
357
+ .y0((d) =>
358
+ // d.axis == "Primary" ?
359
+ yScaleLeft(0)
360
+ // : yScaleRight(0)
361
+ )
362
+ .y1((d) =>
363
+ // d.axis == "Primary" ?
364
+ d[1] > 0 ? yScaleLeft(d[1]) : yScaleLeft(d[0])
365
+ // : yScaleRight((d as TDataPoint).value)
366
+ )
367
+ // .defined((d) => (d.hideZero ? Boolean(d.value) : true))
368
+ .curve(getCurveType(formatOptions));
369
+ //Lines
370
+ // Bind dummy data to ensure a single group is created
371
+ let area = gTag.selectAll(".parentGroup").data([stackChartData.reverse()]);
372
+ area = area
373
+ .enter()
374
+ .append("g")
375
+ .attr("class", "area parentGroup")
376
+ .merge(area);
377
+ // JOIN: one group per line
378
+ let areaGroups = area.selectAll(".line-group").data((d) => d);
379
+ let focus = gTag.append("g").attr("class", "focusClass");
380
+ // ENTER: create group for each new line
381
+ let areaGroupsEnter = areaGroups
382
+ .enter()
383
+ .append("g")
384
+ .attr("class", (d) => "line-group " + d.key.replace(/ /g, "-"));
385
+ // .attr("class", (d) => d.key.replace(/ /g, "-"));
386
+ areaGroupsEnter
387
+ .attr("hoverId", (d) => d.key.includes("~$~")
388
+ ? d.key.split("~$~")[1].replace(/ /g, "-")
389
+ : d.key.replace(/ /g, "-"))
390
+ .append("path")
391
+ .attr("class", "line")
392
+ .attr("fill", (d) => (d.color !== "#ffffff" ? d.color : "none"));
393
+ // ENTER + UPDATE
394
+ areaGroupsEnter
395
+ .merge(areaGroups)
396
+ .select("path")
397
+ .attr("d", (d, i) => lineGenerator(d))
398
+ .attr("stroke", (d) => (d.color !== "#ffffff" ? d.color : "none"))
399
+ // .style("visibility", (d,i) => (this.individualLegendStyle[i].hideZero && d[i].data[d.key] === 0) ? "hidden" : "visible")
400
+ .attr("stroke-dasharray", (d, i) => seriesData[i].properties.lineStyle === "dotted"
401
+ ? "0,3"
402
+ : seriesData[i].properties.lineStyle === "dashed"
403
+ ? "20,10,5,5,5,10"
404
+ : "")
405
+ .attr("stroke-linecap", (d, i) => seriesData[i].properties.lineStyle === "dotted" ? "round" : "")
406
+ .attr("stroke-width", (d, i) => seriesData[i].properties.lineStyle !== "None"
407
+ ? seriesData[i].properties.lineWidth
408
+ : "0");
409
+ onHoverMarkerForAreaChartFamily(formatOptions, area, focus, filteredDimension, lineData, xScale, yScaleLeft, chartType);
410
+ // EXIT: remove old groups
411
+ areaGroups.exit().remove();
412
+ //Markers
413
+ lineMarkers(area, lineData, chartType, xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue, true);
414
+ };
415
+ const setSVGContainer = (margin) => {
416
+ innerWidth = width - margin.left - margin.right;
417
+ innerHeight = height - margin.bottom - margin.top;
418
+ };
419
+ const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
420
+ if (!formatOptions.plotArea.fitChart) {
421
+ // Scrollbar parameters
422
+ const scrollMax = seriesData[0].data.length - visibleBars;
423
+ // Scrollbar track & handle
424
+ const scrollbarY = height - 20;
425
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
426
+ getXScale();
427
+ filteredData = JSON.parse(JSON.stringify(seriesData));
428
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
429
+ createStackLineData();
430
+ getXAxis();
431
+ svg
432
+ .append("rect")
433
+ .attr("x", margin.left)
434
+ .attr("y", scrollbarY)
435
+ .attr("width", innerWidth)
436
+ .attr("height", 8)
437
+ .attr("fill", "#ddd")
438
+ .attr("rx", 4);
439
+ const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
440
+ const handle = svg
441
+ .append("rect")
442
+ .attr("x", margin.left)
443
+ .attr("y", scrollbarY)
444
+ .attr("width", handleWidth)
445
+ .attr("height", 8)
446
+ .attr("fill", "#999")
447
+ .attr("rx", 4)
448
+ .style("cursor", "ew-resize")
449
+ .call(d3.drag().on("drag", (event) => {
450
+ let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
451
+ handle.attr("x", x);
452
+ scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
453
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
454
+ getXScale();
455
+ filteredData = JSON.parse(JSON.stringify(seriesData));
456
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
457
+ createStackLineData();
458
+ getXAxis();
459
+ drawLineChart();
460
+ }));
461
+ svg.on("wheel", (event) => {
462
+ event.preventDefault();
463
+ const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
464
+ ? event.deltaX
465
+ : event.deltaY;
466
+ scrollPosition += scrollDelta > 0 ? 1 : -1;
467
+ scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
468
+ const x = margin.left +
469
+ ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
470
+ handle.attr("x", x);
471
+ getXScale();
472
+ filteredData = JSON.parse(JSON.stringify(seriesData));
473
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
474
+ createStackLineData();
475
+ getXAxis();
476
+ drawLineChart();
477
+ });
478
+ }
479
+ drawLineChart();
480
+ };
481
+ const drawLineChart = () => {
482
+ // filteredData.forEach((data) => getChartType([data]));
483
+ getChartType(filteredData);
484
+ initXaxis(gTag, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, xAxisObj[0].dataType, innerWidth, innerHeight, filteredDimension);
485
+ stacklineAnnotations(stackChartData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
486
+ margin, d3Annotation, [], //this.labelExcludeList,
487
+ [], //this.individualLabelColor,
488
+ [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
489
+ formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg, dataTableHeight);
490
+ let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn, true).labelArray;
491
+ // adding series labels ( appending legends at the end of line : by default) in plot area
492
+ drawSeriesLabels(formatOptions, gTag, newSeriesLabelArray);
493
+ };
494
+ const createStackLineData = () => {
495
+ let stackLineData = getStackedData(filteredDimension, filteredData, isNormalizedChart);
496
+ // }
497
+ stackChartData = d3
498
+ .stack()
499
+ .keys(chartJSON.legendList)
500
+ .offset(d3.stackOffsetDiverging)(stackLineData);
501
+ filteredData.forEach((data, index) => data.data.forEach((axisData, position) => {
502
+ axisData["0"] = stackChartData[index][position][0];
503
+ axisData["1"] = stackChartData[index][position][1];
504
+ }));
505
+ //Appending Extra key for tooltip color
506
+ let seriesColor = formatOptions.annotation.annotationSetLabelColor;
507
+ stackChartData.forEach((K, j) => K.forEach((d) => {
508
+ d["key"] = K.key;
509
+ K["color"] = JSON.parse(JSON.stringify(seriesData[j].properties.color));
510
+ d.data.labelPosition = seriesData[j].properties.dataLabelPosition;
511
+ d.data["labelColor"] =
512
+ seriesColor == "2"
513
+ ? JSON.parse(JSON.stringify(seriesData[j].properties.color))
514
+ : seriesData[j].properties.labelColor;
515
+ d["hideZero"] = JSON.parse(JSON.stringify(seriesData[j].properties.hideZeroValues));
516
+ }));
517
+ };
518
+ 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%" } })] }));
519
+ };
520
+ export default NormalizedStackAreaChart;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type TLineChartProps } from "../ChartsWithAxisTypes.types";
3
+ declare const NormalisedStackLineChart: React.FC<TLineChartProps>;
4
+ export default NormalisedStackLineChart;