pace-chart-lib 0.0.7 → 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 -10
- 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,367 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
//#region imports
|
|
3
|
+
import * as d3 from "d3";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { referenceLineTypes, } from "../../Core/Common.types";
|
|
6
|
+
import { calculateLegendsMaxPossibleWidth, convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initLegendListWithTotalValueAllowance, initSvg, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
7
|
+
import { chartMargins } from "../../Core/DefaultProperties.types";
|
|
8
|
+
import { customXscaleLabelFormatting, customYscaleLabelFormatting, initXaxis, initYaxis, marginCalculationForBubbleScatter, responsiveXaxisLabelForNumericValue, responsiveYaxisLabel, setXaxistitle, yAxistitle, } from "../ChartsWithoutAxisFunctions";
|
|
9
|
+
import { logError } from "../../../../Services/ErrorLog";
|
|
10
|
+
//#endregion
|
|
11
|
+
const BubbleChart = ({ data, formatOptions, chartId, legendEntries, }) => {
|
|
12
|
+
//#region Variables
|
|
13
|
+
const svgRef = useRef(); // Reference to the SVG element
|
|
14
|
+
let chartFormatOptions; // Format options for the chart
|
|
15
|
+
let maxLegendDimensions = [0, 0]; // to calculate margins [width, height]
|
|
16
|
+
let width; // svg total width
|
|
17
|
+
let height; // svg total height
|
|
18
|
+
let chartTitleHeight = 40; // Height of the chart title
|
|
19
|
+
let margins = chartMargins; // Margins for the chart
|
|
20
|
+
let innerHeight; // Height of the chart excluding margins
|
|
21
|
+
let innerWidth; // Width of the chart excluding margins
|
|
22
|
+
let chartAreaTagG; // Group element for the chart area
|
|
23
|
+
let svg; // SVG element for the chart
|
|
24
|
+
let measuresList = []; // List of measures for the bubble chart
|
|
25
|
+
let dimensionsList = []; // List of dimensions for the bubble chart
|
|
26
|
+
let minDimension; // Longest dimension for the chart
|
|
27
|
+
let maxDimension; // Longest measure for the chart
|
|
28
|
+
let minMeasure; // Longest measure for the chart
|
|
29
|
+
let maxMeasure; // Longest measure for the chart
|
|
30
|
+
let yLabel; // Y-axis label
|
|
31
|
+
let xLabel; // X-axis label
|
|
32
|
+
let yTitle; // Y-axis title
|
|
33
|
+
let xTitle; // X-axis title
|
|
34
|
+
let legendMargin; // Margin for the legend
|
|
35
|
+
let longestDimension; // Longest dimension for the chart
|
|
36
|
+
let customXaxisIntervalValue; // Custom X-axis interval value
|
|
37
|
+
let customXaxisMaxValue; // Custom X-axis maximum value
|
|
38
|
+
let customXaxisMinValue; // Custom X-axis minimum value
|
|
39
|
+
let longestMeasure; // Longest measure for the chart
|
|
40
|
+
let customYaxisIntervalValue; // Custom Y-axis interval value
|
|
41
|
+
let customYaxisMaxValue; // Custom Y-axis maximum value
|
|
42
|
+
let customYaxisMinValue; // Custom Y-axis minimum value
|
|
43
|
+
let xScale; // X-axis scale
|
|
44
|
+
let yScale; // Y-axis scale
|
|
45
|
+
//#endregion
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
drawChart();
|
|
48
|
+
}, [formatOptions, data, chartId]);
|
|
49
|
+
const drawChart = () => {
|
|
50
|
+
({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
|
|
51
|
+
let tempLegendEntries = legendEntries;
|
|
52
|
+
maxLegendDimensions = calculateLegendsMaxPossibleWidth(chartFormatOptions, tempLegendEntries, "alias");
|
|
53
|
+
iterateOverChartData();
|
|
54
|
+
({
|
|
55
|
+
longestMeasure,
|
|
56
|
+
customYaxisIntervalValue,
|
|
57
|
+
customYaxisMaxValue,
|
|
58
|
+
customYaxisMinValue,
|
|
59
|
+
} = customYscaleLabelFormatting(chartFormatOptions, minMeasure, maxMeasure));
|
|
60
|
+
({
|
|
61
|
+
longestDimension,
|
|
62
|
+
customXaxisIntervalValue,
|
|
63
|
+
customXaxisMaxValue,
|
|
64
|
+
customXaxisMinValue,
|
|
65
|
+
} = customXscaleLabelFormatting(chartFormatOptions, minDimension, maxDimension));
|
|
66
|
+
({
|
|
67
|
+
margins,
|
|
68
|
+
yLabel,
|
|
69
|
+
xLabel,
|
|
70
|
+
yTitle,
|
|
71
|
+
xTitle,
|
|
72
|
+
chartTitleHeight,
|
|
73
|
+
legendMargin,
|
|
74
|
+
innerHeight,
|
|
75
|
+
innerWidth,
|
|
76
|
+
} = marginCalculationForBubbleScatter(width, height, longestMeasure, chartFormatOptions, longestDimension, maxLegendDimensions));
|
|
77
|
+
initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
|
|
78
|
+
chartAreaTagG = initChartArea(svg, margins);
|
|
79
|
+
drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
|
|
80
|
+
initScale();
|
|
81
|
+
drawXAxis();
|
|
82
|
+
drawYAxis();
|
|
83
|
+
setXaxistitle(formatOptions, false, svg, margins, xLabel, height, xTitle, "Bubble", yLabel, innerWidth, innerHeight);
|
|
84
|
+
yAxistitle(innerHeight, formatOptions, 0, false, svg, margins, yTitle, yLabel);
|
|
85
|
+
drawReferenceLines();
|
|
86
|
+
initLegendList();
|
|
87
|
+
initCircles();
|
|
88
|
+
};
|
|
89
|
+
const initCircles = () => {
|
|
90
|
+
try {
|
|
91
|
+
let minBubbleSize = 5;
|
|
92
|
+
let maxBubbleSize = 30;
|
|
93
|
+
let sizeData = { minimumValue: minMeasure, maximumValue: maxMeasure };
|
|
94
|
+
const circles = chartAreaTagG
|
|
95
|
+
.append("g")
|
|
96
|
+
.attr("class", "circles")
|
|
97
|
+
.attr("class", "parentGroup");
|
|
98
|
+
//Lines
|
|
99
|
+
circles
|
|
100
|
+
.append("g")
|
|
101
|
+
.selectAll(".bubbleScatter")
|
|
102
|
+
.data(data)
|
|
103
|
+
.enter()
|
|
104
|
+
.append("g")
|
|
105
|
+
.attr("hoverId", (d) => d.legendName.replace(/ /g, "-"))
|
|
106
|
+
.attr("fill", (d) => d.legendColor !== "#ffffff" ? d.legendColor : "none")
|
|
107
|
+
.append("path")
|
|
108
|
+
.attr("class", "path")
|
|
109
|
+
.attr("id", function (d, i) {
|
|
110
|
+
d3.select(this).attr("d", d3
|
|
111
|
+
.symbol()
|
|
112
|
+
.type(d3.symbolCircle)
|
|
113
|
+
.size(getBubbleSize(minBubbleSize, maxBubbleSize, sizeData, d.measure, 10) *
|
|
114
|
+
convertStringToNumber(chartFormatOptions.plotArea.bubbleSizeIndex) *
|
|
115
|
+
3));
|
|
116
|
+
})
|
|
117
|
+
.attr("transform", function (d) {
|
|
118
|
+
return `translate(${xScale(d.dimension)}, ${yScale(d.measure)})`;
|
|
119
|
+
})
|
|
120
|
+
.attr("opacity", chartFormatOptions.plotArea.fillOpacity)
|
|
121
|
+
.style("visibility", (d, i) => d.dimension[0] === 0 ||
|
|
122
|
+
(d.measure === 0 && chartFormatOptions.plotArea.hideZeroValues) ||
|
|
123
|
+
d.dimension < customXaxisMinValue ||
|
|
124
|
+
d.dimension > customXaxisMaxValue ||
|
|
125
|
+
d.measure < customYaxisMinValue ||
|
|
126
|
+
d.measure > customYaxisMaxValue
|
|
127
|
+
? "hidden"
|
|
128
|
+
: "visible")
|
|
129
|
+
.on("mousemove", (event, d) => {
|
|
130
|
+
showTooltipOnMouseMove([
|
|
131
|
+
{
|
|
132
|
+
key: chartFormatOptions.xAxisTitle.xAxisTitleText,
|
|
133
|
+
value: getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.dimension),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
key: chartFormatOptions.yAxisTitle.yAxisTitleText,
|
|
137
|
+
value: getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.measure),
|
|
138
|
+
},
|
|
139
|
+
{ key: "Legend", value: d.legendName },
|
|
140
|
+
// { key: "Calculated Tooltip", value: d.tooltip },
|
|
141
|
+
], chartFormatOptions);
|
|
142
|
+
})
|
|
143
|
+
.on("mouseout", () => {
|
|
144
|
+
hideTooltipOnMouseOut();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
logError("BubbleChart", "initCircles", e);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
function getBubbleSize(minBubbleSize, maxBubbleSize, sizeData, currentValue, defaultSize) {
|
|
152
|
+
try {
|
|
153
|
+
if (currentValue == undefined)
|
|
154
|
+
return defaultSize;
|
|
155
|
+
var f = sizeData.minimumValue;
|
|
156
|
+
var b = sizeData.maximumValue;
|
|
157
|
+
var i = maxBubbleSize * maxBubbleSize * 2 * Math.PI;
|
|
158
|
+
var a = minBubbleSize * minBubbleSize * 2 * Math.PI;
|
|
159
|
+
var l = defaultSize;
|
|
160
|
+
if (f == b)
|
|
161
|
+
l = maxBubbleSize;
|
|
162
|
+
else {
|
|
163
|
+
var k = currentValue;
|
|
164
|
+
var j = ((k - f) / (b - f)) * (i - a) + a;
|
|
165
|
+
if (j < a)
|
|
166
|
+
j = a;
|
|
167
|
+
l = Math.sqrt(j / (Math.PI * 2));
|
|
168
|
+
}
|
|
169
|
+
return l;
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
logError("BubbleChart", "getBubbleSize", e);
|
|
173
|
+
return defaultSize;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const iterateOverChartData = () => {
|
|
177
|
+
try {
|
|
178
|
+
// Clear arrays to prevent accumulation on each render
|
|
179
|
+
measuresList = [];
|
|
180
|
+
dimensionsList = [];
|
|
181
|
+
minMeasure = undefined;
|
|
182
|
+
maxMeasure = undefined;
|
|
183
|
+
minDimension = undefined;
|
|
184
|
+
maxDimension = undefined;
|
|
185
|
+
data.forEach((d) => {
|
|
186
|
+
if (d.measureName) {
|
|
187
|
+
measuresList.push(d.measure);
|
|
188
|
+
if (d.measure < minMeasure || minMeasure === undefined) {
|
|
189
|
+
minMeasure = d.measure;
|
|
190
|
+
}
|
|
191
|
+
if (d.measure > maxMeasure || maxMeasure === undefined) {
|
|
192
|
+
maxMeasure = d.measure;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (d.dimensionName) {
|
|
196
|
+
dimensionsList.push(d.dimension);
|
|
197
|
+
if (d.dimension < minDimension || minDimension === undefined) {
|
|
198
|
+
minDimension = d.dimension;
|
|
199
|
+
}
|
|
200
|
+
if (d.dimension > maxDimension || maxDimension === undefined) {
|
|
201
|
+
maxDimension = d.dimension;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
logError("BubbleChart", "iterateOverChartData", e);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const initScale = () => {
|
|
211
|
+
try {
|
|
212
|
+
let xStartValue = chartFormatOptions.xAxisLabel.xAxisIntervalsVisibility &&
|
|
213
|
+
chartFormatOptions.xAxisLabel.xAxisMinText !== ""
|
|
214
|
+
? parseFloat(chartFormatOptions.xAxisLabel.xAxisMinText)
|
|
215
|
+
: minDimension > 0
|
|
216
|
+
? 0
|
|
217
|
+
: minDimension * 1.1;
|
|
218
|
+
let xEndValue = chartFormatOptions.xAxisLabel.xAxisIntervalsVisibility &&
|
|
219
|
+
chartFormatOptions.xAxisLabel.xAxisMaxText !== ""
|
|
220
|
+
? parseFloat(chartFormatOptions.xAxisLabel.xAxisMaxText)
|
|
221
|
+
: maxDimension * 1.1;
|
|
222
|
+
let yStartValue = chartFormatOptions.yAxisLabel.yAxisIntervalsVisibility &&
|
|
223
|
+
chartFormatOptions.yAxisLabel.yAxisMinText !== ""
|
|
224
|
+
? parseFloat(chartFormatOptions.yAxisLabel.yAxisMinText)
|
|
225
|
+
: minMeasure > 0
|
|
226
|
+
? 0
|
|
227
|
+
: minMeasure * 1.1;
|
|
228
|
+
let yEndValue = chartFormatOptions.yAxisLabel.yAxisIntervalsVisibility &&
|
|
229
|
+
chartFormatOptions.yAxisLabel.yAxisMaxText !== ""
|
|
230
|
+
? parseFloat(chartFormatOptions.yAxisLabel.yAxisMaxText)
|
|
231
|
+
: maxMeasure * 1.1;
|
|
232
|
+
xScale = d3
|
|
233
|
+
.scaleLinear()
|
|
234
|
+
.domain([xStartValue, xEndValue])
|
|
235
|
+
//.nice()
|
|
236
|
+
.range([0, innerWidth]);
|
|
237
|
+
yScale = d3
|
|
238
|
+
.scaleLinear()
|
|
239
|
+
.domain([yStartValue, yEndValue])
|
|
240
|
+
//.nice()
|
|
241
|
+
.range([innerHeight, 0]);
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
logError("BubbleChart", "initScale", e);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
const drawXAxis = () => {
|
|
248
|
+
try {
|
|
249
|
+
let { xAxisLabelArray, customTickValue } = responsiveXaxisLabelForNumericValue(maxDimension, minDimension, innerWidth, formatOptions, customXaxisMinValue, customXaxisMaxValue, innerHeight, false);
|
|
250
|
+
const xAxis = d3
|
|
251
|
+
.axisBottom(xScale)
|
|
252
|
+
.tickFormat(getNumberWithFormatFunction(formatOptions.xAxisLabel.xAxisDisplayUnits, formatOptions.xAxisLabel.xAxisNumberFormat, formatOptions.xAxisLabel.xAxisLabelDecimalPrecision ?? "2"))
|
|
253
|
+
.tickSize(chartFormatOptions.plotArea.gridLinesVisibility
|
|
254
|
+
? chartFormatOptions.plotArea.gridLinesVertical
|
|
255
|
+
? chartFormatOptions.xAxisLabel.xAxisPosition === "0"
|
|
256
|
+
? -innerHeight
|
|
257
|
+
: chartFormatOptions.xAxisLabel.xAxisPosition === "1"
|
|
258
|
+
? innerHeight
|
|
259
|
+
: 0
|
|
260
|
+
: 0
|
|
261
|
+
: 0)
|
|
262
|
+
.tickValues(xAxisLabelArray.length > 0 ? xAxisLabelArray : null)
|
|
263
|
+
.ticks(customTickValue)
|
|
264
|
+
.tickSizeOuter(0);
|
|
265
|
+
initXaxis(chartAreaTagG, chartFormatOptions, 0, xLabel, xAxis, innerHeight, innerWidth, margins, yScale);
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
logError("BubbleChart", "drawXAxis", e);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const drawYAxis = () => {
|
|
272
|
+
try {
|
|
273
|
+
let { yAxisLabelArray, customTickValue } = responsiveYaxisLabel(maxMeasure, minMeasure, innerHeight, formatOptions, customYaxisMinValue, customYaxisMaxValue);
|
|
274
|
+
const yAxis = d3
|
|
275
|
+
.axisLeft(yScale)
|
|
276
|
+
.tickFormat(getNumberWithFormatFunction(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? "2"))
|
|
277
|
+
.tickSize(chartFormatOptions.plotArea.gridLinesVisibility
|
|
278
|
+
? chartFormatOptions.plotArea.gridLinesHorizontal
|
|
279
|
+
? -innerWidth
|
|
280
|
+
: 0
|
|
281
|
+
: 0)
|
|
282
|
+
.tickValues(yAxisLabelArray.length > 0 ? yAxisLabelArray : null)
|
|
283
|
+
.ticks(customTickValue)
|
|
284
|
+
.tickSizeOuter(0);
|
|
285
|
+
initYaxis(chartAreaTagG, chartFormatOptions, 0, yLabel, yAxis, innerHeight);
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
logError("BubbleChart", "drawYAxis", e);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const drawReferenceLines = () => {
|
|
292
|
+
try {
|
|
293
|
+
if (chartFormatOptions.plotArea.xCoordinate != referenceLineTypes.None) {
|
|
294
|
+
let xCordinate;
|
|
295
|
+
switch (chartFormatOptions.plotArea.xCoordinate) {
|
|
296
|
+
case referenceLineTypes.Mean:
|
|
297
|
+
xCordinate = d3.mean(data, (d) => d.dimension);
|
|
298
|
+
break;
|
|
299
|
+
case referenceLineTypes.Median:
|
|
300
|
+
xCordinate = d3.median(data, (d) => d.dimension);
|
|
301
|
+
break;
|
|
302
|
+
case referenceLineTypes.Custom:
|
|
303
|
+
xCordinate = convertStringToNumber(chartFormatOptions.plotArea.xscaleposition);
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
chartAreaTagG
|
|
307
|
+
.append("line")
|
|
308
|
+
.attr("x1", xScale(xCordinate))
|
|
309
|
+
.attr("y1", 0)
|
|
310
|
+
.attr("x2", xScale(xCordinate))
|
|
311
|
+
.attr("y2", innerHeight)
|
|
312
|
+
.attr("stroke", chartFormatOptions.plotArea.refLineBorderColor)
|
|
313
|
+
.attr("stroke-width", chartFormatOptions.plotArea.refLineBorderThickness);
|
|
314
|
+
// .attr("stroke-dasharray", chartFormatOptions.plotArea.refLineStyle);
|
|
315
|
+
}
|
|
316
|
+
if (chartFormatOptions.plotArea.yCoordinate != referenceLineTypes.None) {
|
|
317
|
+
let yCordinate;
|
|
318
|
+
switch (chartFormatOptions.plotArea.yCoordinate) {
|
|
319
|
+
case referenceLineTypes.Mean:
|
|
320
|
+
yCordinate = d3.mean(data, (d) => d.measure);
|
|
321
|
+
break;
|
|
322
|
+
case referenceLineTypes.Median:
|
|
323
|
+
yCordinate = d3.median(data, (d) => d.measure);
|
|
324
|
+
break;
|
|
325
|
+
case referenceLineTypes.Custom:
|
|
326
|
+
yCordinate = convertStringToNumber(chartFormatOptions.plotArea.yscaleposition);
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
chartAreaTagG
|
|
330
|
+
.append("line")
|
|
331
|
+
.attr("x1", 0)
|
|
332
|
+
.attr("y1", yScale(yCordinate))
|
|
333
|
+
.attr("x2", innerWidth)
|
|
334
|
+
.attr("y2", yScale(yCordinate))
|
|
335
|
+
.attr("stroke", chartFormatOptions.plotArea.refLineBorderColor)
|
|
336
|
+
.attr("stroke-width", chartFormatOptions.plotArea.refLineBorderThickness);
|
|
337
|
+
// .attr("stroke-dasharray", chartFormatOptions.plotArea.refLineStyle);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
logError("BubbleChart", "drawReferenceLines", e);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const initLegendList = () => {
|
|
345
|
+
try {
|
|
346
|
+
let tempLegendEntries = legendEntries.map((d) => {
|
|
347
|
+
let modifiedProperties = {
|
|
348
|
+
...d,
|
|
349
|
+
legendFontStyle: d.fontStyle,
|
|
350
|
+
fontSize: d.fontSize + "px",
|
|
351
|
+
legendFontFamily: d.fontFamily,
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
legend: d.name,
|
|
355
|
+
properties: modifiedProperties,
|
|
356
|
+
data: {},
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
initLegendListWithTotalValueAllowance(chartFormatOptions, svg, tempLegendEntries, width, height, maxLegendDimensions[0], chartTitleHeight, chartId, margins);
|
|
360
|
+
}
|
|
361
|
+
catch (e) {
|
|
362
|
+
logError("BubbleChart", "initLegendList", e);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
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%" } })] }));
|
|
366
|
+
};
|
|
367
|
+
export default BubbleChart;
|