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.
- package/README.md +10 -54
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +46 -0
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +2285 -0
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +169 -0
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +47 -0
- package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +4 -0
- package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.js +403 -0
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -0
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
- package/dist/Components1/Charts/Core/Common.type.d.ts +8 -0
- package/dist/Components1/Charts/Core/Common.type.js +9 -0
- package/dist/Components1/Charts/Core/CommonFunctions.d.ts +12 -0
- package/dist/Components1/Charts/Core/CommonFunctions.js +512 -0
- package/dist/Components1/Charts/Core/DefaultProperties.d.ts +586 -0
- package/dist/Components1/Charts/Core/DefaultProperties.js +585 -0
- package/dist/Services/ErrorLog.d.ts +1 -0
- package/dist/Services/ErrorLog.js +3 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +497 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +491 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +520 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +553 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +519 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +553 -0
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +12 -0
- package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +9 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +623 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +4897 -0
- 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.d.ts +173 -0
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +49 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +486 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +498 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +417 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +1014 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +479 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +451 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +535 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +512 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +532 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +512 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +12 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +9 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +498 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +498 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +479 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +479 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +474 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +464 -0
- 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.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +452 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +554 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +513 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +508 -0
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +395 -0
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +608 -0
- 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.d.ts +92 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +815 -0
- 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.d.ts +108 -0
- package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +32 -0
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +26 -0
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +15021 -0
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +391 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +367 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +569 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +3 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +212 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +3 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +401 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +313 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +719 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +807 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +3 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +514 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +282 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +207 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +476 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +4 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +420 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +10 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +106 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +3 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +507 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +3 -0
- package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +246 -0
- 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.d.ts +369 -0
- package/dist/components/Charts/Core/Common.types.js +133 -0
- package/dist/components/Charts/Core/CommonFunctions.d.ts +236 -0
- package/dist/components/Charts/Core/CommonFunctions.js +1778 -0
- package/dist/components/Charts/Core/DefaultChartDataProperties.d.ts +65 -0
- package/dist/components/Charts/Core/DefaultChartDataProperties.js +64 -0
- 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 +586 -0
- package/dist/components/Charts/Core/DefaultProperties.type.js +585 -0
- package/dist/components/Charts/Core/DefaultProperties.types.d.ts +592 -0
- package/dist/components/Charts/Core/DefaultProperties.types.js +592 -0
- package/dist/index.d.ts +34 -2
- package/dist/index.js +40 -2
- package/package.json +40 -29
- package/dist/components/charts/linechart/LineChart.d.ts +0 -12
- package/dist/components/charts/linechart/LineChart.js +0 -5
- /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.d.ts +0 -0
- /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.js +0 -0
|
@@ -0,0 +1,313 @@
|
|
|
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); // 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
|
+
data.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 = data.length > 1
|
|
62
|
+
? d3.max(data, (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 = data.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 = data.map((d, i) => d.data[0].legend);
|
|
86
|
+
let sumofmeasure = data.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;
|