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,513 @@
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 { drawLegends, generalizedChartData, lineMarkers } from "../../Core/CommonFunctions";
8
+ import { addDataTable, dataTablePreCalculation, drawSeriesLabels, firstFunctionBeforeRender, getCurveType, getStackedData, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, setChartTitle, setDateFormats, setXaxistitle, stacklineAnnotations, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
9
+ import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
10
+ import { staticLegendShape } from "../../Core/Common.types";
11
+ const NormalisedStackLineChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
12
+ // adding variables as per requirement
13
+ const barWidth = 0; // coz line chart
14
+ const chartType = actualChartTypes.stackLine100;
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", "createNormalizedLinechart", 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, "Line", 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.line);
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
+ // for future reference
249
+ // if (isSecondaryAxisDrawn) {
250
+ // yScaleRight = d3
251
+ // .scaleLinear()
252
+ // .domain([
253
+ // chartJSON.yMinRight >= 0
254
+ // ? (secondaryCustomYaxisMinValue ||
255
+ // secondaryCustomYaxisMinValue == 0) &&
256
+ // !Number.isNaN(secondaryCustomYaxisMinValue)
257
+ // ? secondaryCustomYaxisMinValue
258
+ // : 0
259
+ // : (secondaryCustomYaxisMinValue ||
260
+ // secondaryCustomYaxisMinValue == 0) &&
261
+ // !Number.isNaN(secondaryCustomYaxisMinValue)
262
+ // ? secondaryCustomYaxisMinValue
263
+ // : chartJSON.yMinRight * 1.1,
264
+ // chartJSON.yMaxRight <= 0
265
+ // ? secondaryCustomYaxisMaxValue
266
+ // ? secondaryCustomYaxisMaxValue
267
+ // : 0
268
+ // : secondaryCustomYaxisMaxValue
269
+ // ? secondaryCustomYaxisMaxValue
270
+ // : chartJSON.yMaxRight * 1.1,
271
+ // ])
272
+ // .range([
273
+ // dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
274
+ // 0,
275
+ // ]);
276
+ // }
277
+ calculatedRange = [0, innerWidth];
278
+ if (formatOptions.seriesLabel.seriesLabelVisibility) {
279
+ let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn, true);
280
+ seriesLabels = labelObj.labelArray;
281
+ formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
282
+ (seriesLabelWidth = labelObj.heightWidth[0]);
283
+ formatOptions.seriesLabel.seriesLabelPosition == "Right"
284
+ ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
285
+ : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
286
+ }
287
+ getXScale();
288
+ };
289
+ const getXScale = () => {
290
+ xScale = d3
291
+ .scalePoint()
292
+ .domain(filteredDimension)
293
+ .range(calculatedRange)
294
+ .padding(0.5);
295
+ };
296
+ const initAxis = () => {
297
+ getXAxis();
298
+ if (isPrimaryAxisDrawn) {
299
+ yAxisLeft = d3
300
+ .axisLeft(yScaleLeft)
301
+ // .tickFormat((d: number) => //tick format will be always % line 544 with 0 precision
302
+ // getNumberWithFormat(
303
+ // d,
304
+ // formatOptions.yAxisLabel.yAxisDisplayUnits,
305
+ // formatOptions.yAxisLabel.yAxisNumberFormat,
306
+ // formatOptions.yAxisLabel.yAxisLabelDecimalPrecision
307
+ // )
308
+ // )
309
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
310
+ ? formatOptions.plotArea.gridLinesHorizontal
311
+ ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
312
+ : 0
313
+ : 0)
314
+ .ticks(dataTableHeight > 0
315
+ ? (innerHeight - dataTableHeight) / 30
316
+ : innerHeight / 30, "%")
317
+ .tickSizeOuter(0);
318
+ }
319
+ };
320
+ const getXAxis = () => {
321
+ xAxis = d3
322
+ .axisBottom(xScale)
323
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
324
+ ? formatOptions.plotArea.gridLinesVertical
325
+ ? formatOptions.plotArea.gridLinesVertical
326
+ ? -(dataTableHeight > 0
327
+ ? innerHeight - dataTableHeight
328
+ : innerHeight)
329
+ : parseFloat(formatOptions.plotArea.ticksHeight) *
330
+ ((dataTableHeight > 0
331
+ ? innerHeight - dataTableHeight
332
+ : innerHeight) /
333
+ 100) *
334
+ (formatOptions.xAxisLabel.xAxisPosition == "1" ? 1 : -1)
335
+ : 0
336
+ : 0)
337
+ .tickSizeOuter(0)
338
+ .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
339
+ };
340
+ const getChartType = (lineData) => {
341
+ // to convert data value to percentage
342
+ stackChartData.forEach((data, i) => data.forEach((item, position) => {
343
+ if (lineData[i] && lineData[i].data[position]) {
344
+ lineData[i].data[position][0] = item[0] =
345
+ item.data.total === 0 ? 0 : item[0] / item.data.total;
346
+ lineData[i].data[position][1] = item[1] =
347
+ item.data.total === 0 ? 0 : item[1] / item.data.total;
348
+ }
349
+ }));
350
+ lineData.forEach((lData) => {
351
+ lData.data.forEach((cData) => {
352
+ cData.hideZero = lData.properties.hideZeroValues;
353
+ cData.axis = lData.properties.axis;
354
+ });
355
+ });
356
+ const lineGenerator = d3
357
+ .line()
358
+ .x((d) => xScale(d.data.dimension)
359
+ ? xScale(d.data.dimension)
360
+ : null)
361
+ .y((d) => (d[1] > 0 ? yScaleLeft(d[1]) : yScaleLeft(d[0])))
362
+ // .defined((d) => (d.hideZero ? Boolean(d.value) : true))
363
+ .curve(getCurveType(formatOptions));
364
+ //Lines
365
+ // Bind dummy data to ensure a single group is created
366
+ let lines = gTag.selectAll(".parentGroup").data([stackChartData.reverse()]);
367
+ lines = lines
368
+ .enter()
369
+ .append("g")
370
+ .attr("class", "lines parentGroup")
371
+ .merge(lines);
372
+ // JOIN: one group per line
373
+ let lineGroups = lines.selectAll(".line-group").data((d) => d);
374
+ // ENTER: create group for each new line
375
+ let lineGroupsEnter = lineGroups
376
+ .enter()
377
+ .append("g")
378
+ .attr("class", (d) => "line-group " + d.key.replace(/ /g, "-"));
379
+ // .attr("class", (d) => d.key.replace(/ /g, "-"));
380
+ lineGroupsEnter
381
+ .attr("hoverId", (d) => d.key.includes("~$~")
382
+ ? d.key.split("~$~")[1].replace(/ /g, "-")
383
+ : d.key.replace(/ /g, "-"))
384
+ .append("path")
385
+ .attr("class", "line")
386
+ .attr("fill", "none");
387
+ // ENTER + UPDATE
388
+ lineGroupsEnter
389
+ .merge(lineGroups)
390
+ .select("path")
391
+ .attr("d", (d, i) => lineGenerator(d))
392
+ .attr("stroke", (d) => (d.color !== "#ffffff" ? d.color : "none"))
393
+ // .style("visibility", (d,i) => (this.individualLegendStyle[i].hideZero && d[i].data[d.key] === 0) ? "hidden" : "visible")
394
+ .attr("stroke-dasharray", (d, i) => seriesData[i].properties.lineStyle === "dotted"
395
+ ? "0,3"
396
+ : seriesData[i].properties.lineStyle === "dashed"
397
+ ? "20,10,5,5,5,10"
398
+ : "")
399
+ .attr("stroke-linecap", (d, i) => seriesData[i].properties.lineStyle === "dotted" ? "round" : "")
400
+ .attr("stroke-width", (d, i) => seriesData[i].properties.lineStyle !== "None"
401
+ ? seriesData[i].properties.lineWidth
402
+ : "0");
403
+ // EXIT: remove old groups
404
+ lineGroups.exit().remove();
405
+ //Markers
406
+ lineMarkers(lines, lineData, chartType, xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue, true);
407
+ };
408
+ const setSVGContainer = (margin) => {
409
+ innerWidth = width - margin.left - margin.right;
410
+ innerHeight = height - margin.bottom - margin.top;
411
+ };
412
+ const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
413
+ if (!formatOptions.plotArea.fitChart) {
414
+ // Scrollbar parameters
415
+ const scrollMax = seriesData[0].data.length - visibleBars;
416
+ // Scrollbar track & handle
417
+ const scrollbarY = height - 20;
418
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
419
+ getXScale();
420
+ filteredData = JSON.parse(JSON.stringify(seriesData));
421
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
422
+ createStackLineData();
423
+ getXAxis();
424
+ svg
425
+ .append("rect")
426
+ .attr("x", margin.left)
427
+ .attr("y", scrollbarY)
428
+ .attr("width", innerWidth)
429
+ .attr("height", 8)
430
+ .attr("fill", "#ddd")
431
+ .attr("rx", 4);
432
+ const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
433
+ const handle = svg
434
+ .append("rect")
435
+ .attr("x", margin.left)
436
+ .attr("y", scrollbarY)
437
+ .attr("width", handleWidth)
438
+ .attr("height", 8)
439
+ .attr("fill", "#999")
440
+ .attr("rx", 4)
441
+ .style("cursor", "ew-resize")
442
+ .call(d3.drag().on("drag", (event) => {
443
+ let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
444
+ handle.attr("x", x);
445
+ scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
446
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
447
+ getXScale();
448
+ filteredData = JSON.parse(JSON.stringify(seriesData));
449
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
450
+ createStackLineData();
451
+ getXAxis();
452
+ drawLineChart();
453
+ }));
454
+ svg.on("wheel", (event) => {
455
+ event.preventDefault();
456
+ const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
457
+ ? event.deltaX
458
+ : event.deltaY;
459
+ scrollPosition += scrollDelta > 0 ? 1 : -1;
460
+ scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
461
+ const x = margin.left +
462
+ ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
463
+ handle.attr("x", x);
464
+ getXScale();
465
+ filteredData = JSON.parse(JSON.stringify(seriesData));
466
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
467
+ createStackLineData();
468
+ getXAxis();
469
+ drawLineChart();
470
+ });
471
+ }
472
+ drawLineChart();
473
+ };
474
+ const drawLineChart = () => {
475
+ // filteredData.forEach((data) => getChartType([data]));
476
+ getChartType(filteredData);
477
+ initXaxis(gTag, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, xAxisObj[0].dataType, innerWidth, innerHeight, filteredDimension);
478
+ stacklineAnnotations(stackChartData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
479
+ margin, d3Annotation, [], //this.labelExcludeList,
480
+ [], //this.individualLabelColor,
481
+ [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
482
+ formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg, dataTableHeight);
483
+ let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn, true).labelArray;
484
+ // adding series labels ( appending legends at the end of line : by default) in plot area
485
+ drawSeriesLabels(formatOptions, gTag, newSeriesLabelArray);
486
+ };
487
+ const createStackLineData = () => {
488
+ let stackLineData = getStackedData(filteredDimension, filteredData, isNormalizedChart);
489
+ // }
490
+ stackChartData = d3
491
+ .stack()
492
+ .keys(chartJSON.legendList)
493
+ .offset(d3.stackOffsetDiverging)(stackLineData);
494
+ filteredData.forEach((data, index) => data.data.forEach((axisData, position) => {
495
+ axisData["0"] = stackChartData[index][position][0];
496
+ axisData["1"] = stackChartData[index][position][1];
497
+ }));
498
+ //Appending Extra key for tooltip color
499
+ let seriesColor = formatOptions.annotation.annotationSetLabelColor;
500
+ stackChartData.forEach((K, j) => K.forEach((d) => {
501
+ d["key"] = K.key;
502
+ K["color"] = JSON.parse(JSON.stringify(seriesData[j].properties.color));
503
+ d.data.labelPosition = seriesData[j].properties.dataLabelPosition;
504
+ d.data["labelColor"] =
505
+ seriesColor == "2"
506
+ ? JSON.parse(JSON.stringify(seriesData[j].properties.color))
507
+ : seriesData[j].properties.labelColor;
508
+ d["hideZero"] = JSON.parse(JSON.stringify(seriesData[j].properties.hideZeroValues));
509
+ }));
510
+ };
511
+ 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%" } })] }));
512
+ };
513
+ export default NormalisedStackLineChart;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type TChartProps } from "../ChartsWithAxisTypes.types";
3
+ declare const StackLineChart: React.FC<TChartProps>;
4
+ export default StackLineChart;