pace-chart-lib 0.0.7 → 0.0.9

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