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