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