pace-chart-lib 1.0.2 → 1.0.3

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,476 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // Pending Task -> Custom Annotations on charts
3
- //#region imports
4
- import * as d3 from "d3";
5
- import { useEffect, useRef } from "react";
6
- import { fontStyleOptions, } from "../../Core/Common.types";
7
- import { calculateLegendsMaxPossibleWidth, convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, generalizedChartData, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initLegendListWithTotalValueAllowance, initSvg, marginCalculationsForChartsWithoutAxis, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
8
- import { chartMargins } from "../../Core/DefaultProperties.types";
9
- import { connectorStyle } from "../ChartsWithoutAxisTypes.types";
10
- import { logError } from "../../../../Services/ErrorLog";
11
- //#endregion
12
- const fileName = "DonutChart.tsx";
13
- const DonutChart = ({ data, formatOptions, chartId, }) => {
14
- const svgRef = useRef();
15
- const seriesData = generalizedChartData(data.ChartData);
16
- let chartFormatOptions;
17
- let width; // svg total width
18
- let height; // svg total height
19
- let chartTitleHeight = 40; // Height of the chart title
20
- let margins = chartMargins; // Margins for the chart
21
- let maxLegendDimensions = [0, 0]; // to calculate margins [width, height]
22
- let innerHeight; // Height of the chart excluding margins
23
- let innerWidth; // Width of the chart excluding margins
24
- let radius; // Radius of the pie chart
25
- let innerRadius; // Inner radius of the pie chart
26
- let legendListWidth; // Width of the legend list
27
- let chartAreaTagG; // Group element for the chart area
28
- let pieChartData; //Data output by d3.pie function
29
- let pieTotalValue; // Required for % calculations also appeding total to svg
30
- let outsideDataLabelFlag = false; // Flag to check if any data label is outside
31
- let svg; // D3 selection of the SVG element
32
- useEffect(() => {
33
- drawChart();
34
- }, [formatOptions]);
35
- const drawChart = () => {
36
- ({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
37
- loopOverSeriesData();
38
- maxLegendDimensions = calculateLegendsMaxPossibleWidth(chartFormatOptions, seriesData);
39
- ({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } =
40
- marginCalculationsForChartsWithoutAxis(chartFormatOptions, width, height, maxLegendDimensions, margins));
41
- defineChartRadius();
42
- initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
43
- chartAreaTagG = initChartArea(svg, margins);
44
- drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
45
- initLegendListWithTotalValueAllowance(chartFormatOptions, svg, seriesData, width, height, legendListWidth, chartTitleHeight, chartId, margins, false);
46
- initPieChartData();
47
- drawDonutChart();
48
- drawDonutDataLabels();
49
- drawTotalValue();
50
- };
51
- const loopOverSeriesData = () => {
52
- try {
53
- pieTotalValue = 0;
54
- seriesData.forEach((d) => {
55
- d.properties.dataLabelPosition == "2"
56
- ? (outsideDataLabelFlag = true)
57
- : null;
58
- pieTotalValue += d.data[0].value;
59
- });
60
- }
61
- catch (error) {
62
- logError(fileName, "loopOverSeriesData", error);
63
- }
64
- };
65
- const defineChartRadius = () => {
66
- try {
67
- radius = Math.min(innerHeight * 0.4, innerWidth * 0.4);
68
- outsideDataLabelFlag ? (radius = radius * 0.9) : null;
69
- innerRadius = Math.min((convertStringToNumber(chartFormatOptions.plotArea.innerRadius) / 100) *
70
- radius, radius);
71
- }
72
- catch (error) {
73
- logError(fileName, "defineChartRadius", error);
74
- }
75
- };
76
- const initPieChartData = () => {
77
- try {
78
- let rotationAngle = convertStringToNumber(chartFormatOptions.plotArea.rotation);
79
- const pie = d3
80
- ?.pie()
81
- .value((d) => d.data[0].value)
82
- .startAngle(((rotationAngle ?? 0) * (Math.PI / 180)) % 360)
83
- .endAngle((((rotationAngle ?? 0) + 360) * (Math.PI / 180)) % 360);
84
- let pieData = pie(seriesData);
85
- pieChartData = pieData?.map((d, i) => ({
86
- ...d,
87
- x0: d.startAngle,
88
- x1: d.endAngle,
89
- y0: 0,
90
- y1: radius,
91
- depth: 2, // Set depth to 2 to simulate hierarchical level for consistent arc rendering (e.g., in sunburst or partition layouts)
92
- }));
93
- }
94
- catch (error) {
95
- logError(fileName, "initPieChartData", error);
96
- }
97
- };
98
- const drawDonutChart = () => {
99
- try {
100
- const arc = d3
101
- .arc()
102
- .innerRadius(innerRadius) // Donut inner radius
103
- .outerRadius(radius);
104
- const arcOver = d3
105
- .arc()
106
- .innerRadius(innerRadius)
107
- .outerRadius(radius + 10); // Slightly bigger on hover
108
- chartAreaTagG
109
- .append("g")
110
- .attr("class", "parentGroup")
111
- .attr("fill-opacity", chartFormatOptions.plotArea.opacity)
112
- .attr("transform", `${getPiePosition()}`)
113
- .selectAll("path")
114
- .data(pieChartData)
115
- .enter()
116
- .append("path")
117
- .attr("class", (d) => "path " + d.data.legend)
118
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
119
- .attr("fill", (d) => d.data.properties.color !== "#ffffff"
120
- ? d.data.properties.color
121
- : "none")
122
- .attr("d", (d) => arc(d))
123
- .on("mouseover.arc", function (d) {
124
- d3.select(this).transition().duration(100).attr("d", arcOver);
125
- })
126
- .on("mousemove.text", (d) => {
127
- showTooltipOnMouseMove([
128
- {
129
- key: chartFormatOptions.yAxisTitle.yAxisTitleText,
130
- value: chartFormatOptions.toolTip.toolTipNumberFormat == ",.0%"
131
- ? (Math.abs(d.currentTarget.__data__.data.data[0].value /
132
- pieTotalValue) * 100).toFixed(convertStringToNumber(chartFormatOptions.toolTip.toolTipDecimalPrecision)) + "%"
133
- : getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.currentTarget.__data__.data.data[0].value),
134
- },
135
- { key: "Legend", value: d.currentTarget.__data__.data.legend },
136
- ], chartFormatOptions);
137
- })
138
- .on("mouseout.text", () => {
139
- hideTooltipOnMouseOut();
140
- })
141
- .on("mouseout.arc", function (d) {
142
- d3.select(this).transition().duration(100).attr("d", arc);
143
- });
144
- }
145
- catch (error) {
146
- logError(fileName, "drawDonutChart", error);
147
- }
148
- };
149
- const getPiePosition = () => {
150
- try {
151
- return `translate(${innerWidth / 2},${innerHeight / 2})`;
152
- }
153
- catch (error) {
154
- logError(fileName, "getPiePosition", error);
155
- return "";
156
- }
157
- };
158
- const getDataLabelTransformString = (d) => {
159
- try {
160
- const midAngle = (d.startAngle + d.endAngle) / 2;
161
- // Adjust label radius (between innerRadius and outerRadius)
162
- const labelRadius = (innerRadius + radius) / 2; // midpoint between inner and outer radius
163
- const x = Math.cos(midAngle - Math.PI / 2) * labelRadius;
164
- const y = Math.sin(midAngle - Math.PI / 2) * labelRadius;
165
- // Optional rotation logic
166
- let rotate = ((midAngle * 180) / Math.PI) % 360;
167
- let angle = 0;
168
- rotate > 180 && rotate < 360 ? (angle = 90) : (angle = -90);
169
- rotate += angle;
170
- return `translate(${x},${y}) rotate(${rotate})`;
171
- }
172
- catch (error) {
173
- logError(fileName, "getDataLabelTransformString", error);
174
- return "";
175
- }
176
- };
177
- const drawDonutDataLabels = () => {
178
- try {
179
- if (chartFormatOptions.plotArea.dataLabels) {
180
- // Code for inside data labels
181
- chartAreaTagG
182
- .append("g")
183
- .attr("class", "parentGroup")
184
- .attr("transform", `${getPiePosition()}`)
185
- .attr("pointer-events", "none")
186
- .attr("text-anchor", "middle")
187
- .selectAll("text")
188
- .data(pieChartData.filter((d) => d.data.properties.dataLabelPosition == "1"))
189
- .enter()
190
- .append("text")
191
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
192
- .attr("font-size", (d) => d.data.properties?.labelFontSize ?? 11)
193
- .attr("fill", (d) => d.data.properties?.labelFontColor ?? "#000000")
194
- .attr("font-style", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.italic)
195
- ? fontStyleOptions.italic
196
- : "")
197
- .attr("text-decoration", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.underline)
198
- ? fontStyleOptions.underline
199
- : "")
200
- .attr("font-weight", (d) => d.data.properties?.labelFontStyle?.includes(fontStyleOptions.bold)
201
- ? fontStyleOptions.bold
202
- : "")
203
- .attr("font-family", (d) => d.data.properties?.labelFont ?? "Helvetica")
204
- .attr("transform", (d) => getDataLabelTransformString(d))
205
- .attr("dy", "-0.35em")
206
- .attr("text-anchor", "middle")
207
- .attr("alignment-baseline", "middle")
208
- .text((d) => {
209
- const { plotArea } = chartFormatOptions;
210
- if (plotArea.dataLabelName) {
211
- return d.data.legend;
212
- }
213
- return "";
214
- });
215
- chartAreaTagG
216
- .append("g")
217
- .attr("class", "parentGroup")
218
- .attr("transform", `${getPiePosition()}`)
219
- .attr("pointer-events", "none")
220
- .attr("text-anchor", "middle")
221
- .selectAll("text")
222
- .data(pieChartData.filter((d) => d.data.properties.dataLabelPosition == "1"))
223
- .enter()
224
- .append("text")
225
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
226
- .attr("font-size", (d) => d.data.properties?.valueFontSize ?? 11)
227
- .attr("fill", (d) => d.data.properties?.valueFontColor ?? "#000000")
228
- .attr("font-style", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.italic)
229
- ? fontStyleOptions.italic
230
- : "")
231
- .attr("text-decoration", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.underline)
232
- ? fontStyleOptions.underline
233
- : "")
234
- .attr("font-weight", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.bold)
235
- ? fontStyleOptions.bold
236
- : "300")
237
- .attr("font-family", (d) => d.data.properties?.valueFont ?? "Helvetica")
238
- .attr("transform", (d) => getDataLabelTransformString(d))
239
- .attr("text-anchor", "middle")
240
- .attr("alignment-baseline", "middle")
241
- .attr("dy", "1.00em")
242
- .text((d) => {
243
- if (chartFormatOptions.plotArea.dataLabelValue) {
244
- const dataValue = d.data.data[0].value;
245
- if (chartFormatOptions.plotArea.dataLabelName &&
246
- chartFormatOptions.plotArea.dataLabelValue &&
247
- dataValue !== undefined) {
248
- if (chartFormatOptions.plotArea.dataLabelNumberFormat === ",.0%") {
249
- return ((Math.abs(dataValue / pieTotalValue) * 100).toFixed(convertStringToNumber(chartFormatOptions.plotArea.dataLabelDecimalPrecision) ?? 0) + "%");
250
- }
251
- else {
252
- return getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(dataValue);
253
- }
254
- }
255
- return dataValue;
256
- }
257
- })
258
- .append("tspan")
259
- .attr("x", 0)
260
- .attr("y", chartFormatOptions.plotArea.dataLabelValue
261
- ? chartFormatOptions.plotArea.dataLabelName
262
- ? "2.45em"
263
- : "0.1em"
264
- : null)
265
- .attr("font-weight", (d) => d.data.properties?.valueFontStyle?.includes(fontStyleOptions.bold)
266
- ? fontStyleOptions.bold
267
- : "300")
268
- .attr("fill-opacity", 0.5)
269
- .text((d) => {
270
- const dataValue = Math.abs(d.data.data[0].value);
271
- if (chartFormatOptions.plotArea.plotAreaAbsoluteValue &&
272
- dataValue !== undefined) {
273
- return d3.format(".2s")(dataValue);
274
- }
275
- return "";
276
- });
277
- // Code for outside data labels
278
- let outerRadius = d3
279
- .arc()
280
- .startAngle((d) => d.x0)
281
- .endAngle((d) => d.x1)
282
- .innerRadius((d) => (d.depth > 1 ? d.y1 - 1 + radius / 7 : 0))
283
- .outerRadius((d) => (d.depth > 1 ? d.y1 - 1 + radius / 7 : 0));
284
- let innerRadius = d3
285
- .arc()
286
- .startAngle((d) => d.x0)
287
- .endAngle((d) => d.x1)
288
- .innerRadius((d) => (d.depth > 2 ? d.y0 : 0))
289
- .outerRadius((d) => d.y1 + radius / 1.5);
290
- chartAreaTagG
291
- .selectAll("polyline")
292
- .data(pieChartData.filter((d) => d.data.properties.dataLabelPosition == "2"))
293
- .join("polyline")
294
- .attr("transform", getPiePosition())
295
- .style("stroke", (d) => chartFormatOptions.connector.connectorColorOption == "Uniform"
296
- ? chartFormatOptions.connector.connectorUniformLineColor
297
- : d.data.properties.color)
298
- .style("fill", "none")
299
- .style("stroke-dasharray", chartFormatOptions.connector.connectorStyle === connectorStyle.solid
300
- ? 0
301
- : chartFormatOptions.connector.connectorStyle ===
302
- connectorStyle.dotted
303
- ? 1
304
- : 4)
305
- .style("stroke-width", chartFormatOptions.connector.connectorLineThickness)
306
- .attr("points", (d) => {
307
- const posA = innerRadius.centroid(d);
308
- const posB = outerRadius.centroid(d);
309
- let midangle = d.x0 + (d.x1 - d.x0) / 2;
310
- midangle = midangle % (2 * Math.PI);
311
- const xC = radius * 1.1 * (midangle < Math.PI ? 1 : -1);
312
- const yC = posB[1];
313
- return [posA, posB, [xC, yC]]
314
- .map((point) => point.join(",")) // convert to "x,y"
315
- .join(" "); // join as "x1,y1 x2,y2 x3,y3"
316
- });
317
- chartAreaTagG
318
- .append("g")
319
- .attr("transform", getPiePosition())
320
- .selectAll("foreignObject")
321
- .data(pieChartData.filter((d) => d.data.properties.dataLabelPosition == "2"))
322
- .join("foreignObject")
323
- .attr("width", 80)
324
- .attr("height", 60)
325
- .attr("x", (d) => {
326
- let midangle = d.x0 + (d.x1 - d.x0) / 2;
327
- midangle = midangle % (2 * Math.PI);
328
- const textWidth = 80;
329
- const xOffset = midangle < Math.PI ? 0 : -textWidth;
330
- return radius * 1.1 * (midangle < Math.PI ? 1 : -1) + xOffset;
331
- })
332
- .attr("y", (d) => outerRadius.centroid(d)[1] - 30)
333
- .append("xhtml:div")
334
- .attr("hoverId", (d) => d.data.legend.replace(/ /g, "-"))
335
- .style("display", "flex")
336
- .style("flex-direction", "column")
337
- .style("justify-content", "center")
338
- .style("align-items", "center")
339
- .style("height", "60px")
340
- .html((d) => {
341
- try {
342
- let value = d.data.data[0].value.toString();
343
- if (d.data.data[0].value !== undefined) {
344
- value =
345
- chartFormatOptions.plotArea.dataLabelNumberFormat === ",.0%"
346
- ? (Math.abs(d.data.data[0].value / pieTotalValue) * 100).toFixed(convertStringToNumber(chartFormatOptions.plotArea.dataLabelDecimalPrecision)) + "%"
347
- : getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(d.data.data[0].value);
348
- }
349
- let htmlString = "";
350
- if (chartFormatOptions.plotArea.dataLabelName) {
351
- htmlString += `<span style="
352
- font-size: ${d.data.properties.labelFontSize}px;
353
- color: ${d.data.properties.labelFontColor};
354
- font-style: ${d.data.properties.labelFontStyle.includes(fontStyleOptions.italic)
355
- ? fontStyleOptions.italic
356
- : ""};
357
- text-decoration: ${d.data.properties.labelFontStyle.includes(fontStyleOptions.underline)
358
- ? fontStyleOptions.underline
359
- : ""};
360
- font-weight: ${d.data.properties.labelFontStyle.includes(fontStyleOptions.bold)
361
- ? fontStyleOptions.bold
362
- : ""};
363
- font-family: ${d.data.properties.labelFont};
364
- display: block; white-space: nowrap; width:80px; overflow:hidden; text-overflow:ellipsis; text-align: center;">
365
- ${d.data.legend}
366
- </span>`;
367
- }
368
- if (chartFormatOptions.plotArea.dataLabelValue &&
369
- d.data.data[0].value !== undefined) {
370
- htmlString += `<span style="
371
- font-size: ${d.data.properties.valueFontSize}px;
372
- color: ${d.data.properties.valueFontColor};
373
- font-style: ${d.data.properties.valueFontStyle.includes(fontStyleOptions.italic)
374
- ? fontStyleOptions.italic
375
- : ""};
376
- text-decoration: ${d.data.properties.valueFontStyle.includes(fontStyleOptions.underline)
377
- ? fontStyleOptions.underline
378
- : ""};
379
- font-weight: ${d.data.properties.valueFontStyle.includes(fontStyleOptions.bold)
380
- ? fontStyleOptions.bold
381
- : "300"};
382
- font-family: ${d.data.properties.valueFont};
383
- display: block;">
384
- ${value}
385
- </span>`;
386
- }
387
- if (chartFormatOptions.plotArea.plotAreaAbsoluteValue &&
388
- d.data[0].value !== undefined) {
389
- htmlString += `<span style="
390
- font-size: ${d.data.properties.valueFontSize}px;
391
- color: ${d.data.properties.valueFontColor};
392
- font-style: ${d.data.properties.valueFontStyle.includes(fontStyleOptions.italic)
393
- ? fontStyleOptions.italic
394
- : ""};
395
- text-decoration: ${d.data.properties.valueFontStyle.includes(fontStyleOptions.underline)
396
- ? fontStyleOptions.underline
397
- : ""};
398
- font-weight: ${d.data.properties.valueFontStyle.includes(fontStyleOptions.bold)
399
- ? fontStyleOptions.bold
400
- : "300"};
401
- font-family: ${d.data.properties.valueFont};
402
- display: block;">
403
- ${d3.format(".2s")(d.data[0].value)}
404
- </span>`;
405
- }
406
- return htmlString;
407
- }
408
- catch (error) {
409
- logError(fileName, "drawDonutDataLabels", error);
410
- return "";
411
- }
412
- });
413
- }
414
- }
415
- catch (error) {
416
- logError(fileName, "drawDonutDataLabels", error);
417
- }
418
- };
419
- const drawTotalValue = () => {
420
- try {
421
- if (chartFormatOptions.total &&
422
- chartFormatOptions.total.totalVisibility) {
423
- let total = pieTotalValue;
424
- let fontStyle = chartFormatOptions.total.totalFontStyle;
425
- chartAreaTagG
426
- .append("g")
427
- .attr("transform", getPiePosition())
428
- .attr("pointer-events", "none")
429
- .attr("text-anchor", "middle")
430
- .append("text")
431
- .style("fill", chartFormatOptions.total.totalColor !== "#ffffff"
432
- ? chartFormatOptions.total.totalColor
433
- : "none")
434
- .style("font-family", chartFormatOptions.total.totalFontFamily)
435
- .style("font-size", chartFormatOptions.total.totalFontSize)
436
- .style("font-style", fontStyle.includes(fontStyleOptions.italic)
437
- ? fontStyleOptions.italic
438
- : "")
439
- .style("text-decoration", fontStyle.includes(fontStyleOptions.underline)
440
- ? fontStyleOptions.underline
441
- : "")
442
- .style("font-weight", fontStyle.includes(fontStyleOptions.bold)
443
- ? fontStyleOptions.bold
444
- : "")
445
- .attr("text-anchor", "middle")
446
- .attr("visibility", chartFormatOptions.plotArea.dataLabelValue ? "visible" : "hidden")
447
- .text(chartFormatOptions.total.editTotalText)
448
- .append("tspan")
449
- .attr("x", 0)
450
- .attr("y", "1.3em")
451
- .attr("font-weight", fontStyle.includes(fontStyleOptions.bold)
452
- ? fontStyleOptions.bold
453
- : 300)
454
- // .attr("fill-opacity", 0.5)
455
- .text(chartFormatOptions.total.totalNumberFormat === ",.0%" ||
456
- chartFormatOptions.total.totalNumberFormat === "Percentage"
457
- ? "100%"
458
- : getNumberWithFormatFunction(chartFormatOptions.total.totalDisplayUnits, chartFormatOptions.total.totalNumberFormat, chartFormatOptions.total.totalDecimalPrecision)(total));
459
- }
460
- }
461
- catch (error) {
462
- logError(fileName, "drawTotalValue", error);
463
- }
464
- };
465
- // return (
466
- // <div style={{ width: "100%", height: "100%" }}>
467
- // <svg
468
- // className="chartSVG"
469
- // style={{ width: "100%", height: "100%" }}
470
- // ref={svgRef}
471
- // ></svg>
472
- // </div>
473
- // );
474
- 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%" } })] }));
475
- };
476
- export default DonutChart;