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,391 +0,0 @@
1
- import { jsx as _jsx } 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, firstFunctionBeforeRender, generalizedChartData, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initSvg, marginCalculationsForChartsWithoutLegends, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
7
- import { chartMargins } from "../../Core/DefaultProperties.types";
8
- import { unitedStates } from "./Cordinates";
9
- import { logError } from "../../../../Services/ErrorLog";
10
- //#endregion
11
- const Maps = ({ data, geoJsonNode, formatOptions, chartId, }) => {
12
- //#region Variables
13
- const svgRef = useRef(); // Reference to the SVG element
14
- let seriesData = generalizedChartData(data); // Data for the word cloud, expected to be an array of objects with properties
15
- let chartFormatOptions; // Format options for the chart
16
- let width; // svg total width
17
- let height; // svg total height
18
- let min = Number.MAX_VALUE; // svg total height
19
- let max = Number.MIN_VALUE; // svg total height
20
- let chartTitleHeight = 40; // Height of the chart title
21
- let margins = chartMargins; // Margins for the chart
22
- let innerHeight; // Height of the chart excluding margins
23
- let innerWidth; // Width of the chart excluding margins
24
- let chartAreaTagG; // Group element for the chart area
25
- let svg; // SVG element for the chart
26
- let valueIndex = 0; // Index for the value in the data series
27
- let bubbleIndex = 1; // Index for the bubble in the data series
28
- let cordinatesData; // Data for the map coordinates, initially undefined
29
- let actualNameToGroupedNameMap = new Map(); // Map to hold actual names to grouped names
30
- let actualNameToAliasedNameMap = new Map(); // Map to hold aliased names to actual names
31
- let nameToDataMap = new Map(); // Map to hold names to data series
32
- let valueMin = Number.MAX_VALUE; // Minimum value for the data series
33
- let valueMax = Number.MIN_VALUE; // Maximum value for the data series
34
- let bubbleMin = Number.MAX_VALUE; // Minimum value for bubble size
35
- let bubbleMax = Number.MIN_VALUE; // Max;imum value for bubble size
36
- let totalValue = 0; // Total value for the data series
37
- let bubbleTotal = 0; // Total value for bubble size
38
- let colorScale;
39
- let colorScaleForMapsBubble; // Color scale for the bubbles
40
- //#endregion
41
- useEffect(() => {
42
- drawChart();
43
- }, [formatOptions, chartId]);
44
- const drawChart = () => {
45
- ({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
46
- ({ margins, chartTitleHeight, innerHeight, innerWidth } =
47
- marginCalculationsForChartsWithoutLegends(chartFormatOptions, height, width));
48
- initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
49
- chartAreaTagG = initChartArea(svg, margins);
50
- drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
51
- dataPreparation(data);
52
- readMapsCordinateFile(data);
53
- generateDataForMaps();
54
- drawMap();
55
- };
56
- const dataPreparation = (data) => {
57
- try {
58
- let uniqueValues = new Set();
59
- let bubbleUniqueValues = new Set();
60
- data.forEach((series) => {
61
- series.data.forEach((dataPoint, index) => {
62
- if (index === valueIndex) {
63
- uniqueValues.add(dataPoint.value.toString());
64
- totalValue += dataPoint.value;
65
- }
66
- if (index === bubbleIndex) {
67
- bubbleUniqueValues.add(dataPoint.value.toString());
68
- bubbleTotal += dataPoint.value;
69
- }
70
- });
71
- });
72
- let startColor = chartFormatOptions.colorScaleForMaps &&
73
- chartFormatOptions.colorScaleForMaps.startColorForMaps
74
- ? chartFormatOptions.colorScaleForMaps.startColorForMaps
75
- : "#c1d8f3";
76
- let endColor = chartFormatOptions.colorScaleForMaps &&
77
- chartFormatOptions.colorScaleForMaps.endColorForMaps
78
- ? chartFormatOptions.colorScaleForMaps.endColorForMaps
79
- : "#4c6ba5";
80
- if (uniqueValues.size === 1) {
81
- colorScale = () => startColor; // Single value — one color
82
- }
83
- else {
84
- const interpolator = d3.interpolateLab(startColor, endColor);
85
- colorScale = d3
86
- .scaleOrdinal()
87
- .domain(Array.from(uniqueValues))
88
- .range(Array.from(uniqueValues).map((_, i) => interpolator(i / (uniqueValues.size - 1))));
89
- }
90
- if (bubbleUniqueValues.size === 1) {
91
- colorScaleForMapsBubble = () => startColor; // Single value — one color
92
- }
93
- else {
94
- const interpolator = d3.interpolateLab(chartFormatOptions.colorScaleForMapsBubble.startColorForMapsBubble, chartFormatOptions.colorScaleForMapsBubble.endColorForMapsBubble);
95
- colorScaleForMapsBubble = d3
96
- .scaleOrdinal()
97
- .domain(Array.from(bubbleUniqueValues))
98
- .range(Array.from(bubbleUniqueValues).map((_, i) => interpolator(i / (bubbleUniqueValues.size - 1))));
99
- }
100
- }
101
- catch (error) {
102
- logError("Maps.tsx", "dataPreparation", error);
103
- }
104
- };
105
- const readMapsCordinateFile = (data) => {
106
- cordinatesData = unitedStates; // Use the hardcoded cordinates data for the map
107
- };
108
- const generateDataForMaps = () => {
109
- try {
110
- seriesData?.forEach((series) => {
111
- nameToDataMap.set(series.legend, series);
112
- });
113
- geoJsonNode.mappings.forEach((mapping) => {
114
- actualNameToAliasedNameMap.set(mapping.actualName, mapping.mappedName);
115
- });
116
- geoJsonNode.groups.forEach((groupObject) => {
117
- groupObject.groupedRegions.forEach((region) => {
118
- actualNameToGroupedNameMap.set(region, groupObject.groupName);
119
- });
120
- });
121
- cordinatesData.features.forEach((feature) => {
122
- const regionName = feature.properties.name;
123
- let name;
124
- if (actualNameToAliasedNameMap.has(regionName)) {
125
- const aliasedRegion = actualNameToAliasedNameMap.get(regionName);
126
- feature.properties["displayName"] = aliasedRegion;
127
- name = aliasedRegion;
128
- }
129
- if (actualNameToGroupedNameMap.has(regionName)) {
130
- const groupedRegion = actualNameToGroupedNameMap.get(regionName);
131
- feature.properties["displayName"] = groupedRegion;
132
- name = groupedRegion;
133
- }
134
- else {
135
- name = regionName;
136
- }
137
- if (nameToDataMap.has(name)) {
138
- const dataSeries = nameToDataMap.get(name);
139
- feature.properties["data"] = dataSeries;
140
- let value;
141
- if (dataSeries.data && dataSeries.data[1]) {
142
- value = dataSeries.data[1] ? dataSeries.data[1].value : 0;
143
- bubbleMin = Math.min(bubbleMin, value);
144
- bubbleMax = Math.max(bubbleMax, value);
145
- }
146
- if (dataSeries.data && dataSeries.data[0]) {
147
- value = dataSeries.data[0].value;
148
- min = Math.min(min, value);
149
- max = Math.max(max, value);
150
- }
151
- }
152
- else {
153
- feature.properties["data"] = undefined; // Default value if no data series found
154
- }
155
- });
156
- }
157
- catch (error) {
158
- logError("Maps.tsx", "generateDataForMaps", error);
159
- }
160
- };
161
- const drawMap = () => {
162
- //#region Drawing the map
163
- try {
164
- let totalArea = 0;
165
- const Projection = d3
166
- .geoAlbersUsa()
167
- .fitSize([innerWidth, innerHeight], cordinatesData);
168
- const pathGenerator = d3.geoPath().projection(Projection);
169
- const paths = chartAreaTagG.append("g").attr("class", "paths");
170
- paths
171
- .selectAll(chartId + " .path-group")
172
- .data(cordinatesData.features)
173
- .enter()
174
- .append("path")
175
- .attr("id", (d) => d.properties.name)
176
- .attr("fill", (d, i) => getMapColor(d))
177
- .attr("stroke", (d) => (d.properties.data ? "unset" : "#CCCCCC"))
178
- .attr("fill-opacity", chartFormatOptions.plotArea.opacity)
179
- .attr("stroke-width", "0.4px")
180
- .attr("d", (d) => {
181
- totalArea += pathGenerator.area(d);
182
- return pathGenerator(d);
183
- })
184
- .on("mousemove", (event, d) => {
185
- let data = d.properties.data;
186
- if (data) {
187
- let keyValueObject = data.data.map((keyValue) => ({
188
- key: keyValue.dimension,
189
- value: getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(keyValue.value),
190
- }));
191
- showTooltipOnMouseMove([
192
- {
193
- key: "Region",
194
- value: data.properties.alias,
195
- },
196
- ...keyValueObject,
197
- ], chartFormatOptions);
198
- }
199
- })
200
- .on("mouseout", (event, d) => {
201
- hideTooltipOnMouseOut();
202
- });
203
- //#endregion
204
- //#region Labels
205
- if (chartFormatOptions.plotArea.dataLabels) {
206
- const avgArea = totalArea / cordinatesData.features.length;
207
- const isLabelVisible = chartFormatOptions.plotArea.dataLabelName;
208
- const isValueVisible = chartFormatOptions.plotArea.dataLabelValue;
209
- const isSmallArea = (d) => chartFormatOptions.dataLabelOverlappingToggle.dataLabelOverlap &&
210
- d.geometry.type === "Polygon"
211
- ? pathGenerator.area(d) < avgArea * 0.25
212
- : false;
213
- paths
214
- .selectAll(".text-container")
215
- .data(cordinatesData.features)
216
- .enter()
217
- .append("foreignObject")
218
- .style("pointer-events", "none")
219
- .attr("class", "text-container")
220
- .attr("x", (d) => {
221
- const centroid = pathGenerator.centroid(d);
222
- return centroid[0] - 50; // Adjust x-position based on text width
223
- })
224
- .attr("y", (d) => {
225
- const centroid = pathGenerator.centroid(d);
226
- return isLabelVisible && isValueVisible
227
- ? centroid[1] - 15
228
- : centroid[1] - 10; // Adjust y-position based on text height
229
- })
230
- .attr("width", 100)
231
- .attr("height", 40)
232
- .append("xhtml:div")
233
- .html((d) => {
234
- let data = d.properties.data;
235
- if ((isLabelVisible || isValueVisible) && data && !isSmallArea(d)) {
236
- if (isSmallArea(d))
237
- return null;
238
- const name = data?.properties.alias || d.properties.displayName;
239
- const value = chartFormatOptions.plotArea.dataLabelNumberFormat == ",.0%"
240
- ? Math.round((d.properties.data.data[0].value / totalValue) * 100) + "%"
241
- : getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(d.properties.data.data[0].value);
242
- let htmlString = "";
243
- if (chartFormatOptions.plotArea.dataLabelName) {
244
- htmlString += `<div style=
245
- "text-align:center;
246
- font-family:${d.properties.data.properties.labelFont};
247
- font-size:${d.properties.data.properties.labelFontSize}px;
248
- font-weight:${d.properties.data.properties.labelFontStyle.includes(fontStyleOptions.bold)
249
- ? fontStyleOptions.bold
250
- : "normal"};
251
- font-style:${d.properties.data.properties.labelFontStyle.includes(fontStyleOptions.italic)
252
- ? fontStyleOptions.italic
253
- : "normal"};
254
- text-decoration:${d.properties.data.properties.labelFontStyle.includes(fontStyleOptions.underline)
255
- ? fontStyleOptions.underline
256
- : "none"};
257
- color:${d.properties.data.properties.labelFontColor};">
258
- ${name ?? ""}
259
- </div>`;
260
- }
261
- if (chartFormatOptions.plotArea.dataLabelValue) {
262
- htmlString += `<div style=
263
- "text-align:center;
264
- font-family:${d.properties.data.properties.valueFont}; font-size:${d.properties.data.properties.valueFontSize}px;
265
- font-weight:${d.properties.data.properties.valueFontStyle.includes(fontStyleOptions.bold)
266
- ? fontStyleOptions.bold
267
- : "normal"};
268
- font-style:${d.properties.data.properties.valueFontStyle.includes(fontStyleOptions.italic)
269
- ? fontStyleOptions.italic
270
- : "normal"};
271
- text-decoration:${d.properties.data.properties.valueFontStyle.includes(fontStyleOptions.underline)
272
- ? fontStyleOptions.underline
273
- : "none"};
274
- color:${d.properties.data.properties.valueFontColor};">
275
- ${value ?? ""}
276
- </div>`;
277
- }
278
- return htmlString;
279
- }
280
- return null;
281
- });
282
- }
283
- //#endregion
284
- // will introduce zoom and pan functionality later
285
- // #region Zoom and Pan
286
- // const ZOOM_KEY = "myZoomTransform";
287
- // // 1. Load saved transform from localStorage (if exists)
288
- // let savedTransform = d3.zoomIdentity;
289
- // const stored = localStorage.getItem(ZOOM_KEY);
290
- // if (stored) {
291
- // try {
292
- // const { x, y, k } = JSON.parse(stored);
293
- // savedTransform = d3.zoomIdentity.translate(x, y).scale(k);
294
- // } catch (e) {
295
- // console.warn("Invalid zoom transform in storage:", e);
296
- // }
297
- // }
298
- // // 2. Setup zoom behavior
299
- // const zoom = d3
300
- // .zoom()
301
- // .scaleExtent([1, 8])
302
- // .on("zoom", (event) => {
303
- // const t = event.transform;
304
- // Paths.attr("transform", t);
305
- // // 3. Save transform to localStorage
306
- // localStorage.setItem(ZOOM_KEY, JSON.stringify(t));
307
- // });
308
- // // 4. Call zoom and apply saved transform
309
- // svg.call(zoom).call(zoom.transform, savedTransform);
310
- //#endregion
311
- //#region bubble
312
- if (chartFormatOptions.bubbleformatting.showBubble) {
313
- let minDim = Math.min(innerWidth, innerHeight);
314
- const scaleCircle = d3
315
- .scaleLinear()
316
- .domain([bubbleMin, bubbleMax])
317
- .range([minDim * 0.01, minDim * 0.07]);
318
- chartAreaTagG
319
- .selectAll("myCircles")
320
- .data(cordinatesData.features)
321
- .join("circle")
322
- .attr("cx", (d) => pathGenerator.centroid(d)[0])
323
- .attr("cy", (d) => pathGenerator.centroid(d)[1])
324
- .attr("r", (d) => d.properties.data
325
- ? scaleCircle(d.properties.data?.data[1]?.value || 0)
326
- : 0)
327
- // .attr("fill", chartFormatOptions.bubbleformatting && chartFormatOptions.bubbleformatting.BubbleColor)
328
- .attr("fill", (d, i) => chartFormatOptions.colorScaleForMapsBubble.showColorForMapsBubble ==
329
- "2"
330
- ? colorScaleForMapsBubble(d.properties.data
331
- ? d.properties.data.data[bubbleIndex]?.value || 0
332
- : 0)
333
- : chartFormatOptions.bubbleformatting.bubbleColor)
334
- .attr("stroke", chartFormatOptions.bubbleformatting &&
335
- chartFormatOptions.bubbleformatting.bubbleBorderColor)
336
- .attr("stroke-width", chartFormatOptions.bubbleformatting &&
337
- chartFormatOptions.bubbleformatting.bubbleBorderWidth)
338
- .attr("fill-opacity", chartFormatOptions.bubbleformatting &&
339
- convertStringToNumber(chartFormatOptions.bubbleformatting.bubbleOpacity) / 10)
340
- .on("mousemove", function (event, d) {
341
- showTooltipOnMouseMove([
342
- {
343
- key: "Region",
344
- value: d.properties?.data?.propeties?.Alias,
345
- },
346
- {
347
- key: d.properties.data?.data[1]?.dimension,
348
- value: chartFormatOptions.toolTip.toolTipNumberFormat == ",.0%"
349
- ? Math.round((d.properties.data?.data[1]?.value / bubbleTotal) *
350
- 100) + "%"
351
- : getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.properties.data?.data[1]?.value),
352
- },
353
- ], chartFormatOptions);
354
- d3.select(this).style("r", (d.properties.data
355
- ? scaleCircle(d.properties.data?.data[1]?.value || 0)
356
- : 0) * 1.2);
357
- })
358
- .on("mouseout", function (event, d) {
359
- hideTooltipOnMouseOut();
360
- d3.select(this).style("r", d.properties.data
361
- ? scaleCircle(d.properties.data?.data[1]?.value || 0)
362
- : 0);
363
- });
364
- }
365
- //#endregion
366
- }
367
- catch (error) {
368
- logError("Maps.tsx", "drawMap", error);
369
- }
370
- };
371
- const getMapColor = (d) => {
372
- try {
373
- let data = d.properties.data;
374
- switch (parseInt(chartFormatOptions.colorScaleForMaps.showColorForMaps)) {
375
- case 1:
376
- return data ? data.properties.color : "#E6E6E6";
377
- case 2:
378
- return chartFormatOptions.colorScaleForMaps.defaultColor;
379
- case 3:
380
- return d.properties.data
381
- ? colorScale(d.properties.data?.data[valueIndex]?.value)
382
- : "#E6E6E6";
383
- }
384
- }
385
- catch (error) {
386
- logError("Maps.tsx", "getMapColor", error);
387
- }
388
- };
389
- return (_jsx("div", { style: { width: "100%", height: "100%" }, children: _jsx("svg", { id: chartId, className: "chartSVG", style: { width: "100%", height: "100%" }, ref: svgRef }) }));
390
- };
391
- export default Maps;