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