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