pace-chart-lib 1.0.2 → 1.0.4

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