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,486 @@
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, hideTooltipOnMouseOut, showTooltipOnMouseMove } from "../../Core/CommonFunctions";
8
+ import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, drawSeriesLabels, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, initYaxisRight, commonAnnotations, marginCalculation, prepareDataForSeriesLabel, responsiveSecondaryYaxisLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight } from "../ChartsWithAxisFunctions";
9
+ import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
10
+ import { legendShape } from "../../Core/Common.types";
11
+ const ColumnChart = ({ title, width, height, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
12
+ // adding variables as per requirement
13
+ let columnWidth = 0; // coz line chartO
14
+ const chartType = actualChartTypes.column;
15
+ const svgRef = useRef();
16
+ const seriesData = data;
17
+ const barChart = false;
18
+ let isSecondaryAxisDrawn = false;
19
+ const isNormalizedChart = 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 dataTable;
40
+ let dataTableHeight;
41
+ let svg;
42
+ let gTag;
43
+ let yScaleLeft;
44
+ let yScaleRight;
45
+ let xScale;
46
+ let xScaleForLegends;
47
+ let seriesLabels;
48
+ let calculatedRange;
49
+ let seriesLabelWidth;
50
+ let yAxisLeft;
51
+ let xAxis;
52
+ let yAxisRight;
53
+ let filteredDimension;
54
+ let filteredData;
55
+ let scrollPosition = 0;
56
+ const visibleBars = 2;
57
+ let chartJSON = {
58
+ dimensionList: [],
59
+ chartType: chartType,
60
+ chartData: [],
61
+ formatOptions: formatOptions,
62
+ legendList: [],
63
+ secondaryAxisDrawn: false,
64
+ yMaxLeft: 0,
65
+ yMaxRight: 0,
66
+ yMinLeft: 0,
67
+ yMinRight: 0,
68
+ hideZeroValues: false,
69
+ formattedDimensionListMap: new Map(),
70
+ };
71
+ //#region UseEffect
72
+ useEffect(() => {
73
+ try {
74
+ createColumnChart();
75
+ }
76
+ catch (error) {
77
+ logError("Columnchart", "createColumnChart", error);
78
+ }
79
+ }, [formatOptions]);
80
+ //#endregion
81
+ const createColumnChart = () => {
82
+ ({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
83
+ preProcessChartData(); // preaparing data related to chart creation
84
+ // Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
85
+ ({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } = customYscaleLabelFormatting(
86
+ // for calculating primary/secondary axis max number so that we can calculate margin accordinglt
87
+ formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
88
+ ({
89
+ margin,
90
+ yLabel,
91
+ xLabel,
92
+ yTitle,
93
+ xTitle,
94
+ dimensionHeightWidthArray,
95
+ chartTitleHeight,
96
+ secondaryAxisTitleWidth,
97
+ legendMargin,
98
+ secondaryYLabel,
99
+ } = marginCalculation(
100
+ // for all margin related calculations
101
+ width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart));
102
+ setSVGContainer(margin); // for innerWidth/height static width/height
103
+ ({ dataTable, dataTableHeight } = dataTablePreCalculation(
104
+ // calculations for data tables
105
+ formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
106
+ initSvg(
107
+ // for svg creation
108
+ svg, width, height, formatOptions);
109
+ gTag = initChartArea(svg, margin); // creating chart area
110
+ initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
111
+ initScale();
112
+ initAxis();
113
+ initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
114
+ initYaxisRight(gTag, formatOptions, dataTableHeight, secondaryYLabel, yAxisRight, innerHeight, innerWidth);
115
+ horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
116
+ if (formatOptions.dataTableProperties &&
117
+ formatOptions.dataTableProperties.dataTable) {
118
+ if (formatOptions.xAxisLabel.xAxisPosition != "1")
119
+ formatOptions.xAxisLabel.xAxisLabelVisibility = false;
120
+ addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, columnWidth, yScaleLeft, xScale, xScaleForLegends, undefined, undefined, dataTableHeight, chartType, formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
121
+ }
122
+ setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
123
+ yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
124
+ yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
125
+ setChartTitle(svg, formatOptions, width, chartTitleHeight);
126
+ drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, legendShape.rectangle);
127
+ };
128
+ const preProcessChartData = () => {
129
+ const allChartData = [];
130
+ const legendList = [];
131
+ const dimensionSet = new Set();
132
+ let formatedDimesionList = [];
133
+ let yMaxLeft = -Infinity;
134
+ let yMinLeft = Infinity;
135
+ let yMaxRight = -Infinity;
136
+ let yMinRight = Infinity;
137
+ seriesData.forEach((series) => {
138
+ legendList.push(series.legend);
139
+ series.data.forEach((point) => {
140
+ allChartData.push(point);
141
+ dimensionSet.add(point.dimension);
142
+ if (series.properties.axis === "Secondary") {
143
+ isSecondaryAxisDrawn = true;
144
+ yMaxRight = Math.max(yMaxRight, point.value);
145
+ yMinRight = Math.min(yMinRight, point.value);
146
+ }
147
+ else {
148
+ yMaxLeft = Math.max(yMaxLeft, point.value);
149
+ yMinLeft = Math.min(yMinLeft, point.value);
150
+ }
151
+ });
152
+ });
153
+ chartJSON.chartData = allChartData;
154
+ chartJSON.legendList = legendList;
155
+ chartJSON.dimensionList = Array.from(dimensionSet);
156
+ chartJSON.yMaxLeft = yMaxLeft;
157
+ chartJSON.yMinLeft = yMinLeft;
158
+ chartJSON.yMaxRight = yMaxRight;
159
+ chartJSON.yMinRight = yMinRight;
160
+ // Apply formatted dimensions
161
+ let xAxisObject = xAxisObj[0];
162
+ formatedDimesionList =
163
+ (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
164
+ xAxisObject.dataType === "DATE"
165
+ ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d[0])
166
+ : chartJSON.dimensionList;
167
+ chartJSON.dimensionList.forEach((dim, i) => {
168
+ chartJSON.formattedDimensionListMap.set(dim, formatedDimesionList[i]);
169
+ });
170
+ filteredData = JSON.parse(JSON.stringify(seriesData));
171
+ if (!formatOptions.plotArea.fitChart) {
172
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
173
+ }
174
+ else {
175
+ filteredDimension = chartJSON.dimensionList;
176
+ }
177
+ if (formatOptions.plotArea.hideZeroValues) {
178
+ chartJSON.hideZeroValues = true;
179
+ }
180
+ };
181
+ const initScale = () => {
182
+ // rounding the ymin & ymax
183
+ let yAxisLabelArray = responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray;
184
+ chartJSON.yMaxLeft = yAxisLabelArray[yAxisLabelArray.length - 1];
185
+ chartJSON.yMinLeft = yAxisLabelArray[0];
186
+ if (isPrimaryAxisDrawn) {
187
+ yScaleLeft = d3
188
+ .scaleLinear()
189
+ .domain([
190
+ customYaxisMinValue !== undefined &&
191
+ !Number.isNaN(customYaxisMinValue)
192
+ ? customYaxisMinValue
193
+ : chartJSON.yMinLeft < 0
194
+ ? chartJSON.yMinLeft * 1.1
195
+ : chartJSON.yMinLeft * 0.9,
196
+ chartJSON.yMaxLeft <= 0
197
+ ? 0
198
+ : customYaxisMaxValue !== undefined &&
199
+ !Number.isNaN(customYaxisMaxValue)
200
+ ? customYaxisMaxValue
201
+ : chartJSON.yMaxLeft * 1.1,
202
+ ])
203
+ .range([
204
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
205
+ 0,
206
+ ]);
207
+ }
208
+ if (isSecondaryAxisDrawn) {
209
+ yScaleRight = d3
210
+ .scaleLinear()
211
+ .domain([
212
+ chartJSON.yMinRight >= 0
213
+ ? (secondaryCustomYaxisMinValue ||
214
+ secondaryCustomYaxisMinValue == 0) &&
215
+ !Number.isNaN(secondaryCustomYaxisMinValue)
216
+ ? secondaryCustomYaxisMinValue
217
+ : 0
218
+ : (secondaryCustomYaxisMinValue ||
219
+ secondaryCustomYaxisMinValue == 0) &&
220
+ !Number.isNaN(secondaryCustomYaxisMinValue)
221
+ ? secondaryCustomYaxisMinValue
222
+ : chartJSON.yMinRight * 1.1,
223
+ chartJSON.yMaxRight <= 0
224
+ ? secondaryCustomYaxisMaxValue
225
+ ? secondaryCustomYaxisMaxValue
226
+ : 0
227
+ : secondaryCustomYaxisMaxValue
228
+ ? secondaryCustomYaxisMaxValue
229
+ : chartJSON.yMaxRight * 1.1,
230
+ ])
231
+ .range([
232
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
233
+ 0,
234
+ ]);
235
+ }
236
+ calculatedRange = [0, innerWidth];
237
+ if (formatOptions.seriesLabel.seriesLabelVisibility) {
238
+ let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn);
239
+ seriesLabels = labelObj.labelArray;
240
+ formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
241
+ (seriesLabelWidth = labelObj.heightWidth[0]);
242
+ formatOptions.seriesLabel.seriesLabelPosition == "Right"
243
+ ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
244
+ : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
245
+ }
246
+ getXScale();
247
+ };
248
+ const getXScale = () => {
249
+ columnWidth =
250
+ (0.51 + (0.61 * (100 - parseFloat(formatOptions.plotArea.plotAreaGapWidth))) / 100) *
251
+ (innerWidth / filteredDimension.length);
252
+ xScaleForLegends = d3.scaleBand()
253
+ // .domain(barLegendList.map((d) => d.legend))
254
+ .domain(chartJSON.legendList)
255
+ .range([0, columnWidth])
256
+ .paddingInner(chartJSON.legendList.length > 1
257
+ ? (0.3 * parseFloat(formatOptions.plotArea.plotAreaSeriesWidth)) / 100
258
+ : 0);
259
+ xScale = d3
260
+ .scalePoint()
261
+ .domain(filteredDimension)
262
+ .range(calculatedRange)
263
+ .padding(0.5);
264
+ };
265
+ const initAxis = () => {
266
+ getXAxis();
267
+ if (isPrimaryAxisDrawn) {
268
+ yAxisLeft = d3
269
+ .axisLeft(yScaleLeft)
270
+ .tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
271
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
272
+ ? formatOptions.plotArea.gridLinesHorizontal
273
+ ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
274
+ : 0
275
+ : 0)
276
+ .tickValues(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray)
277
+ .ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).customTickValue ??
278
+ (dataTableHeight > 0
279
+ ? (innerHeight - dataTableHeight) / 30
280
+ : innerHeight / 30))
281
+ .tickSizeOuter(0);
282
+ }
283
+ if (isSecondaryAxisDrawn) {
284
+ yAxisRight = d3
285
+ .axisRight(yScaleRight)
286
+ .tickFormat((d) => getNumberWithFormat(d, formatOptions.secondaryYAxisLabel.secondaryYAxisDisplayUnits, formatOptions.secondaryYAxisLabel.secondaryYAxisNumberFormat, formatOptions.secondaryYAxisLabel
287
+ .secondaryYAxisLabelDecimalPrecision))
288
+ .tickValues(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
289
+ ? secondaryCustomYaxisMaxValue
290
+ : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryYAxisLabelArray)
291
+ .ticks(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
292
+ ? secondaryCustomYaxisMaxValue
293
+ : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryCustomTickValue ?? innerHeight / 30)
294
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
295
+ ? formatOptions.plotArea.gridLinesHorizontal
296
+ ? -innerWidth
297
+ : 0
298
+ : 0)
299
+ .tickSizeOuter(0);
300
+ }
301
+ };
302
+ const getXAxis = () => {
303
+ xAxis = d3
304
+ .axisBottom(xScale)
305
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
306
+ ? formatOptions.plotArea.gridLinesVeritcal
307
+ ? formatOptions.plotArea.gridLinesVeritcal
308
+ ? -(dataTableHeight > 0
309
+ ? innerHeight - dataTableHeight
310
+ : innerHeight)
311
+ : parseFloat(formatOptions.plotArea.ticksHeight) *
312
+ ((dataTableHeight > 0
313
+ ? innerHeight - dataTableHeight
314
+ : innerHeight) /
315
+ 100) *
316
+ (formatOptions.xAxisLabel.xAxisPosition == "1" ? 1 : -1)
317
+ : 0
318
+ : 0)
319
+ .tickSizeOuter(0)
320
+ .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
321
+ };
322
+ const getChartType = (lineData) => {
323
+ lineData.forEach((lData) => {
324
+ lData.data.forEach((cData) => {
325
+ cData.hideZero = lData.properties.hideZeroValues;
326
+ cData.axis = lData.properties.axis;
327
+ });
328
+ });
329
+ // Bind dummy data to ensure a single group is created
330
+ lineData.forEach((data) => {
331
+ // Step 1: Outer group for the whole chart
332
+ let column = gTag.selectAll(".parentGroup")
333
+ .data([data], d => d.legend); // use key so exit works
334
+ column = column
335
+ .enter()
336
+ .append("g")
337
+ .attr("class", `column parentGroup`)
338
+ .merge(column);
339
+ // Step 2: JOIN each data point inside the series
340
+ let columnGroups = column
341
+ .selectAll(".column-group")
342
+ .data(data.data, d => d.legend + d.dimension); // key on dimension + legend
343
+ // Step 3: ENTER - one group per bar (optional if you need transform)
344
+ let columnGroupsEnter = columnGroups
345
+ .enter()
346
+ .append("g")
347
+ .attr("class", "column-group")
348
+ .attr("hoverId", (d) => (d.legend.includes("-") ? d.legend.replace("-", "`").split("`")[1].replace(/ /g, "-") : d.legend.replace(/ /g, "-")))
349
+ .attr("transform", d => `translate(${xScale(d.dimension) - columnWidth / 2}, 0)`);
350
+ // ✨ Add this to handle UPDATE:
351
+ columnGroups
352
+ .attr("transform", d => `translate(${xScale(d.dimension) - columnWidth / 2}, 0)`);
353
+ // Merge ENTER + UPDATE
354
+ columnGroupsEnter.merge(columnGroups)
355
+ .attr("transform", d => `translate(${xScale(d.dimension) - columnWidth / 2}, 0)`);
356
+ // Step 4: Draw the rects
357
+ columnGroupsEnter
358
+ .append("rect")
359
+ .attr("x", (d) => xScaleForLegends(d.legend))
360
+ .attr("width", xScaleForLegends.bandwidth())
361
+ .attr("y", (d) => {
362
+ const yScale = data.properties.axis === "Primary" ? yScaleLeft : yScaleRight;
363
+ return d.value > 0 ? yScale(d.value) : yScale(0);
364
+ })
365
+ .attr("height", (d) => {
366
+ const yScale = data.properties.axis === "Primary" ? yScaleLeft : yScaleRight;
367
+ return Math.abs(yScale(d.value) - yScale(0));
368
+ })
369
+ .attr("fill", data.properties.color)
370
+ .attr("stroke-dasharray", (d) => d.stackBorderStyle === 2 ? "5,3" : "0")
371
+ .attr("stroke-width", (d) => `${d.stackBorderWidth}px`)
372
+ .attr("stroke", (d) => data.properties.stackBorderStyle === 0
373
+ ? "none"
374
+ : formatOptions.column.stackBorderVisibility
375
+ ? data.properties.stackBorderStyle
376
+ : "none")
377
+ .style("clip-path", "inset(0px) fill-box")
378
+ .style("shape-rendering", "crispEdges")
379
+ .attr("visibility", (d) => d.value === 0 && formatOptions.xAxisLabel.hideZeroValues
380
+ ? "hidden"
381
+ : "visible")
382
+ .on("mousemove", (event, d) => {
383
+ showTooltipOnMouseMove([
384
+ {
385
+ key: formatOptions.xAxisTitle.xAxisTitleText.includes("~$~")
386
+ ? formatOptions.xAxisTitle.xAxisTitleText.split("~$~")[1]
387
+ : formatOptions.xAxisTitle.xAxisTitleText,
388
+ value: chartJSON.formattedDimensionListMap.get(Array.isArray(d.dimension) ? d.dimension[0] : d.dimension),
389
+ },
390
+ {
391
+ key: formatOptions.yAxisTitle.yAxisTitleText || d.value,
392
+ value: getNumberWithFormat([actualChartTypes.stackLine100, actualChartTypes.stackArea100, ""].includes(chartType)
393
+ ? d[1] - d[0]
394
+ : d.value, formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision),
395
+ },
396
+ {
397
+ key: "Legend",
398
+ value: d.legend.includes("~$~") ? d.legend.split("~$~")[1] : d.legend,
399
+ },
400
+ ], formatOptions, event);
401
+ })
402
+ .on("mouseout", hideTooltipOnMouseOut);
403
+ // Step 5: EXIT - remove old bars
404
+ columnGroups.exit().remove().each(function (d) {
405
+ console.log("Exiting:", d.dimension, d.legend);
406
+ });
407
+ });
408
+ };
409
+ const setSVGContainer = (margin) => {
410
+ innerWidth = width - margin.left - margin.right;
411
+ innerHeight = height - margin.bottom - margin.top;
412
+ };
413
+ const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
414
+ if (!formatOptions.plotArea.fitChart) {
415
+ // Scrollbar parameters
416
+ const scrollMax = seriesData[0].data.length - visibleBars;
417
+ // Scrollbar track & handle
418
+ const scrollbarY = height - 20;
419
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
420
+ getXScale();
421
+ filteredData = JSON.parse(JSON.stringify(seriesData));
422
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
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) / seriesData.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
+ getXAxis();
451
+ drawColumnChart();
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
+ getXAxis();
467
+ drawColumnChart();
468
+ });
469
+ }
470
+ drawColumnChart();
471
+ };
472
+ const drawColumnChart = () => {
473
+ getChartType(filteredData);
474
+ initXaxis(gTag, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, xAxisObj[0].dataType, innerWidth, innerHeight, filteredDimension);
475
+ commonAnnotations(seriesData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
476
+ margin, d3Annotation, [], //this.labelExcludeList,
477
+ [], //this.individualLabelColor,
478
+ [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
479
+ formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg, xScaleForLegends, columnWidth);
480
+ let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn).labelArray;
481
+ // adding series labels ( appending legends at the end of line : by default) in plot area
482
+ drawSeriesLabels(formatOptions, gTag, newSeriesLabelArray);
483
+ };
484
+ return (_jsxs("div", { children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, width: width, height: height })] }));
485
+ };
486
+ export default ColumnChart;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type TChartProps } from "../ChartsWithAxisTypes.types";
3
+ declare const ColumnChart: React.FC<TChartProps>;
4
+ export default ColumnChart;