pace-chart-lib 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +76 -38
- package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +4 -2
- package/dist/{components → Components}/Charts/Core/CommonFunctions.d.ts +3 -1
- package/dist/{components → Components}/Charts/Core/DefaultProperties.types.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/pace-chart-lib.es.js +54619 -0
- package/dist/pace-chart-lib.umd.js +54622 -0
- package/dist/vite.svg +1 -0
- package/package.json +1 -1
- package/dist/Services/ErrorLog.js +0 -3
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +0 -496
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +0 -491
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +0 -517
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +0 -553
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +0 -517
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +0 -553
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -4909
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +0 -49
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +0 -486
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +0 -418
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +0 -1013
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +0 -478
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +0 -451
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +0 -533
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +0 -512
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +0 -530
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +0 -512
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +0 -12
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +0 -9
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +0 -497
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +0 -479
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +0 -478
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +0 -473
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +0 -465
- package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -451
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +0 -554
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +0 -510
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +0 -4
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +0 -507
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +0 -393
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +0 -606
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -815
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +0 -32
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +0 -15021
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +0 -391
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +0 -367
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +0 -570
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +0 -212
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +0 -401
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +0 -313
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +0 -719
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +0 -807
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +0 -514
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +0 -282
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +0 -207
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +0 -476
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +0 -420
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +0 -106
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +0 -507
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +0 -246
- package/dist/components/Charts/Core/Common.type.d.ts +0 -0
- package/dist/components/Charts/Core/Common.type.js +0 -0
- package/dist/components/Charts/Core/Common.types.js +0 -133
- package/dist/components/Charts/Core/CommonFunctions.js +0 -1782
- package/dist/components/Charts/Core/DefaultChartDataProperties.js +0 -64
- package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
- package/dist/components/Charts/Core/DefaultProperties.js +0 -0
- package/dist/components/Charts/Core/DefaultProperties.type.d.ts +0 -586
- package/dist/components/Charts/Core/DefaultProperties.type.js +0 -585
- package/dist/components/Charts/Core/DefaultProperties.types.js +0 -592
- package/dist/index.js +0 -40
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -0
- /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/NormalizedStackLineChart.d.ts +0 -0
- /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/StackLineChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +0 -0
- /package/dist/{components → Components}/Charts/Core/Common.types.d.ts +0 -0
- /package/dist/{components → Components}/Charts/Core/DefaultChartDataProperties.d.ts +0 -0
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Additional Features for future implementation:,
|
|
3
|
-
// 1) Custom end Angle
|
|
4
|
-
// 2) Custom arc end radius
|
|
5
|
-
// 3) Data Labels outside the arc
|
|
6
|
-
//#region imports
|
|
7
|
-
import * as d3 from "d3";
|
|
8
|
-
import { useEffect, useRef } from "react";
|
|
9
|
-
import { fontStyleOptions, } from "../../Core/Common.types";
|
|
10
|
-
import { calculateLegendsMaxPossibleWidth, convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, generalizedChartData, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initLegendListWithTotalValueAllowance, initSvg, marginCalculationsForChartsWithoutAxis, preCalculateTextDimensions, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
11
|
-
import { chartMargins } from "../../Core/DefaultProperties.types";
|
|
12
|
-
//#endregion
|
|
13
|
-
// Dummy logError function for demonstration
|
|
14
|
-
function logError(fileName, functionName, error) {
|
|
15
|
-
console.error(`[${fileName}][${functionName}]`, error);
|
|
16
|
-
}
|
|
17
|
-
const RadialBarChart = ({ data, formatOptions, chartId, }) => {
|
|
18
|
-
const svgRef = useRef(); // Reference to the SVG element
|
|
19
|
-
const seriesData = generalizedChartData(data.ChartData); // Input data for the chart, expected to be in TSeries format
|
|
20
|
-
let chartFormatOptions; // Data for the pie chart, expected to be in TSeries format
|
|
21
|
-
let width; // svg total width
|
|
22
|
-
let height; // svg total height
|
|
23
|
-
let chartTitleHeight = 40; // Height of the chart title
|
|
24
|
-
let margins = chartMargins; // Margins for the chart
|
|
25
|
-
let maxLegendDimensions = [0, 0]; // to calculate margins [width, height]
|
|
26
|
-
let innerHeight; // Height of the chart excluding margins
|
|
27
|
-
let innerWidth; // Width of the chart excluding margins
|
|
28
|
-
let radius; // Radius of the pie chart
|
|
29
|
-
let chartAreaTagG;
|
|
30
|
-
let svg;
|
|
31
|
-
let pieTotalValue; // Required for % calculations also appeding total to svg
|
|
32
|
-
let legendListWidth; // Width of the legend list
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
drawChart();
|
|
35
|
-
}, [formatOptions]);
|
|
36
|
-
const drawChart = () => {
|
|
37
|
-
({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
|
|
38
|
-
loopOverChartData();
|
|
39
|
-
({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } =
|
|
40
|
-
marginCalculationsForChartsWithoutAxis(chartFormatOptions, width, height, maxLegendDimensions, margins));
|
|
41
|
-
maxLegendDimensions = calculateLegendsMaxPossibleWidth(chartFormatOptions, seriesData);
|
|
42
|
-
initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
|
|
43
|
-
chartAreaTagG = initChartArea(svg, margins);
|
|
44
|
-
drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
|
|
45
|
-
initLegendListWithTotalValueAllowance(chartFormatOptions, svg, seriesData, width, height, legendListWidth, chartTitleHeight, chartId, margins);
|
|
46
|
-
initRadialBarChart();
|
|
47
|
-
};
|
|
48
|
-
const loopOverChartData = () => {
|
|
49
|
-
try {
|
|
50
|
-
pieTotalValue = 0;
|
|
51
|
-
seriesData.forEach((d) => {
|
|
52
|
-
pieTotalValue += d.data[0].value;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
logError("RadialBarChart.tsx", "loopOverChartData", error);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const initRadialBarChart = () => {
|
|
60
|
-
try {
|
|
61
|
-
let scaleMaxValue = seriesData.length > 1
|
|
62
|
-
? d3.max(seriesData, (d) => d.data[0].value) * 1.1
|
|
63
|
-
: data[0].data[0].value * 1.1;
|
|
64
|
-
let valuefontStyle = chartFormatOptions.plotArea.dataLabelValueFontStyle;
|
|
65
|
-
let maxDim = getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.axialAxisDataLabelNumberFormat, chartFormatOptions.plotArea.axialAxisDataLabelDecimalPrecision)(scaleMaxValue);
|
|
66
|
-
let maxWidth = chartFormatOptions.plotArea.axialAxis
|
|
67
|
-
? preCalculateTextDimensions(maxDim, convertStringToNumber(chartFormatOptions.plotArea.axialAxisDataLabelFontSize), chartFormatOptions.plotArea.axialAxisDataLabelFontFamily).width + 10
|
|
68
|
-
: 20;
|
|
69
|
-
const chartRadius = Math.min(innerHeight * 0.5, innerWidth * 0.5) - maxWidth;
|
|
70
|
-
let svg = chartAreaTagG
|
|
71
|
-
.append("g")
|
|
72
|
-
.attr("transform", getPiePosition())
|
|
73
|
-
.attr("width", innerWidth)
|
|
74
|
-
.attr("height", innerHeight);
|
|
75
|
-
const piConstant = Math.PI, arcMinRadius = seriesData.length > 1 ? 10 : 70, arcPadding = convertStringToNumber(chartFormatOptions.plotArea.arcPadding), numTicks = convertStringToNumber(chartFormatOptions.plotArea.axialTicks);
|
|
76
|
-
let scale = d3
|
|
77
|
-
.scaleLinear()
|
|
78
|
-
.domain([0, scaleMaxValue])
|
|
79
|
-
.range([0, degToRad(360)]);
|
|
80
|
-
let tempTicks = scale.ticks(numTicks);
|
|
81
|
-
if (tempTicks[tempTicks.length - 1] == scaleMaxValue) {
|
|
82
|
-
tempTicks.pop(); // remove the last tick if it equals the max value which will ovelap with 0 value
|
|
83
|
-
}
|
|
84
|
-
let ticks = tempTicks;
|
|
85
|
-
let keys = seriesData.map((d, i) => d.data[0].legend);
|
|
86
|
-
let sumofmeasure = seriesData.reduce((accumulator, currentValue) => accumulator + currentValue.data[0].value, 0);
|
|
87
|
-
const numArcs = keys.length;
|
|
88
|
-
const arcWidth = (chartRadius - arcMinRadius - numArcs * arcPadding) / numArcs;
|
|
89
|
-
let arc = d3
|
|
90
|
-
.arc()
|
|
91
|
-
.innerRadius((d, i) => getInnerRadius(i))
|
|
92
|
-
.outerRadius((d, i) => getOuterRadius(i))
|
|
93
|
-
.startAngle(0)
|
|
94
|
-
.endAngle((d) => scale(Math.abs(d.data[0].value)));
|
|
95
|
-
// .cornerRadius(chartFormatOptions.plotArea.cornerRadius); // Future implementation
|
|
96
|
-
let dummyArc = d3
|
|
97
|
-
.arc()
|
|
98
|
-
.innerRadius((d, i) => getInnerRadius(i))
|
|
99
|
-
.outerRadius((d, i) => getOuterRadius(i))
|
|
100
|
-
.startAngle(0)
|
|
101
|
-
.endAngle(degToRad(360));
|
|
102
|
-
// Radial axis
|
|
103
|
-
let radialAxis = svg
|
|
104
|
-
.append("g")
|
|
105
|
-
.attr("class", "r axis")
|
|
106
|
-
.selectAll("g")
|
|
107
|
-
.data(data)
|
|
108
|
-
.enter()
|
|
109
|
-
.append("g");
|
|
110
|
-
if (chartFormatOptions.plotArea.axialGrid) {
|
|
111
|
-
radialAxis
|
|
112
|
-
.append("circle")
|
|
113
|
-
.attr("r", (d, i) => getOuterRadius(i) + arcPadding)
|
|
114
|
-
.attr("stroke", "#d3d3d3")
|
|
115
|
-
.attr("stroke-width", 1)
|
|
116
|
-
.attr("fill", "none");
|
|
117
|
-
}
|
|
118
|
-
// Axial axis
|
|
119
|
-
let axialAxis = svg
|
|
120
|
-
.append("g")
|
|
121
|
-
.attr("class", "a axis")
|
|
122
|
-
.selectAll("g")
|
|
123
|
-
.data(ticks)
|
|
124
|
-
.enter()
|
|
125
|
-
.append("g")
|
|
126
|
-
.attr("transform", (d) => "rotate(" + (radTodeg(scale(d)) - 90) + ")");
|
|
127
|
-
if (chartFormatOptions.plotArea.axialGrid) {
|
|
128
|
-
axialAxis
|
|
129
|
-
.append("line")
|
|
130
|
-
.attr("x2", chartRadius)
|
|
131
|
-
.attr("stroke", "#a9a9a9")
|
|
132
|
-
.attr("stroke-width", 1);
|
|
133
|
-
}
|
|
134
|
-
axialAxis
|
|
135
|
-
.append("text")
|
|
136
|
-
.attr("x", chartRadius + 10)
|
|
137
|
-
.attr("class", "text-xs text-gray-600")
|
|
138
|
-
.style("text-anchor", (d) => scale(d) >= piConstant && scale(d) < 2 * piConstant ? "end" : null)
|
|
139
|
-
.attr("transform", (d) => "rotate(" +
|
|
140
|
-
(90 - radTodeg(scale(d))) +
|
|
141
|
-
"," +
|
|
142
|
-
(chartRadius + 10) +
|
|
143
|
-
",0)")
|
|
144
|
-
.text((d) => getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.axialAxisDataLabelNumberFormat, chartFormatOptions.plotArea.axialAxisDataLabelDecimalPrecision)(d))
|
|
145
|
-
.attr("fill", chartFormatOptions.plotArea.axialAxisDataLabelColor !== "#ffffff"
|
|
146
|
-
? chartFormatOptions.plotArea.axialAxisDataLabelColor
|
|
147
|
-
: "none")
|
|
148
|
-
.style("font-size", chartFormatOptions.plotArea.axialAxisDataLabelFontSize)
|
|
149
|
-
.style("font-family", chartFormatOptions.plotArea.axialAxisDataLabelFontFamily)
|
|
150
|
-
.attr("font-style", chartFormatOptions.plotArea.axialAxisDataLabelFontStyle.includes(fontStyleOptions.italic)
|
|
151
|
-
? fontStyleOptions.italic
|
|
152
|
-
: "")
|
|
153
|
-
.attr("text-decoration", chartFormatOptions.plotArea.axialAxisDataLabelFontStyle.includes(fontStyleOptions.underline)
|
|
154
|
-
? fontStyleOptions.underline
|
|
155
|
-
: "")
|
|
156
|
-
.attr("font-weight", chartFormatOptions.plotArea.axialAxisDataLabelFontStyle.includes(fontStyleOptions.bold)
|
|
157
|
-
? fontStyleOptions.bold
|
|
158
|
-
: "")
|
|
159
|
-
.attr("visibility", chartFormatOptions.plotArea.axialAxis ? "visible" : "hidden");
|
|
160
|
-
// Data arcs
|
|
161
|
-
let arcs = svg
|
|
162
|
-
.attr("class", "data")
|
|
163
|
-
.selectAll("path")
|
|
164
|
-
.data(data)
|
|
165
|
-
.enter()
|
|
166
|
-
.append("path")
|
|
167
|
-
.attr("class", "parentGroup")
|
|
168
|
-
.attr("hoverId", (d) => d.data[0].legend)
|
|
169
|
-
.style("fill", (d, i) => d.properties.color)
|
|
170
|
-
.on("mousemove", (event, d) => {
|
|
171
|
-
showTooltipOnMouseMove([
|
|
172
|
-
{
|
|
173
|
-
key: chartFormatOptions.yAxisTitle.yAxisTitleText,
|
|
174
|
-
value: chartFormatOptions.toolTip.toolTipNumberFormatProgress ==
|
|
175
|
-
",.0%"
|
|
176
|
-
? (Math.abs(d.data[0].value / sumofmeasure) * 100).toFixed(convertStringToNumber(chartFormatOptions.toolTip.toolTipDecimalPrecision)) + "%"
|
|
177
|
-
: getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormatProgress, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.data[0].value),
|
|
178
|
-
},
|
|
179
|
-
{ key: "Legend", value: d.properties.alias },
|
|
180
|
-
], chartFormatOptions);
|
|
181
|
-
})
|
|
182
|
-
.on("mouseout", () => {
|
|
183
|
-
hideTooltipOnMouseOut();
|
|
184
|
-
});
|
|
185
|
-
arcs
|
|
186
|
-
.transition()
|
|
187
|
-
.delay((d, i) => chartFormatOptions.plotArea.arcTransition ? i * 200 : 0)
|
|
188
|
-
.duration(chartFormatOptions.plotArea.arcTransition ? 500 : 0)
|
|
189
|
-
.attrTween("d", arcTween);
|
|
190
|
-
// Adding data labels along the arcs
|
|
191
|
-
if (chartFormatOptions.plotArea.dataLabels) {
|
|
192
|
-
svg
|
|
193
|
-
.selectAll(".arc-label-" + chartId)
|
|
194
|
-
.data(data)
|
|
195
|
-
.enter()
|
|
196
|
-
.append("text")
|
|
197
|
-
.attr("class", "arc-label-" + chartId)
|
|
198
|
-
.attr("class", "parentGroup")
|
|
199
|
-
.attr("text-anchor", "start")
|
|
200
|
-
.attr("dy", (d, i) => (getOuterRadius(i) - getInnerRadius(i)) / 1.75)
|
|
201
|
-
.append("textPath")
|
|
202
|
-
.attr("xlink:href", (d, i) => `#arc-path-${i}-` + chartId)
|
|
203
|
-
.style("startOffset", "50%") // Center the text
|
|
204
|
-
.attr("hoverId", (d) => d.legend.replaceAll(" ", "-")) // Center the text
|
|
205
|
-
.text((d) => `\u00A0\u00A0${d.properties.alias}
|
|
206
|
-
\u00A0${chartFormatOptions.plotArea.dataLabelValue
|
|
207
|
-
? getNumberWithFormatFunction(chartFormatOptions.plotArea.plotAreaDisplayUnits, chartFormatOptions.plotArea.dataLabelNumberFormat, chartFormatOptions.plotArea.dataLabelDecimalPrecision)(d.data[0].value)
|
|
208
|
-
: ""}`)
|
|
209
|
-
.attr("fill", chartFormatOptions.plotArea.dataLabelValueColor !== "#ffffff"
|
|
210
|
-
? chartFormatOptions.plotArea.dataLabelValueColor
|
|
211
|
-
: "none")
|
|
212
|
-
.style("font-size", chartFormatOptions.plotArea.dataLabelValueFontSize)
|
|
213
|
-
.style("font-family", chartFormatOptions.plotArea.dataLabelValueFontFamily)
|
|
214
|
-
.attr("font-style", valuefontStyle.includes(fontStyleOptions.italic)
|
|
215
|
-
? fontStyleOptions.italic
|
|
216
|
-
: "")
|
|
217
|
-
.attr("text-decoration", valuefontStyle.includes(fontStyleOptions.underline)
|
|
218
|
-
? fontStyleOptions.underline
|
|
219
|
-
: "")
|
|
220
|
-
.attr("font-weight", valuefontStyle.includes(fontStyleOptions.bold)
|
|
221
|
-
? fontStyleOptions.bold
|
|
222
|
-
: "")
|
|
223
|
-
.on("mousemove", (mouseEvent, d) => {
|
|
224
|
-
showTooltipOnMouseMove([
|
|
225
|
-
{
|
|
226
|
-
key: chartFormatOptions.yAxisTitle.yAxisTitleText,
|
|
227
|
-
value: getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.data[0].value),
|
|
228
|
-
},
|
|
229
|
-
{ key: "Legend", value: d.properties.alias },
|
|
230
|
-
], chartFormatOptions);
|
|
231
|
-
})
|
|
232
|
-
.on("mouseout", () => {
|
|
233
|
-
hideTooltipOnMouseOut();
|
|
234
|
-
});
|
|
235
|
-
// Create invisible paths for text to follow
|
|
236
|
-
arcs.each((d, i) => {
|
|
237
|
-
svg
|
|
238
|
-
.append("path")
|
|
239
|
-
.attr("id", `arc-path-${i}-` + chartId)
|
|
240
|
-
.attr("d", dummyArc(d, i)) // Draw the arc path
|
|
241
|
-
.style("fill", "none")
|
|
242
|
-
.style("stroke", "none");
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
function arcTween(d, i) {
|
|
246
|
-
try {
|
|
247
|
-
let interpolate = d3.interpolate({ endAngle: 0 }, { endAngle: scale(Math.abs(d.data[0].value)) });
|
|
248
|
-
return (t) => arc({
|
|
249
|
-
...d,
|
|
250
|
-
endAngle: interpolate(t),
|
|
251
|
-
}, i);
|
|
252
|
-
}
|
|
253
|
-
catch (error) {
|
|
254
|
-
logError("RadialBarChart.tsx", "arcTween", error);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function radTodeg(angle) {
|
|
258
|
-
try {
|
|
259
|
-
return (angle * 180) / piConstant;
|
|
260
|
-
}
|
|
261
|
-
catch (error) {
|
|
262
|
-
logError("RadialBarChart.tsx", "radTodeg", error);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
function degToRad(deg) {
|
|
266
|
-
try {
|
|
267
|
-
return (deg * Math.PI) / 180;
|
|
268
|
-
}
|
|
269
|
-
catch (error) {
|
|
270
|
-
logError("RadialBarChart.tsx", "degToRad", error);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
function getInnerRadius(index) {
|
|
274
|
-
try {
|
|
275
|
-
return (arcMinRadius + (numArcs - (index + 1)) * (arcWidth + arcPadding));
|
|
276
|
-
}
|
|
277
|
-
catch (error) {
|
|
278
|
-
logError("RadialBarChart.tsx", "getInnerRadius", error);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
function getOuterRadius(index) {
|
|
282
|
-
try {
|
|
283
|
-
return getInnerRadius(index) + arcWidth;
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
logError("RadialBarChart.tsx", "getOuterRadius", error);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
catch (error) {
|
|
291
|
-
logError("RadialBarChart.tsx", "initRadialBarChart", error);
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
const getPiePosition = () => {
|
|
295
|
-
try {
|
|
296
|
-
return `translate(${innerWidth / 2},${innerHeight / 2})`;
|
|
297
|
-
}
|
|
298
|
-
catch (error) {
|
|
299
|
-
logError("RadialBarChart.tsx", "getPiePosition", error);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
// return (
|
|
303
|
-
// <div style={{ width: "100%", height: "100%" }}>
|
|
304
|
-
// <svg
|
|
305
|
-
// className="chartSVG"
|
|
306
|
-
// style={{ width: "100%", height: "100%" }}
|
|
307
|
-
// ref={svgRef}
|
|
308
|
-
// ></svg>
|
|
309
|
-
// </div>
|
|
310
|
-
// );
|
|
311
|
-
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%" } })] }));
|
|
312
|
-
};
|
|
313
|
-
export default RadialBarChart;
|