pace-chart-lib 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +76 -38
  2. package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +4 -2
  3. package/dist/{components → Components}/Charts/Core/CommonFunctions.d.ts +3 -1
  4. package/dist/{components → Components}/Charts/Core/DefaultProperties.types.d.ts +2 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/pace-chart-lib.es.js +54619 -0
  7. package/dist/pace-chart-lib.umd.js +54622 -0
  8. package/dist/vite.svg +1 -0
  9. package/package.json +1 -1
  10. package/dist/Services/ErrorLog.js +0 -3
  11. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +0 -496
  12. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +0 -4
  13. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +0 -491
  14. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +0 -517
  15. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +0 -4
  16. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +0 -553
  17. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +0 -517
  18. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +0 -4
  19. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +0 -553
  20. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
  21. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
  22. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -4909
  23. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
  24. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
  25. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +0 -49
  26. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +0 -4
  27. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +0 -486
  28. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +0 -497
  29. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +0 -418
  30. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +0 -1013
  31. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +0 -478
  32. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +0 -4
  33. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +0 -451
  34. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +0 -533
  35. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +0 -512
  36. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +0 -530
  37. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +0 -512
  38. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +0 -12
  39. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +0 -9
  40. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +0 -497
  41. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +0 -497
  42. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +0 -4
  43. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +0 -479
  44. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +0 -478
  45. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +0 -473
  46. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +0 -465
  47. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
  48. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
  49. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -451
  50. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +0 -4
  51. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +0 -554
  52. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +0 -4
  53. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +0 -510
  54. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +0 -4
  55. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +0 -507
  56. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +0 -393
  57. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +0 -606
  58. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
  59. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
  60. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -815
  61. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  62. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  63. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +0 -32
  64. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +0 -15021
  65. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +0 -391
  66. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +0 -367
  67. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +0 -570
  68. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +0 -212
  69. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +0 -401
  70. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +0 -313
  71. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +0 -719
  72. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +0 -807
  73. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +0 -514
  74. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +0 -282
  75. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +0 -207
  76. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +0 -476
  77. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +0 -420
  78. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +0 -106
  79. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +0 -507
  80. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +0 -246
  81. package/dist/components/Charts/Core/Common.type.d.ts +0 -0
  82. package/dist/components/Charts/Core/Common.type.js +0 -0
  83. package/dist/components/Charts/Core/Common.types.js +0 -133
  84. package/dist/components/Charts/Core/CommonFunctions.js +0 -1782
  85. package/dist/components/Charts/Core/DefaultChartDataProperties.js +0 -64
  86. package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
  87. package/dist/components/Charts/Core/DefaultProperties.js +0 -0
  88. package/dist/components/Charts/Core/DefaultProperties.type.d.ts +0 -586
  89. package/dist/components/Charts/Core/DefaultProperties.type.js +0 -585
  90. package/dist/components/Charts/Core/DefaultProperties.types.js +0 -592
  91. package/dist/index.js +0 -40
  92. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +0 -0
  93. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +0 -0
  94. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +0 -0
  95. /package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +0 -0
  96. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +0 -0
  97. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +0 -0
  98. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +0 -0
  99. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +0 -0
  100. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +0 -0
  101. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +0 -0
  102. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +0 -0
  103. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +0 -0
  104. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +0 -0
  105. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +0 -0
  106. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +0 -0
  107. /package/dist/{components → Components}/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -0
  108. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/NormalizedStackLineChart.d.ts +0 -0
  109. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/StackLineChart.d.ts +0 -0
  110. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +0 -0
  111. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +0 -0
  112. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  113. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +0 -0
  114. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +0 -0
  115. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +0 -0
  116. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +0 -0
  117. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +0 -0
  118. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +0 -0
  119. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +0 -0
  120. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +0 -0
  121. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +0 -0
  122. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +0 -0
  123. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +0 -0
  124. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +0 -0
  125. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +0 -0
  126. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +0 -0
  127. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +0 -0
  128. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +0 -0
  129. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +0 -0
  130. /package/dist/{components → Components}/Charts/Core/Common.types.d.ts +0 -0
  131. /package/dist/{components → Components}/Charts/Core/DefaultChartDataProperties.d.ts +0 -0
@@ -1,514 +0,0 @@
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.ChartData);
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
- seriesData.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 (seriesData.length > 0) {
418
- for (let i = 0; i < seriesData.length; i++)
419
- powerGauge.render(setPointerofSpeedometer(seriesData[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;