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,507 +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 { useEffect, useRef } from "react";
5
- import { fontStyleOptions, } from "../../Core/Common.types";
6
- import { convertStringToNumber, drawChartTitle, findStringWithLongestLength, firstFunctionBeforeRender, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initLegendListWithTotalValueAllowance, initSvg, marginCalculationsForChartsWithoutAxis, preCalculateTextDimensions, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
7
- import { chartMargins, } from "../../Core/DefaultProperties.types";
8
- import { drawTotalValue } from "./PieFamilyCommonFunctions";
9
- import { logError } from "../../../../Services/ErrorLog";
10
- //#endregion
11
- const fileName = "PieofPieChart.tsx";
12
- const PieofPie = ({ data, formatOptions, chartId, legendProperties, }) => {
13
- // #region variables
14
- const svgRef = useRef(); // Reference to the SVG element
15
- let chartFormatOptions; // Chart format options with defaults
16
- let width; // svg total width
17
- let height; // svg total height
18
- let chartTitleHeight = 40; // Height of the chart title
19
- let margins = chartMargins; // Margins for the chart
20
- let innerHeight; // Height of the chart excluding margins
21
- let innerWidth; // Width of the chart excluding margins
22
- let chartAreaTagG; // Main chart area group
23
- let svg; // Main SVG element
24
- let pieOfPieData;
25
- let radius; // Radius of the parent pie chart
26
- let childRadius; // Radius of the parent pie chart
27
- let parentPieTotalValue; // Total value of the parent pie chart
28
- let expandedArcName = undefined; // Name of the expanded arc, if any
29
- let parentPieX; // X position of the parent pie chart
30
- let parentPieY; // Y position of the parent pie chart
31
- let childPieX; // X position of the child pie chart
32
- let childPieY; // Y position of the child pie chart
33
- let maxLegendDimensions = [0, 0]; // to calculate margins [width, height]
34
- let legendListWidth; // to calculate margins [width, height]
35
- let plotArea; // Default plot area options
36
- // #endregion
37
- // #region useEffect
38
- useEffect(() => {
39
- drawChart();
40
- }, [formatOptions]);
41
- // #endregion
42
- const drawChart = () => {
43
- ({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
44
- ({ plotArea } = chartFormatOptions);
45
- calculateMaxPossibleWidth();
46
- ({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } =
47
- marginCalculationsForChartsWithoutAxis(chartFormatOptions, width, height, maxLegendDimensions, margins));
48
- calculatePieRadius();
49
- initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
50
- chartAreaTagG = initChartArea(svg, margins);
51
- drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
52
- initChartData();
53
- drawPieChart();
54
- drawParentPieDataLabels();
55
- drawTotalValue(chartFormatOptions, parentPieTotalValue, chartTitleHeight, svg, width, height);
56
- initLegendList();
57
- };
58
- const calculateMaxPossibleWidth = () => {
59
- try {
60
- let legendDims = preCalculateTextDimensions(findStringWithLongestLength(legendProperties, "name"), convertStringToNumber(chartFormatOptions.legends.legendFontSize), chartFormatOptions.legends.legendFontFamily);
61
- maxLegendDimensions = [legendDims.width, legendDims.height];
62
- }
63
- catch (error) {
64
- logError(fileName, "calculateMaxPossibleWidth", error);
65
- }
66
- };
67
- const calculatePieRadius = () => {
68
- try {
69
- radius = Math.min(innerHeight * 0.4, innerWidth * 0.4);
70
- childRadius = chartFormatOptions.pieofPie.pieOfPieRadius;
71
- }
72
- catch (error) {
73
- logError(fileName, "calculatePieRadius", error);
74
- }
75
- };
76
- const initChartData = () => {
77
- try {
78
- let legendMap = new Map();
79
- legendProperties.forEach((legend) => {
80
- legendMap.set(legend.name, legend);
81
- });
82
- parentPieTotalValue = 0;
83
- data.forEach((dataParentObj) => {
84
- dataParentObj["properties"] = legendMap.get(dataParentObj.legend);
85
- parentPieTotalValue += dataParentObj.data[0].value;
86
- if (dataParentObj.children) {
87
- dataParentObj.children.forEach((child) => (child["properties"] = legendMap.get(child.legend)));
88
- }
89
- });
90
- const pie = d3.pie().value((d) => d.data[0].value);
91
- let pieData = pie(data);
92
- pieOfPieData = pieData.map((d, i) => ({
93
- ...d,
94
- x0: d.startAngle,
95
- x1: d.endAngle,
96
- y0: 0,
97
- y1: radius,
98
- depth: 2, // Set depth to 2 to simulate hierarchical level for consistent arc rendering (e.g., in sunburst or partition layouts)
99
- }));
100
- }
101
- catch (error) {
102
- logError(fileName, "initChartData", error);
103
- }
104
- };
105
- const drawPieChart = () => {
106
- try {
107
- const arc = d3
108
- .arc()
109
- .innerRadius(0)
110
- .outerRadius(radius);
111
- const arcOver = d3
112
- .arc()
113
- .innerRadius(0)
114
- .outerRadius(radius + 10);
115
- chartAreaTagG
116
- .append("g")
117
- .attr("class", "parentGroup")
118
- .attr("fill-opacity", chartFormatOptions.plotArea.opacity)
119
- .attr("transform", `${getParentPiePosition()}`)
120
- .selectAll("path")
121
- .data(pieOfPieData)
122
- .enter()
123
- .append("path")
124
- .attr("class", (d) => "path " + d.data.legend)
125
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
126
- .attr("fill", (d) => d.data.properties.color !== "#ffffff"
127
- ? d.data.properties.color
128
- : "none")
129
- .attr("d", (d) => arc(d))
130
- .on("mouseover.arc", function (d) {
131
- d3.select(this).transition().duration(100).attr("d", arcOver);
132
- })
133
- .on("mousemove.text", (d) => {
134
- showTooltipOnMouseMove([
135
- {
136
- key: chartFormatOptions.yAxisTitle.yAxisTitleText,
137
- value: chartFormatOptions.toolTip.toolTipNumberFormat == ",.0%"
138
- ? (Math.abs(d.currentTarget.__data__.data.data[0].value /
139
- parentPieTotalValue) * 100).toFixed(convertStringToNumber(chartFormatOptions.toolTip.toolTipDecimalPrecision) ?? 0) + "%"
140
- : getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.currentTarget.__data__.data.data[0].value),
141
- },
142
- { key: "Legend", value: d.currentTarget.__data__.data.legend },
143
- ], chartFormatOptions);
144
- })
145
- .on("mouseout.text", () => {
146
- hideTooltipOnMouseOut();
147
- })
148
- .on("mouseout.arc", function (d) {
149
- d3.select(this).transition().duration(100).attr("d", arc);
150
- hideTooltipOnMouseOut();
151
- })
152
- .on("click", (event, data) => {
153
- try {
154
- let currentArcData = data;
155
- if (currentArcData.data.children &&
156
- currentArcData.data.children.length > 1) {
157
- chartAreaTagG.selectAll(".childGroup").remove();
158
- chartAreaTagG.selectAll(".childLabels").remove();
159
- chartAreaTagG.selectAll("line").remove();
160
- expandedArcName = currentArcData.data.legend;
161
- let rotate = 90 - ((data.x0 + data.x1) / 2 / Math.PI) * 180;
162
- drawChildPie(currentArcData.data.children, rotate, data);
163
- }
164
- }
165
- catch (error) {
166
- logError(fileName, "drawPieChart_onClick", error);
167
- }
168
- });
169
- }
170
- catch (error) {
171
- logError(fileName, "drawPieChart", error);
172
- }
173
- };
174
- const drawChildPie = (childData, rotate, parentArc) => {
175
- try {
176
- // Code to rotate parent pie
177
- chartAreaTagG
178
- .select(".parentGroup")
179
- .transition()
180
- .attr("transform", `${getParentPiePosition()} rotate(${rotate})`)
181
- .duration(1000);
182
- chartAreaTagG
183
- .selectAll(".parentLabels")
184
- .transition()
185
- .attr("transform", `${getParentPiePosition()} rotate(${rotate})`)
186
- .duration(1000);
187
- //end
188
- const childPie = d3.pie().value((d) => d.data[0].value);
189
- let childPieData = childPie(childData).map((d, i) => ({
190
- ...d,
191
- x0: d.startAngle,
192
- x1: d.endAngle,
193
- y0: 0,
194
- y1: childRadius,
195
- depth: 2, // Set depth to 2 to simulate hierarchical level for consistent arc rendering (e.g., in sunburst or partition layouts)
196
- }));
197
- const arc = d3
198
- .arc()
199
- .innerRadius(0)
200
- .outerRadius(childRadius);
201
- const arcOver = d3
202
- .arc()
203
- .innerRadius(0)
204
- .outerRadius(childRadius + 10);
205
- chartAreaTagG
206
- .append("g")
207
- .attr("class", "childGroup")
208
- .attr("fill-opacity", chartFormatOptions.plotArea.opacity)
209
- .attr("transform", `${getChildPiePosition()}`)
210
- .selectAll("path")
211
- .data(childPieData)
212
- .enter()
213
- .append("path")
214
- .attr("class", (d) => "path " + d.data.legend)
215
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
216
- .attr("fill", (d) => d.data.properties.color !== "#ffffff"
217
- ? d.data.properties.color
218
- : "none")
219
- .attr("d", (d) => arc(d))
220
- .on("mouseover.arc", function (d) {
221
- d3.select(this).transition().duration(100).attr("d", arcOver);
222
- })
223
- .on("mousemove.text", (d) => {
224
- showTooltipOnMouseMove([
225
- {
226
- key: chartFormatOptions.yAxisTitle.yAxisTitleText,
227
- value: chartFormatOptions.toolTip.toolTipNumberFormat == ",.0%"
228
- ? (Math.abs(d.currentTarget.__data__.data.data[0].value /
229
- parentPieTotalValue) * 100).toFixed(convertStringToNumber(chartFormatOptions.toolTip.toolTipDecimalPrecision)) + "%"
230
- : getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.currentTarget.__data__.data.data[0].value),
231
- },
232
- { key: "Legend", value: d.currentTarget.__data__.data.legend },
233
- ], chartFormatOptions);
234
- })
235
- .on("mouseout.text", () => {
236
- hideTooltipOnMouseOut();
237
- })
238
- .on("mouseout.arc", function (d) {
239
- d3.select(this).transition().duration(100).attr("d", arc);
240
- hideTooltipOnMouseOut();
241
- });
242
- drawChildPieDataLabels(childPieData);
243
- drawLines(parentArc, childData);
244
- }
245
- catch (error) {
246
- logError(fileName, "drawChildPie", error);
247
- }
248
- };
249
- const getParentPiePosition = () => {
250
- try {
251
- parentPieX = expandedArcName ? (3 * innerWidth) / 8 : innerWidth / 2;
252
- parentPieY = innerHeight / 2;
253
- return `translate(${parentPieX},${parentPieY})`;
254
- }
255
- catch (error) {
256
- logError(fileName, "getParentPiePosition", error);
257
- }
258
- };
259
- const getChildPiePosition = () => {
260
- try {
261
- childPieX = (3 * innerWidth) / 4;
262
- childPieY = innerHeight / 2;
263
- return `translate(${childPieX},${childPieY})`;
264
- }
265
- catch (error) {
266
- logError(fileName, "getChildPiePosition", error);
267
- }
268
- };
269
- const getDataLabelTransformString = (d, radius) => {
270
- try {
271
- const midAngle = (d.startAngle + d.endAngle) / 2;
272
- const x = Math.cos(midAngle - Math.PI / 2) * (radius * 0.65);
273
- const y = Math.sin(midAngle - Math.PI / 2) * (radius * 0.65);
274
- let rotate = (midAngle * 180) / Math.PI - 90;
275
- return `translate(${x},${y}) rotate(${rotate})`;
276
- }
277
- catch (error) {
278
- logError(fileName, "getDataLabelTransformString", error);
279
- }
280
- };
281
- const drawParentPieDataLabels = () => {
282
- try {
283
- if (chartFormatOptions.plotArea.dataLabels) {
284
- // Code for inside data labels
285
- chartAreaTagG
286
- .append("g")
287
- .attr("class", "parentLabels parentGroup")
288
- .attr("transform", `${getParentPiePosition()}`)
289
- .attr("pointer-events", "none")
290
- .attr("text-anchor", "middle")
291
- .selectAll("text")
292
- .data(pieOfPieData)
293
- .enter()
294
- .append("text")
295
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
296
- .attr("font-size", (d) => d.data.properties?.labelFontSize ?? 11)
297
- .attr("fill", (d) => d.data.properties?.labelFontColor ?? "#000000")
298
- .attr("font-style", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.italic)
299
- ? fontStyleOptions.italic
300
- : "")
301
- .attr("text-decoration", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.underline)
302
- ? fontStyleOptions.underline
303
- : "")
304
- .attr("font-weight", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.bold)
305
- ? fontStyleOptions.bold
306
- : "")
307
- .attr("font-family", (d) => d.data.properties?.labelFont ?? "Helvetica")
308
- .attr("transform", (d) => getDataLabelTransformString(d, radius))
309
- .attr("dy", "-0.35em")
310
- .attr("text-anchor", "middle")
311
- .attr("alignment-baseline", "middle")
312
- .text((d) => {
313
- const { plotArea } = chartFormatOptions;
314
- if (plotArea.dataLabelName) {
315
- return d.data.legend;
316
- }
317
- return "";
318
- });
319
- chartAreaTagG
320
- .append("g")
321
- .attr("class", "parentLabels parentGroup")
322
- .attr("transform", `${getParentPiePosition()}`)
323
- .attr("pointer-events", "none")
324
- .attr("text-anchor", "middle")
325
- .selectAll("text")
326
- .data(pieOfPieData)
327
- .enter()
328
- .append("text")
329
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
330
- .attr("font-size", (d) => d.data.properties?.valueFontSize ?? 11)
331
- .attr("fill", (d) => d.data.properties?.valueFontColor ?? "#000000")
332
- .attr("font-style", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.italic)
333
- ? fontStyleOptions.italic
334
- : "")
335
- .attr("text-decoration", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.underline)
336
- ? fontStyleOptions.underline
337
- : "")
338
- .attr("font-weight", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.bold)
339
- ? fontStyleOptions.bold
340
- : "300")
341
- .attr("font-family", (d) => d.data.properties?.valueFont ?? "Helvetica")
342
- .attr("transform", (d) => getDataLabelTransformString(d, radius))
343
- .attr("text-anchor", "middle")
344
- .attr("alignment-baseline", "middle")
345
- .attr("dy", "1.00em")
346
- .text((d) => {
347
- if (chartFormatOptions.plotArea.dataLabelValue) {
348
- const dataValue = d.data.data[0].value;
349
- if (chartFormatOptions.plotArea.dataLabelName &&
350
- chartFormatOptions.plotArea.dataLabelValue &&
351
- dataValue !== undefined) {
352
- if (chartFormatOptions.plotArea.dataLabelNumberFormat === ",.0%") {
353
- return ((Math.abs(dataValue / parentPieTotalValue) * 100).toFixed(convertStringToNumber(chartFormatOptions.plotArea.dataLabelDecimalPrecision) ?? 0) + "%");
354
- }
355
- else {
356
- return getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(dataValue);
357
- }
358
- }
359
- return dataValue;
360
- }
361
- });
362
- }
363
- }
364
- catch (error) {
365
- logError(fileName, "drawParentPieDataLabels", error);
366
- }
367
- };
368
- const drawChildPieDataLabels = (childData) => {
369
- try {
370
- if (chartFormatOptions.plotArea.dataLabels) {
371
- // Code for inside data labels
372
- chartAreaTagG
373
- .append("g")
374
- .attr("class", "childLabels parentGroup")
375
- .attr("transform", `${getChildPiePosition()}`)
376
- .attr("pointer-events", "none")
377
- .attr("text-anchor", "middle")
378
- .selectAll("text")
379
- .data(childData)
380
- .enter()
381
- .append("text")
382
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
383
- .attr("font-size", (d) => d.data.properties?.labelFontSize ?? 11)
384
- .attr("fill", (d) => d.data.properties?.labelFontColor ?? "#000000")
385
- .attr("font-style", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.italic)
386
- ? fontStyleOptions.italic
387
- : "")
388
- .attr("text-decoration", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.underline)
389
- ? fontStyleOptions.underline
390
- : "")
391
- .attr("font-weight", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.bold)
392
- ? fontStyleOptions.bold
393
- : "")
394
- .attr("font-family", (d) => d.data.properties?.labelFont ?? "Helvetica")
395
- .attr("transform", (d) => getDataLabelTransformString(d, childRadius))
396
- .attr("dy", "-0.35em")
397
- .attr("text-anchor", "middle")
398
- .attr("alignment-baseline", "middle")
399
- .text((d) => {
400
- const { plotArea } = chartFormatOptions;
401
- if (plotArea.dataLabelName) {
402
- return d.data.legend;
403
- }
404
- return "";
405
- });
406
- chartAreaTagG
407
- .append("g")
408
- .attr("class", "childLabels parentGroup")
409
- .attr("transform", `${getChildPiePosition()}`)
410
- .attr("pointer-events", "none")
411
- .attr("text-anchor", "middle")
412
- .selectAll("text")
413
- .data(childData)
414
- .enter()
415
- .append("text")
416
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
417
- .attr("font-size", (d) => d.data.properties?.valueFontSize ?? 11)
418
- .attr("fill", (d) => d.data.properties?.valueFontColor ?? "#000000")
419
- .attr("font-style", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.italic)
420
- ? fontStyleOptions.italic
421
- : "")
422
- .attr("text-decoration", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.underline)
423
- ? fontStyleOptions.underline
424
- : "")
425
- .attr("font-weight", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.bold)
426
- ? fontStyleOptions.bold
427
- : "300")
428
- .attr("font-family", (d) => d.data.properties?.valueFont ?? "Helvetica")
429
- .attr("transform", (d) => getDataLabelTransformString(d, childRadius))
430
- .attr("text-anchor", "middle")
431
- .attr("alignment-baseline", "middle")
432
- .attr("dy", "1.00em")
433
- .text((d) => {
434
- if (chartFormatOptions.plotArea.dataLabelValue) {
435
- const dataValue = d.data.data[0].value;
436
- if (chartFormatOptions.plotArea.dataLabelName &&
437
- chartFormatOptions.plotArea.dataLabelValue &&
438
- dataValue !== undefined) {
439
- if (chartFormatOptions.plotArea.dataLabelNumberFormat === ",.0%") {
440
- return ((Math.abs(dataValue / parentPieTotalValue) * 100).toFixed(convertStringToNumber(chartFormatOptions.plotArea.dataLabelDecimalPrecision) ?? 0) + "%");
441
- }
442
- else {
443
- return getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(dataValue);
444
- }
445
- }
446
- return dataValue;
447
- }
448
- });
449
- }
450
- }
451
- catch (error) {
452
- logError(fileName, "drawChildPieDataLabels", error);
453
- }
454
- };
455
- const drawLines = (angleData, chartData) => {
456
- try {
457
- let arcAngle = Math.abs(angleData.x0 - angleData.x1) / 2;
458
- let radius = angleData.y1;
459
- let y = radius * Math.sin(arcAngle);
460
- let x = y / Math.tan(arcAngle);
461
- chartAreaTagG
462
- .append("line")
463
- .transition()
464
- .style("stroke", chartFormatOptions.pieofPie.pieOfPieLineColor)
465
- .style("stroke-width", chartFormatOptions.pieofPie.pieOfPieLineWidth)
466
- .style("stroke-dasharray", "3, 3")
467
- .attr("opacity", 0.5)
468
- .attr("x1", parentPieX + x) // x position of the first end of the line
469
- .attr("y1", parentPieY - y) // y position of the first end of the line
470
- .attr("x2", childPieX) // x position of the second end of the line
471
- .attr("y2", childPieY - childRadius) //childPiechildRadius
472
- .duration(1000);
473
- chartAreaTagG
474
- .append("line")
475
- .transition()
476
- .style("stroke", chartFormatOptions.pieofPie.pieOfPieLineColor)
477
- .style("stroke-width", chartFormatOptions.pieofPie.pieOfPieLineWidth)
478
- .style("stroke-dasharray", "3, 3")
479
- .attr("opacity", 0.5)
480
- .attr("x1", parentPieX + x) // x position of the first end of the line
481
- .attr("y1", parentPieY + y) // y position of the first end of the line
482
- .attr("x2", childPieX) // x position of the second end of the line
483
- .attr("y2", childPieY + childRadius) //childPieRadius
484
- .duration(1000);
485
- }
486
- catch (error) {
487
- logError(fileName, "drawLines", error);
488
- }
489
- };
490
- const initLegendList = () => {
491
- try {
492
- let seriesData = legendProperties.map((individualLegend) => {
493
- return {
494
- legend: individualLegend.name,
495
- properties: individualLegend,
496
- data: [],
497
- };
498
- });
499
- initLegendListWithTotalValueAllowance(chartFormatOptions, svg, seriesData, width, height, legendListWidth, chartTitleHeight, chartId, margins);
500
- }
501
- catch (error) {
502
- logError(fileName, "initLegendList", error);
503
- }
504
- };
505
- 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%" } })] }));
506
- };
507
- export default PieofPie;