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,3 @@
1
+ import { IChartProps } from "../ChartsWithoutAxisTypes.types";
2
+ declare const Speedometer: React.FC<IChartProps>;
3
+ export default Speedometer;
@@ -0,0 +1,514 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as d3 from "d3";
3
+ import { useEffect, useRef } from "react";
4
+ import { colorThemeTypes, connectorKPIforSpeedometerType, dataLabelPositionType, fontStyleOptions, } from "../../Core/Common.types";
5
+ import { convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, generalizedChartData, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initSvg, marginCalculationsForChartsWithoutLegends, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
6
+ import { logError } from "../../../../Services/ErrorLog";
7
+ import { chartMargins } from "../../Core/DefaultProperties.types";
8
+ const Speedometer = ({ data, formatOptions, chartId, }) => {
9
+ const svgRef = useRef();
10
+ const seriesData = generalizedChartData(data);
11
+ let chartFormatOptions;
12
+ let width; // svg total width
13
+ let height; // svg total height
14
+ let chartTitleHeight = 40; // Height of the chart title
15
+ let margins = chartMargins; // Margins for the chart
16
+ let innerHeight; // Height of the chart excluding margins
17
+ let innerWidth; // Width of the chart excluding margins
18
+ let chartAreaTagG;
19
+ let svg;
20
+ let radius; // Radius of the pie chart
21
+ let innerRadius; // Inner radius of the pie chart
22
+ let gaugeMaxMeasure; // Maximum measure value for the gauge
23
+ let gaugeMinMeasure; // Minimum measure value for the gauge
24
+ let colorThemeArray; // Array to hold color themes for the gauge
25
+ let calculatedTicksValue; // Number of ticks for the gauge
26
+ let tickValueArray; // Array to hold tick values for the gauge
27
+ let gaugemap = {}; // Object to hold the gauge functions and configurations
28
+ let positionTransformString; // String to hold the translation for positioning the gauge
29
+ const fileName = "Speedometer.tsx";
30
+ useEffect(() => {
31
+ drawChart();
32
+ }, [formatOptions]);
33
+ const drawChart = () => {
34
+ ({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
35
+ ({ margins, chartTitleHeight, innerHeight, innerWidth } =
36
+ marginCalculationsForChartsWithoutLegends(chartFormatOptions, height, width));
37
+ initChartRadius();
38
+ initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
39
+ chartAreaTagG = initChartArea(svg, margins);
40
+ drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
41
+ initSpeedometerData();
42
+ initColorTheme();
43
+ setDataLabelsOptions();
44
+ initSpeedometer();
45
+ };
46
+ const initChartRadius = () => {
47
+ try {
48
+ let positionDominatorName;
49
+ if (innerHeight * 0.8 < innerWidth * 0.45) {
50
+ radius = innerHeight * 0.8;
51
+ positionDominatorName = "width";
52
+ }
53
+ else {
54
+ radius = innerWidth * 0.45;
55
+ positionDominatorName = "height";
56
+ }
57
+ positionTransformString = centerTranslation(positionDominatorName);
58
+ innerRadius = Math.min((convertStringToNumber(chartFormatOptions.plotArea.innerRadius) / 100) *
59
+ radius, radius);
60
+ }
61
+ catch (error) {
62
+ logError(fileName, "initChartRadius", error);
63
+ }
64
+ };
65
+ function centerTranslation(positionDominatorName) {
66
+ try {
67
+ return positionDominatorName == "height"
68
+ ? `translate(${innerWidth / 2},${innerHeight / 2 + radius / 2})`
69
+ : `translate(${innerWidth / 2},${height - 60})`;
70
+ }
71
+ catch (error) {
72
+ logError(fileName, "centerTranslation", error);
73
+ return "";
74
+ }
75
+ }
76
+ const initSpeedometerData = () => {
77
+ try {
78
+ let firstMeasureValue = data[0].data[0].value;
79
+ if (firstMeasureValue < 0) {
80
+ gaugeMaxMeasure = 0;
81
+ gaugeMinMeasure = firstMeasureValue;
82
+ }
83
+ else {
84
+ gaugeMaxMeasure = firstMeasureValue;
85
+ gaugeMinMeasure = 0;
86
+ }
87
+ if (chartFormatOptions.customScaling.customScalingtoggle) {
88
+ calculatedTicksValue = 100;
89
+ }
90
+ else {
91
+ calculatedTicksValue = convertStringToNumber(chartFormatOptions.plotArea.ticks);
92
+ }
93
+ }
94
+ catch (error) {
95
+ logError(fileName, "initSpeedometerData", error);
96
+ }
97
+ };
98
+ const initColorTheme = () => {
99
+ try {
100
+ colorThemeArray = [];
101
+ let customTicksCount = convertStringToNumber(chartFormatOptions.plotArea.ticks);
102
+ if (chartFormatOptions.customScaling.customScalingtoggle) {
103
+ for (let index = 1; index <= customTicksCount; index++) {
104
+ let colorCount = chartFormatOptions.customScaling[`share${index}`];
105
+ if (colorThemeArray.length < 100) {
106
+ for (let innerIndex = 0; innerIndex < colorCount; innerIndex++) {
107
+ colorThemeArray.push(chartFormatOptions.customScaling[`division${index}`]);
108
+ }
109
+ }
110
+ }
111
+ if (colorThemeArray.length < 101) {
112
+ for (let index = colorThemeArray.length; index < 100; index++) {
113
+ colorThemeArray.push("#000000");
114
+ }
115
+ }
116
+ }
117
+ else {
118
+ if ([colorThemeTypes.none, colorThemeTypes.discrete].includes(chartFormatOptions.colorScale.showColor)) {
119
+ for (let index = 1; index <= customTicksCount; index++) {
120
+ colorThemeArray.push(chartFormatOptions.colorScale["division" + index]);
121
+ }
122
+ }
123
+ else {
124
+ let startColor = chartFormatOptions.colorScale.startColor;
125
+ let endColor = chartFormatOptions.colorScale.endColor;
126
+ const colorScale = d3
127
+ .scaleLinear()
128
+ .domain([0, customTicksCount])
129
+ .range([startColor, endColor]);
130
+ for (let index = 0; index < customTicksCount; index++) {
131
+ colorThemeArray.push(colorScale(index));
132
+ }
133
+ }
134
+ }
135
+ }
136
+ catch (error) {
137
+ logError(fileName, "initColorTheme", error);
138
+ }
139
+ };
140
+ const setTickValues = (maxValue, minValue, ticksCount) => {
141
+ try {
142
+ let ticks = [];
143
+ let absoluteValue = Math.abs(maxValue) - Math.abs(minValue);
144
+ let divisionFactor = Math.abs(absoluteValue) / ticksCount;
145
+ let startTickvalue = minValue > 0 ? 0 : minValue;
146
+ ticks.push(startTickvalue);
147
+ for (let i = 0; i < ticksCount - 1; i++) {
148
+ startTickvalue += parseFloat(divisionFactor.toFixed(5));
149
+ if (startTickvalue.toFixed(5) <= Math.abs(maxValue)) {
150
+ ticks.push(startTickvalue);
151
+ }
152
+ }
153
+ ticks.push(ticks.includes(maxValue) ? 0 : maxValue);
154
+ return ticks;
155
+ }
156
+ catch (error) {
157
+ logError(fileName, "setTickValues", error);
158
+ return [];
159
+ }
160
+ };
161
+ const setDataLabelsOptions = () => {
162
+ try {
163
+ let selectedOption = chartFormatOptions.plotArea.dataLabelsOptions;
164
+ switch (selectedOption) {
165
+ case dataLabelPositionType.automatic:
166
+ tickValueArray = initTicksValues();
167
+ break;
168
+ case dataLabelPositionType.startOnly:
169
+ tickValueArray = [gaugeMinMeasure];
170
+ break;
171
+ case dataLabelPositionType.endOnly:
172
+ let tempTicks = Array(calculatedTicksValue).fill("");
173
+ tempTicks[calculatedTicksValue] = gaugeMaxMeasure;
174
+ tickValueArray = tempTicks;
175
+ break;
176
+ case dataLabelPositionType.startAndEndBoth:
177
+ let allTicks = Array(calculatedTicksValue).fill("");
178
+ allTicks[calculatedTicksValue] = gaugeMaxMeasure;
179
+ allTicks[0] = gaugeMinMeasure;
180
+ tickValueArray = allTicks;
181
+ break;
182
+ case dataLabelPositionType.none:
183
+ tickValueArray = [];
184
+ break;
185
+ }
186
+ }
187
+ catch (error) {
188
+ logError(fileName, "setDataLabelsOptions", error);
189
+ }
190
+ };
191
+ const initTicksValues = () => {
192
+ try {
193
+ let tickValueArray;
194
+ let customTicksCount = convertStringToNumber(chartFormatOptions.plotArea.ticks);
195
+ let ticksArray = setTickValues(gaugeMaxMeasure, gaugeMinMeasure, calculatedTicksValue);
196
+ if (chartFormatOptions.customScaling.customScalingtoggle) {
197
+ let tempTicks = Array(100).fill("");
198
+ tempTicks[0] = gaugeMinMeasure;
199
+ let currentShareValue = 0;
200
+ for (let index = 1; index <= customTicksCount; index++) {
201
+ let shareValue = parseInt(chartFormatOptions.customScaling[`share${index}`]);
202
+ currentShareValue += shareValue;
203
+ if (currentShareValue >= 100)
204
+ break;
205
+ tempTicks[currentShareValue] = ticksArray[currentShareValue];
206
+ }
207
+ tempTicks[99] = gaugeMaxMeasure;
208
+ tickValueArray = tempTicks;
209
+ }
210
+ else {
211
+ tickValueArray = ticksArray;
212
+ }
213
+ return tickValueArray;
214
+ }
215
+ catch (error) {
216
+ logError(fileName, "initTicksValues", error);
217
+ return [];
218
+ }
219
+ };
220
+ const initSpeedometer = () => {
221
+ try {
222
+ let gauge = function (container, configuration) {
223
+ try {
224
+ let range, r, pointerHeadLength, value, arc, scale, ticks, tickData, pointer, actualTicks;
225
+ let config = {
226
+ // size: 200,
227
+ clipWidth: innerWidth,
228
+ clipHeight: innerHeight,
229
+ ringInset: 20,
230
+ ringWidth: 20,
231
+ pointerWidth: 10,
232
+ pointerTailLength: 5,
233
+ pointerHeadLengthPercent: convertStringToNumber(chartFormatOptions.plotArea.pointerHeadLength) / 10,
234
+ minValue: gaugeMinMeasure,
235
+ maxValue: gaugeMaxMeasure,
236
+ minAngle: -90,
237
+ maxAngle: 90,
238
+ transitionMs: 0,
239
+ majorTicks: calculatedTicksValue,
240
+ labelFormat: (d) => getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(d),
241
+ labelInset: -5,
242
+ };
243
+ function deg2rad(deg) {
244
+ try {
245
+ return (deg * Math.PI) / 180;
246
+ }
247
+ catch (error) {
248
+ logError(fileName, "deg2rad", error);
249
+ return 0;
250
+ }
251
+ }
252
+ function configure(configuration) {
253
+ try {
254
+ let prop = undefined;
255
+ for (prop in configuration) {
256
+ config[prop] = configuration[prop];
257
+ }
258
+ range = config.maxAngle - config.minAngle;
259
+ pointerHeadLength = Math.round(radius * config.pointerHeadLengthPercent);
260
+ scale = d3
261
+ .scaleLinear()
262
+ .range([0, 1])
263
+ .domain([config.minValue, config.maxValue]);
264
+ arc = d3
265
+ .arc()
266
+ .innerRadius(innerRadius)
267
+ .outerRadius(radius)
268
+ .startAngle((d, i) => {
269
+ let ratio = (1 / config.majorTicks) * i;
270
+ return deg2rad(config.minAngle + ratio * range);
271
+ })
272
+ .endAngle((d, i) => {
273
+ let ratio = (1 / config.majorTicks) * (i + 1);
274
+ return deg2rad(config.minAngle + ratio * range);
275
+ });
276
+ }
277
+ catch (error) {
278
+ logError(fileName, "configure", error);
279
+ }
280
+ }
281
+ function render(newValue, index) {
282
+ try {
283
+ if (index === 0) {
284
+ let arcs = chartAreaTagG
285
+ .append("g")
286
+ .attr("class", "arc")
287
+ .attr("transform", positionTransformString);
288
+ arcs
289
+ .selectAll("path")
290
+ .data(colorThemeArray)
291
+ .enter()
292
+ .append("path")
293
+ .attr("fill", (d) => d)
294
+ .attr("stroke", (d) => d)
295
+ .attr("d", arc);
296
+ let max = gaugeMaxMeasure;
297
+ let lg = chartAreaTagG
298
+ .append("g")
299
+ .attr("class", "label")
300
+ .attr("transform", positionTransformString);
301
+ lg.selectAll("text")
302
+ .data(tickValueArray)
303
+ .enter()
304
+ .append("text")
305
+ .attr("transform", function (d, i) {
306
+ let factor = (range / config.majorTicks) * i;
307
+ let newAngle = config.minAngle + factor;
308
+ return ("rotate(" +
309
+ newAngle +
310
+ ") translate(0," +
311
+ (config.labelInset - radius) +
312
+ ")");
313
+ })
314
+ .attr("text-anchor", "middle")
315
+ .attr("font-size", chartFormatOptions.plotArea.dataLabelValueFontSize)
316
+ .attr("fill", chartFormatOptions.plotArea.dataLabelValueColor !==
317
+ "#ffffff"
318
+ ? chartFormatOptions.plotArea.dataLabelValueColor
319
+ : "none")
320
+ .attr("font-style", chartFormatOptions.plotArea.dataLabelValueFontStyle.includes(fontStyleOptions.italic)
321
+ ? fontStyleOptions.italic
322
+ : "")
323
+ .attr("text-decoration", chartFormatOptions.plotArea.dataLabelValueFontStyle.includes(fontStyleOptions.underline)
324
+ ? fontStyleOptions.underline
325
+ : "")
326
+ .attr("font-weight", chartFormatOptions.plotArea.dataLabelValueFontStyle.includes(fontStyleOptions.bold)
327
+ ? fontStyleOptions.bold
328
+ : "")
329
+ .attr("font-family", chartFormatOptions.plotArea.dataLabelValueFontFamily)
330
+ .text((d) => chartFormatOptions.plotArea.dataLabelNumberFormat == ",.0%"
331
+ ? (value = Math.round((d / max) * 100) + "%")
332
+ : getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(d))
333
+ .attr("visibility", (d) => (d === "" ? "hidden" : "visible"));
334
+ }
335
+ if (chartFormatOptions.pointerValue.showPointerValue &&
336
+ data.length === 2) {
337
+ setPointerValueText(positionTransformString);
338
+ }
339
+ let lineData = [
340
+ [config.pointerWidth / 2, 0],
341
+ [0, -pointerHeadLength],
342
+ [-(config.pointerWidth / 2), 0],
343
+ [0, config.pointerTailLength],
344
+ [config.pointerWidth / 2, 0],
345
+ ];
346
+ let pointerLine = d3.line().curve(d3.curveLinear);
347
+ let pg = chartAreaTagG
348
+ .append("g")
349
+ .data([lineData])
350
+ .attr("class", "pointer")
351
+ .attr("transform", positionTransformString);
352
+ pointer = pg
353
+ .append("path")
354
+ .attr("d", index > 0 ? pointerLine : null)
355
+ .attr("transform", "rotate(" + config.minAngle + ")")
356
+ .attr("fill", chartFormatOptions.plotArea.pointerColor)
357
+ .on("mousemove", (d, i) => {
358
+ showTooltipOnMouseMove([
359
+ {
360
+ key: `${data[index].data[0].legend}`,
361
+ value: chartFormatOptions.plotArea.dataLabelNumberFormat ==
362
+ ",.0%"
363
+ ? Math.round((data[index].data[0].value /
364
+ ticks[ticks.length - 1]) *
365
+ 100) + "%"
366
+ : getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip
367
+ .toolTipDecimalPrecision)(data[index].data[0].value),
368
+ },
369
+ ], chartFormatOptions);
370
+ })
371
+ .on("mouseout", () => {
372
+ hideTooltipOnMouseOut();
373
+ });
374
+ pointer.selectAll("text").append("text").text(config.maxValue);
375
+ update(newValue === undefined ? 0 : newValue);
376
+ }
377
+ catch (error) {
378
+ logError(fileName, "gauge.render", error);
379
+ }
380
+ }
381
+ function update(newValue, newConfiguration) {
382
+ try {
383
+ if (newConfiguration !== undefined) {
384
+ configure(newConfiguration);
385
+ }
386
+ let ratio = scale(newValue);
387
+ let newAngle = config.minAngle + ratio * range;
388
+ pointer
389
+ .transition()
390
+ .duration(config.transitionMs)
391
+ .ease(d3.easeElastic)
392
+ .attr("transform", "rotate(" + newAngle + ")");
393
+ }
394
+ catch (error) {
395
+ logError(fileName, "gauge.update", error);
396
+ }
397
+ }
398
+ gaugemap.configure = configure;
399
+ gaugemap.render = render;
400
+ gaugemap.update = update;
401
+ configure(configuration);
402
+ return gaugemap;
403
+ }
404
+ catch (error) {
405
+ logError(fileName, "gauge", error);
406
+ }
407
+ };
408
+ let powerGauge = gauge("#power-gauge", {
409
+ clipWidth: innerWidth,
410
+ clipHeight: innerHeight,
411
+ ringWidth: 2.75 *
412
+ convertStringToNumber(chartFormatOptions.plotArea.innerRadiusForSpeedometer),
413
+ ringInset: 20,
414
+ maxValue: gaugeMaxMeasure,
415
+ transitionMs: 0,
416
+ });
417
+ if (data.length > 0) {
418
+ for (let i = 0; i < data.length; i++)
419
+ powerGauge.render(setPointerofSpeedometer(data[i], i), i);
420
+ }
421
+ }
422
+ catch (error) {
423
+ logError(fileName, "initSpeedometer", error);
424
+ }
425
+ };
426
+ function setPointerofSpeedometer(chartData, i) {
427
+ try {
428
+ let scale = gaugeMaxMeasure;
429
+ let target = chartData.data[0].value;
430
+ if ((scale < 0 && target > 0) || (scale > 0 && target < 0)) {
431
+ return 0;
432
+ }
433
+ else if (scale < 0 && target < 0 && scale > target) {
434
+ return scale;
435
+ }
436
+ else if (scale < 0 && target < 0 && scale < target) {
437
+ return target;
438
+ }
439
+ return scale > target ? target : scale;
440
+ }
441
+ catch (error) {
442
+ logError(fileName, "setPointerofSpeedometer", error);
443
+ return 0;
444
+ }
445
+ }
446
+ function setPointerValueText(positionTransformString) {
447
+ try {
448
+ let KPIName = "";
449
+ if (chartFormatOptions.pointerValue.kpiAlias) {
450
+ KPIName = chartFormatOptions.pointerValue.kpiAliasText;
451
+ }
452
+ else {
453
+ switch (chartFormatOptions.pointerValue.connectorKPIforSpeedometer) {
454
+ case connectorKPIforSpeedometerType.PointerValue:
455
+ KPIName = "Pointer Value";
456
+ break;
457
+ case connectorKPIforSpeedometerType.Absolute:
458
+ KPIName = "Absolute Value";
459
+ break;
460
+ case connectorKPIforSpeedometerType.CAGR:
461
+ KPIName = "CAGR";
462
+ break;
463
+ case connectorKPIforSpeedometerType.PercentageGrowth:
464
+ KPIName = "Percentage Growth";
465
+ break;
466
+ }
467
+ }
468
+ let valuefontStyle = chartFormatOptions.pointerValue.pointerValueFontStyle;
469
+ let comparedValue = chartAreaTagG
470
+ .append("g")
471
+ .attr("class", "label")
472
+ .attr("transform", positionTransformString);
473
+ comparedValue
474
+ .selectAll("text")
475
+ .data(["chartData.dataArray[1].maximumMeasure"])
476
+ .enter()
477
+ .append("text")
478
+ .attr("dy", "24")
479
+ .attr("text-anchor", "middle") //(d,i)=> i === ticks.length ? "end" :
480
+ .attr("font-size", chartFormatOptions.pointerValue.pointerValueFontSize)
481
+ .attr("fill", chartFormatOptions.pointerValue.pointerValueColor !== "#ffffff"
482
+ ? chartFormatOptions.pointerValue.pointerValueColor
483
+ : "none")
484
+ .attr("font-style", valuefontStyle.includes(fontStyleOptions.italic)
485
+ ? fontStyleOptions.italic
486
+ : "")
487
+ .attr("text-decoration", valuefontStyle.includes(fontStyleOptions.underline)
488
+ ? fontStyleOptions.underline
489
+ : "")
490
+ .attr("font-weight", valuefontStyle.includes(fontStyleOptions.bold)
491
+ ? fontStyleOptions.bold
492
+ : "")
493
+ .attr("font-family", chartFormatOptions.pointerValue.pointerValueFontFamily)
494
+ .text((d) => `${KPIName}: ${!chartFormatOptions.pointerValue.pointerValueAlias || d != 0
495
+ ? getNumberWithFormatFunction("None", chartFormatOptions.pointerValue.pointerValueNumberFormat, chartFormatOptions.pointerValue.pointerValueDecimalPrecision)(data[1].data[0].value)
496
+ : chartFormatOptions.pointerValue.pointerValueAliasText}`)
497
+ .attr("visibility", chartFormatOptions.plotArea.dataLabels ? "visible" : "hidden");
498
+ }
499
+ catch (error) {
500
+ logError(fileName, "setPointerValueText", error);
501
+ }
502
+ }
503
+ // return (
504
+ // <div style={{ width: "100%", height: "100%" }}>
505
+ // <svg
506
+ // className="chartSVG"
507
+ // style={{ width: "100%", height: "100%" }}
508
+ // ref={svgRef}
509
+ // ></svg>
510
+ // </div>
511
+ // );
512
+ 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%" } })] }));
513
+ };
514
+ export default Speedometer;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { IVennChartProps } from "../ChartsWithoutAxisTypes.types";
3
+ declare const VennChart: React.FC<IVennChartProps>;
4
+ export default VennChart;