pace-chart-lib 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +10 -54
  2. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +46 -0
  3. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +2285 -0
  4. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +169 -0
  5. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +47 -0
  6. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +4 -0
  7. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.js +403 -0
  8. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  9. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -0
  10. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  11. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  12. package/dist/Components1/Charts/Core/Common.type.d.ts +8 -0
  13. package/dist/Components1/Charts/Core/Common.type.js +9 -0
  14. package/dist/Components1/Charts/Core/CommonFunctions.d.ts +12 -0
  15. package/dist/Components1/Charts/Core/CommonFunctions.js +512 -0
  16. package/dist/Components1/Charts/Core/DefaultProperties.d.ts +586 -0
  17. package/dist/Components1/Charts/Core/DefaultProperties.js +585 -0
  18. package/dist/Services/ErrorLog.d.ts +1 -0
  19. package/dist/Services/ErrorLog.js +3 -0
  20. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +4 -0
  21. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +497 -0
  22. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +4 -0
  23. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +491 -0
  24. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +4 -0
  25. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +520 -0
  26. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +4 -0
  27. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +553 -0
  28. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +4 -0
  29. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +519 -0
  30. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +4 -0
  31. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +553 -0
  32. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +12 -0
  33. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +9 -0
  34. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +623 -0
  35. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +4897 -0
  36. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
  37. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
  38. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +173 -0
  39. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +49 -0
  40. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +4 -0
  41. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +486 -0
  42. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +4 -0
  43. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +498 -0
  44. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +4 -0
  45. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +417 -0
  46. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +4 -0
  47. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +1014 -0
  48. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +4 -0
  49. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +479 -0
  50. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +4 -0
  51. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +451 -0
  52. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +4 -0
  53. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +535 -0
  54. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.d.ts +4 -0
  55. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +512 -0
  56. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +4 -0
  57. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +532 -0
  58. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.d.ts +4 -0
  59. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +512 -0
  60. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +12 -0
  61. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +9 -0
  62. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +4 -0
  63. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +498 -0
  64. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +4 -0
  65. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +498 -0
  66. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +4 -0
  67. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +479 -0
  68. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +4 -0
  69. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +479 -0
  70. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +4 -0
  71. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +474 -0
  72. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +4 -0
  73. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +464 -0
  74. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
  75. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
  76. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +4 -0
  77. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +452 -0
  78. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +4 -0
  79. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +554 -0
  80. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +4 -0
  81. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +513 -0
  82. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +4 -0
  83. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +508 -0
  84. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +4 -0
  85. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +395 -0
  86. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +4 -0
  87. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +608 -0
  88. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
  89. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
  90. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +92 -0
  91. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +815 -0
  92. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  93. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  94. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +108 -0
  95. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +32 -0
  96. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +26 -0
  97. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +15021 -0
  98. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +4 -0
  99. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +391 -0
  100. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +4 -0
  101. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +367 -0
  102. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +4 -0
  103. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +569 -0
  104. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +3 -0
  105. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +212 -0
  106. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +3 -0
  107. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +401 -0
  108. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +4 -0
  109. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +313 -0
  110. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +4 -0
  111. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +719 -0
  112. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +4 -0
  113. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +807 -0
  114. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +3 -0
  115. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +514 -0
  116. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +4 -0
  117. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +282 -0
  118. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +4 -0
  119. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +207 -0
  120. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +4 -0
  121. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +476 -0
  122. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +4 -0
  123. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +420 -0
  124. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +10 -0
  125. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +106 -0
  126. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +3 -0
  127. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +507 -0
  128. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +3 -0
  129. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +246 -0
  130. package/dist/components/Charts/Core/Common.type.d.ts +0 -0
  131. package/dist/components/Charts/Core/Common.type.js +0 -0
  132. package/dist/components/Charts/Core/Common.types.d.ts +369 -0
  133. package/dist/components/Charts/Core/Common.types.js +133 -0
  134. package/dist/components/Charts/Core/CommonFunctions.d.ts +236 -0
  135. package/dist/components/Charts/Core/CommonFunctions.js +1778 -0
  136. package/dist/components/Charts/Core/DefaultChartDataProperties.d.ts +65 -0
  137. package/dist/components/Charts/Core/DefaultChartDataProperties.js +64 -0
  138. package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
  139. package/dist/components/Charts/Core/DefaultProperties.js +0 -0
  140. package/dist/components/Charts/Core/DefaultProperties.type.d.ts +586 -0
  141. package/dist/components/Charts/Core/DefaultProperties.type.js +585 -0
  142. package/dist/components/Charts/Core/DefaultProperties.types.d.ts +592 -0
  143. package/dist/components/Charts/Core/DefaultProperties.types.js +592 -0
  144. package/dist/index.d.ts +34 -2
  145. package/dist/index.js +40 -2
  146. package/package.json +40 -29
  147. package/dist/components/charts/linechart/LineChart.d.ts +0 -12
  148. package/dist/components/charts/linechart/LineChart.js +0 -5
  149. /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.d.ts +0 -0
  150. /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.js +0 -0
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { IMapsProps } from "../../Core/Common.types";
3
+ declare const Maps: React.FC<IMapsProps>;
4
+ export default Maps;
@@ -0,0 +1,391 @@
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;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { TBubbleChartProps } from "../../Core/Common.types";
3
+ declare const BubbleChart: React.FC<TBubbleChartProps>;
4
+ export default BubbleChart;