@mui/x-charts-premium 9.2.0 → 9.4.0
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/BarChartPremium/BarChartPremium.js +65 -35
- package/BarChartPremium/BarChartPremium.mjs +65 -35
- package/BarChartPremium/RangeBar/RangeBarPlot.d.mts +10 -0
- package/BarChartPremium/RangeBar/RangeBarPlot.d.ts +10 -0
- package/BarChartPremium/RangeBar/RangeBarPlot.js +59 -2
- package/BarChartPremium/RangeBar/RangeBarPlot.mjs +59 -2
- package/BarChartPremium/RangeBar/RangeBarWebGLPlot.d.mts +10 -0
- package/BarChartPremium/RangeBar/RangeBarWebGLPlot.d.ts +10 -0
- package/BarChartPremium/RangeBar/RangeBarWebGLPlot.js +82 -0
- package/BarChartPremium/RangeBar/RangeBarWebGLPlot.mjs +76 -0
- package/BarChartPremium/RangeBar/seriesConfig/extrema.js +3 -0
- package/BarChartPremium/RangeBar/seriesConfig/extrema.mjs +3 -0
- package/BarChartPremium/RangeBar/seriesConfig/seriesProcessor.js +2 -2
- package/BarChartPremium/RangeBar/seriesConfig/seriesProcessor.mjs +2 -2
- package/BarChartPremium/useBarChartPremiumProps.js +2 -1
- package/BarChartPremium/useBarChartPremiumProps.mjs +2 -1
- package/BarChartPremium/webgl/useBarWebGLPlotData.d.mts +2 -7
- package/BarChartPremium/webgl/useBarWebGLPlotData.d.ts +2 -7
- package/BarChartPremium/webgl/useBarWebGLPlotData.js +4 -151
- package/BarChartPremium/webgl/useBarWebGLPlotData.mjs +4 -150
- package/BarChartPremium/webgl/useWebGLBarLikePlotData.d.mts +39 -0
- package/BarChartPremium/webgl/useWebGLBarLikePlotData.d.ts +39 -0
- package/BarChartPremium/webgl/useWebGLBarLikePlotData.js +169 -0
- package/BarChartPremium/webgl/useWebGLBarLikePlotData.mjs +163 -0
- package/CHANGELOG.md +314 -0
- package/CandlestickChart/CandlestickChart.js +36 -27
- package/CandlestickChart/CandlestickChart.mjs +36 -27
- package/CandlestickChart/seriesConfig/extrema.js +3 -0
- package/CandlestickChart/seriesConfig/extrema.mjs +3 -0
- package/CandlestickChart/seriesConfig/seriesProcessor.js +2 -2
- package/CandlestickChart/seriesConfig/seriesProcessor.mjs +2 -2
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.mts +35 -0
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.ts +35 -0
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.js +125 -0
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.mjs +119 -0
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.mts +5 -0
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.ts +5 -0
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.js +10 -0
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.mjs +4 -0
- package/ChartsGeoDataProviderPremium/index.d.mts +3 -0
- package/ChartsGeoDataProviderPremium/index.d.ts +3 -0
- package/ChartsGeoDataProviderPremium/index.js +20 -0
- package/ChartsGeoDataProviderPremium/index.mjs +3 -0
- package/ChartsGeoDataProviderPremium/useChartsGeoDataProviderPremiumProps.d.mts +10 -0
- package/ChartsGeoDataProviderPremium/useChartsGeoDataProviderPremiumProps.d.ts +10 -0
- package/ChartsGeoDataProviderPremium/useChartsGeoDataProviderPremiumProps.js +49 -0
- package/ChartsGeoDataProviderPremium/useChartsGeoDataProviderPremiumProps.mjs +42 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +2 -2
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +2 -2
- package/HeatmapPremium/HeatmapPremium.js +52 -22
- package/HeatmapPremium/HeatmapPremium.mjs +52 -22
- package/Map/FocusedMapShape.d.mts +4 -0
- package/Map/FocusedMapShape.d.ts +4 -0
- package/Map/FocusedMapShape.js +66 -0
- package/Map/FocusedMapShape.mjs +60 -0
- package/Map/GeoDataPlot.d.mts +26 -0
- package/Map/GeoDataPlot.d.ts +26 -0
- package/Map/GeoDataPlot.js +65 -0
- package/Map/GeoDataPlot.mjs +60 -0
- package/Map/Graticule.d.mts +1 -0
- package/Map/Graticule.d.ts +1 -0
- package/Map/Graticule.js +30 -0
- package/Map/Graticule.mjs +24 -0
- package/Map/MapShape.d.mts +10 -0
- package/Map/MapShape.d.ts +10 -0
- package/Map/MapShape.js +55 -0
- package/Map/MapShape.mjs +49 -0
- package/Map/MapShapePlot.d.mts +21 -0
- package/Map/MapShapePlot.d.ts +21 -0
- package/Map/MapShapePlot.js +86 -0
- package/Map/MapShapePlot.mjs +80 -0
- package/Map/index.d.mts +7 -0
- package/Map/index.d.ts +7 -0
- package/Map/index.js +60 -0
- package/Map/index.mjs +8 -0
- package/Map/seriesConfig/descriptionGetter.d.mts +3 -0
- package/Map/seriesConfig/descriptionGetter.d.ts +3 -0
- package/Map/seriesConfig/descriptionGetter.js +19 -0
- package/Map/seriesConfig/descriptionGetter.mjs +13 -0
- package/Map/seriesConfig/getColor.d.mts +3 -0
- package/Map/seriesConfig/getColor.d.ts +3 -0
- package/Map/seriesConfig/getColor.js +35 -0
- package/Map/seriesConfig/getColor.mjs +29 -0
- package/Map/seriesConfig/getSeriesWithDefaultValues.d.mts +3 -0
- package/Map/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
- package/Map/seriesConfig/getSeriesWithDefaultValues.js +15 -0
- package/Map/seriesConfig/getSeriesWithDefaultValues.mjs +8 -0
- package/Map/seriesConfig/index.d.mts +2 -0
- package/Map/seriesConfig/index.d.ts +2 -0
- package/Map/seriesConfig/index.js +28 -0
- package/Map/seriesConfig/index.mjs +21 -0
- package/Map/seriesConfig/keyboardFocusHandler.d.mts +9 -0
- package/Map/seriesConfig/keyboardFocusHandler.d.ts +9 -0
- package/Map/seriesConfig/keyboardFocusHandler.js +19 -0
- package/Map/seriesConfig/keyboardFocusHandler.mjs +13 -0
- package/Map/seriesConfig/legend.d.mts +3 -0
- package/Map/seriesConfig/legend.d.ts +3 -0
- package/Map/seriesConfig/legend.js +28 -0
- package/Map/seriesConfig/legend.mjs +22 -0
- package/Map/seriesConfig/seriesProcessor.d.mts +3 -0
- package/Map/seriesConfig/seriesProcessor.d.ts +3 -0
- package/Map/seriesConfig/seriesProcessor.js +66 -0
- package/Map/seriesConfig/seriesProcessor.mjs +59 -0
- package/Map/seriesConfig/tooltip.d.mts +3 -0
- package/Map/seriesConfig/tooltip.d.ts +3 -0
- package/Map/seriesConfig/tooltip.js +33 -0
- package/Map/seriesConfig/tooltip.mjs +27 -0
- package/RadialBarChart/RadialBarChart.js +10 -10
- package/RadialBarChart/RadialBarChart.mjs +10 -10
- package/RadialBarChart/seriesConfig/getColor.js +7 -51
- package/RadialBarChart/seriesConfig/getColor.mjs +8 -52
- package/RadialBarChart/seriesConfig/tooltip.js +3 -26
- package/RadialBarChart/seriesConfig/tooltip.mjs +4 -27
- package/RadialLineChart/RadialArea.d.mts +2 -11
- package/RadialLineChart/RadialArea.d.ts +2 -11
- package/RadialLineChart/RadialArea.js +4 -3
- package/RadialLineChart/RadialArea.mjs +4 -3
- package/RadialLineChart/RadialAreaPlot.js +3 -1
- package/RadialLineChart/RadialAreaPlot.mjs +3 -1
- package/RadialLineChart/RadialLine.d.mts +4 -3
- package/RadialLineChart/RadialLine.d.ts +4 -3
- package/RadialLineChart/RadialLine.js +4 -3
- package/RadialLineChart/RadialLine.mjs +4 -3
- package/RadialLineChart/RadialLineChart.d.mts +7 -5
- package/RadialLineChart/RadialLineChart.d.ts +7 -5
- package/RadialLineChart/RadialLineChart.js +11 -11
- package/RadialLineChart/RadialLineChart.mjs +11 -11
- package/RadialLineChart/RadialLineHighlightPlot.d.mts +3 -2
- package/RadialLineChart/RadialLineHighlightPlot.d.ts +3 -2
- package/RadialLineChart/RadialLinePlot.js +3 -1
- package/RadialLineChart/RadialLinePlot.mjs +3 -1
- package/RadialLineChart/seriesConfig/getColor.js +6 -53
- package/RadialLineChart/seriesConfig/getColor.mjs +7 -54
- package/RadialLineChart/seriesConfig/seriesProcessor.d.mts +2 -2
- package/RadialLineChart/seriesConfig/seriesProcessor.d.ts +2 -2
- package/RadialLineChart/seriesConfig/seriesProcessor.js +1 -138
- package/RadialLineChart/seriesConfig/seriesProcessor.mjs +2 -138
- package/RadialLineChart/seriesConfig/tooltip.js +3 -24
- package/RadialLineChart/seriesConfig/tooltip.mjs +4 -25
- package/RadialLineChart/useRadialLinePlotData.d.mts +1 -0
- package/RadialLineChart/useRadialLinePlotData.d.ts +1 -0
- package/RadialLineChart/useRadialLinePlotData.js +3 -1
- package/RadialLineChart/useRadialLinePlotData.mjs +3 -1
- package/ScatterChartPremium/ScatterChartPremium.d.mts +2 -1
- package/ScatterChartPremium/ScatterChartPremium.d.ts +2 -1
- package/ScatterChartPremium/ScatterChartPremium.js +62 -32
- package/ScatterChartPremium/ScatterChartPremium.mjs +62 -32
- package/hooks/index.d.mts +4 -1
- package/hooks/index.d.ts +4 -1
- package/hooks/index.js +33 -0
- package/hooks/index.mjs +4 -1
- package/hooks/useGeoData.d.mts +6 -0
- package/hooks/useGeoData.d.ts +6 -0
- package/hooks/useGeoData.js +17 -0
- package/hooks/useGeoData.mjs +13 -0
- package/hooks/useGeoFeatureIndexesByName.d.mts +7 -0
- package/hooks/useGeoFeatureIndexesByName.d.ts +7 -0
- package/hooks/useGeoFeatureIndexesByName.js +19 -0
- package/hooks/useGeoFeatureIndexesByName.mjs +15 -0
- package/hooks/useGeoPath.d.mts +6 -0
- package/hooks/useGeoPath.d.ts +6 -0
- package/hooks/useGeoPath.js +17 -0
- package/hooks/useGeoPath.mjs +13 -0
- package/hooks/useMapShapeSeries.d.mts +34 -0
- package/hooks/useMapShapeSeries.d.ts +34 -0
- package/hooks/useMapShapeSeries.js +45 -0
- package/hooks/useMapShapeSeries.mjs +40 -0
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/index.js +25 -1
- package/index.mjs +3 -1
- package/internals/plugins/useGeoProjection/index.d.mts +3 -0
- package/internals/plugins/useGeoProjection/index.d.ts +3 -0
- package/internals/plugins/useGeoProjection/index.js +38 -0
- package/internals/plugins/useGeoProjection/index.mjs +3 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.d.mts +3 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.d.ts +3 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.js +58 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.mjs +50 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.mts +39 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.ts +39 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.js +135 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.mjs +128 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.types.d.mts +55 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.types.d.ts +55 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.types.js +5 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.types.mjs +1 -0
- package/models/chartsSlotsComponentsPropsPremium.d.mts +1 -0
- package/models/chartsSlotsComponentsPropsPremium.d.ts +1 -0
- package/models/chartsSlotsComponentsPropsPremium.js +5 -0
- package/models/chartsSlotsComponentsPropsPremium.mjs +1 -0
- package/models/index.d.mts +2 -1
- package/models/index.d.ts +2 -1
- package/models/index.js +11 -0
- package/models/index.mjs +2 -1
- package/models/seriesType/index.d.mts +2 -1
- package/models/seriesType/index.d.ts +2 -1
- package/models/seriesType/index.js +11 -0
- package/models/seriesType/index.mjs +2 -1
- package/models/seriesType/mapShape.d.mts +105 -0
- package/models/seriesType/mapShape.d.ts +105 -0
- package/models/seriesType/mapShape.js +5 -0
- package/models/seriesType/mapShape.mjs +1 -0
- package/models/seriesType/radialBar.d.mts +1 -1
- package/models/seriesType/radialBar.d.ts +1 -1
- package/models/seriesType/radialLine.d.mts +4 -0
- package/models/seriesType/radialLine.d.ts +4 -0
- package/package.json +34 -6
- package/typeOverloads/modules.d.mts +16 -1
- package/typeOverloads/modules.d.ts +16 -1
- package/utils/webgl/useWebGLResizeObserver.js +3 -3
- package/utils/webgl/useWebGLResizeObserver.mjs +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface RangeBarWebGLPlotProps {
|
|
3
|
+
borderRadius?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @ignore - Internal component used for rendering the range bar plot using WebGL. Not exported from the package.
|
|
7
|
+
*/
|
|
8
|
+
export declare function RangeBarWebGLPlot({
|
|
9
|
+
borderRadius
|
|
10
|
+
}: RangeBarWebGLPlotProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.RangeBarWebGLPlot = RangeBarWebGLPlot;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _hooks = require("@mui/x-charts/hooks");
|
|
11
|
+
var _ChartsWebGLContext = require("../../ChartsWebGLLayer/ChartsWebGLContext");
|
|
12
|
+
var _BarWebGLProgram = require("../webgl/BarWebGLProgram");
|
|
13
|
+
var _useWebGLBarLikePlotData = require("../webgl/useWebGLBarLikePlotData");
|
|
14
|
+
var _useRangeBarPlotData = require("./useRangeBarPlotData");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
/**
|
|
17
|
+
* @ignore - Internal component used for rendering the range bar plot using WebGL. Not exported from the package.
|
|
18
|
+
*/
|
|
19
|
+
function RangeBarWebGLPlot({
|
|
20
|
+
borderRadius = 0
|
|
21
|
+
}) {
|
|
22
|
+
const layer = (0, _ChartsWebGLContext.useWebGLLayer)();
|
|
23
|
+
const drawingArea = (0, _hooks.useDrawingArea)();
|
|
24
|
+
const {
|
|
25
|
+
xAxis: xAxes
|
|
26
|
+
} = (0, _hooks.useXAxes)();
|
|
27
|
+
const {
|
|
28
|
+
yAxis: yAxes
|
|
29
|
+
} = (0, _hooks.useYAxes)();
|
|
30
|
+
const completedData = (0, _useRangeBarPlotData.useRangeBarPlotData)(drawingArea, xAxes, yAxes);
|
|
31
|
+
if (!layer) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(RangeBarWebGLPlotImpl, {
|
|
35
|
+
gl: layer.gl,
|
|
36
|
+
registerDraw: layer.registerDraw,
|
|
37
|
+
requestRender: layer.requestRender,
|
|
38
|
+
borderRadius: borderRadius,
|
|
39
|
+
completedData: completedData
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function RangeBarWebGLPlotImpl(props) {
|
|
43
|
+
const {
|
|
44
|
+
gl,
|
|
45
|
+
registerDraw,
|
|
46
|
+
requestRender,
|
|
47
|
+
borderRadius,
|
|
48
|
+
completedData
|
|
49
|
+
} = props;
|
|
50
|
+
const drawingArea = (0, _hooks.useDrawingArea)();
|
|
51
|
+
const plotData = (0, _useWebGLBarLikePlotData.useWebGLBarLikePlotData)(drawingArea, completedData, borderRadius, {
|
|
52
|
+
highlightType: 'rangeBar',
|
|
53
|
+
fullRoundedCorners: true
|
|
54
|
+
});
|
|
55
|
+
const [program, setProgram] = React.useState(null);
|
|
56
|
+
const drawRef = React.useRef(null);
|
|
57
|
+
React.useEffect(() => {
|
|
58
|
+
const prog = new _BarWebGLProgram.BarWebGLProgram(gl);
|
|
59
|
+
setProgram(prog);
|
|
60
|
+
return () => {
|
|
61
|
+
prog.dispose();
|
|
62
|
+
};
|
|
63
|
+
}, [gl]);
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
drawRef.current = () => {
|
|
66
|
+
program?.render(plotData.count);
|
|
67
|
+
};
|
|
68
|
+
}, [program, plotData.count]);
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
const unregister = registerDraw(drawRef);
|
|
71
|
+
return unregister;
|
|
72
|
+
}, [registerDraw]);
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
program?.setResolution(drawingArea.width, drawingArea.height);
|
|
75
|
+
requestRender();
|
|
76
|
+
}, [drawingArea.width, drawingArea.height, program, requestRender]);
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
program?.plot(plotData);
|
|
79
|
+
requestRender();
|
|
80
|
+
}, [program, plotData, requestRender]);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useDrawingArea, useXAxes, useYAxes } from '@mui/x-charts/hooks';
|
|
5
|
+
import { useWebGLLayer } from "../../ChartsWebGLLayer/ChartsWebGLContext.mjs";
|
|
6
|
+
import { BarWebGLProgram } from "../webgl/BarWebGLProgram.mjs";
|
|
7
|
+
import { useWebGLBarLikePlotData } from "../webgl/useWebGLBarLikePlotData.mjs";
|
|
8
|
+
import { useRangeBarPlotData } from "./useRangeBarPlotData.mjs";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
/**
|
|
11
|
+
* @ignore - Internal component used for rendering the range bar plot using WebGL. Not exported from the package.
|
|
12
|
+
*/
|
|
13
|
+
export function RangeBarWebGLPlot({
|
|
14
|
+
borderRadius = 0
|
|
15
|
+
}) {
|
|
16
|
+
const layer = useWebGLLayer();
|
|
17
|
+
const drawingArea = useDrawingArea();
|
|
18
|
+
const {
|
|
19
|
+
xAxis: xAxes
|
|
20
|
+
} = useXAxes();
|
|
21
|
+
const {
|
|
22
|
+
yAxis: yAxes
|
|
23
|
+
} = useYAxes();
|
|
24
|
+
const completedData = useRangeBarPlotData(drawingArea, xAxes, yAxes);
|
|
25
|
+
if (!layer) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/_jsx(RangeBarWebGLPlotImpl, {
|
|
29
|
+
gl: layer.gl,
|
|
30
|
+
registerDraw: layer.registerDraw,
|
|
31
|
+
requestRender: layer.requestRender,
|
|
32
|
+
borderRadius: borderRadius,
|
|
33
|
+
completedData: completedData
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function RangeBarWebGLPlotImpl(props) {
|
|
37
|
+
const {
|
|
38
|
+
gl,
|
|
39
|
+
registerDraw,
|
|
40
|
+
requestRender,
|
|
41
|
+
borderRadius,
|
|
42
|
+
completedData
|
|
43
|
+
} = props;
|
|
44
|
+
const drawingArea = useDrawingArea();
|
|
45
|
+
const plotData = useWebGLBarLikePlotData(drawingArea, completedData, borderRadius, {
|
|
46
|
+
highlightType: 'rangeBar',
|
|
47
|
+
fullRoundedCorners: true
|
|
48
|
+
});
|
|
49
|
+
const [program, setProgram] = React.useState(null);
|
|
50
|
+
const drawRef = React.useRef(null);
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
const prog = new BarWebGLProgram(gl);
|
|
53
|
+
setProgram(prog);
|
|
54
|
+
return () => {
|
|
55
|
+
prog.dispose();
|
|
56
|
+
};
|
|
57
|
+
}, [gl]);
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
drawRef.current = () => {
|
|
60
|
+
program?.render(plotData.count);
|
|
61
|
+
};
|
|
62
|
+
}, [program, plotData.count]);
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
const unregister = registerDraw(drawRef);
|
|
65
|
+
return unregister;
|
|
66
|
+
}, [registerDraw]);
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
program?.setResolution(drawingArea.width, drawingArea.height);
|
|
69
|
+
requestRender();
|
|
70
|
+
}, [drawingArea.width, drawingArea.height, program, requestRender]);
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
program?.plot(plotData);
|
|
73
|
+
requestRender();
|
|
74
|
+
}, [program, plotData, requestRender]);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
@@ -41,6 +41,9 @@ const getValueExtremum = direction => params => {
|
|
|
41
41
|
isDefaultAxis
|
|
42
42
|
} = params;
|
|
43
43
|
return Object.keys(series).filter(seriesId => {
|
|
44
|
+
if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
44
47
|
const axisId = direction === 'x' ? series[seriesId].xAxisId : series[seriesId].yAxisId;
|
|
45
48
|
return axisId === axis.id || isDefaultAxis && axisId === undefined;
|
|
46
49
|
}).reduce((acc, seriesId) => {
|
|
@@ -35,6 +35,9 @@ const getValueExtremum = direction => params => {
|
|
|
35
35
|
isDefaultAxis
|
|
36
36
|
} = params;
|
|
37
37
|
return Object.keys(series).filter(seriesId => {
|
|
38
|
+
if (axis.domainSeries === 'visible' && series[seriesId].hidden) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
38
41
|
const axisId = direction === 'x' ? series[seriesId].xAxisId : series[seriesId].yAxisId;
|
|
39
42
|
return axisId === axis.id || isDefaultAxis && axisId === undefined;
|
|
40
43
|
}).reduce((acc, seriesId) => {
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
10
10
|
var _warning = require("@mui/x-internals/warning");
|
|
11
|
+
var _internals = require("@mui/x-charts/internals");
|
|
11
12
|
const rangeBarValueFormatter = v => v == null ? '' : `[${v[0]}, ${v[1]}]`;
|
|
12
13
|
const seriesProcessor = (params, dataset, isItemVisible) => {
|
|
13
14
|
const {
|
|
@@ -26,8 +27,7 @@ Either provide a data property to the series or use the dataset prop.` : (0, _fo
|
|
|
26
27
|
}
|
|
27
28
|
const missingKeys = ['start', 'end'].filter(key => typeof datasetKeys?.[key] !== 'string');
|
|
28
29
|
if (datasetKeys && missingKeys.length > 0) {
|
|
29
|
-
|
|
30
|
-
Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing.` : (0, _formatErrorMessage2.default)(45, id, missingKeys.map(key => `"${key}"`).join(', ')));
|
|
30
|
+
(0, _internals.incompleteDatasetKeysError)('RangeBar', id, missingKeys);
|
|
31
31
|
}
|
|
32
32
|
let data;
|
|
33
33
|
if (seriesData.valueGetter) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
|
|
3
3
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
|
+
import { incompleteDatasetKeysError } from '@mui/x-charts/internals';
|
|
4
5
|
const rangeBarValueFormatter = v => v == null ? '' : `[${v[0]}, ${v[1]}]`;
|
|
5
6
|
const seriesProcessor = (params, dataset, isItemVisible) => {
|
|
6
7
|
const {
|
|
@@ -19,8 +20,7 @@ Either provide a data property to the series or use the dataset prop.` : _format
|
|
|
19
20
|
}
|
|
20
21
|
const missingKeys = ['start', 'end'].filter(key => typeof datasetKeys?.[key] !== 'string');
|
|
21
22
|
if (datasetKeys && missingKeys.length > 0) {
|
|
22
|
-
|
|
23
|
-
Properties ${missingKeys.map(key => `"${key}"`).join(', ')} are missing.` : _formatErrorMessage(45, id, missingKeys.map(key => `"${key}"`).join(', ')));
|
|
23
|
+
incompleteDatasetKeysError('RangeBar', id, missingKeys);
|
|
24
24
|
}
|
|
25
25
|
let data;
|
|
26
26
|
if (seriesData.valueGetter) {
|
|
@@ -46,7 +46,8 @@ function useBarChartPremiumProps(props) {
|
|
|
46
46
|
onItemClick: props.onItemClick,
|
|
47
47
|
slots: props.slots,
|
|
48
48
|
slotProps: props.slotProps,
|
|
49
|
-
borderRadius: props.borderRadius
|
|
49
|
+
borderRadius: props.borderRadius,
|
|
50
|
+
renderer: renderer === 'webgl' ? 'webgl' : undefined
|
|
50
51
|
};
|
|
51
52
|
return (0, _extends2.default)({}, barChartProps, {
|
|
52
53
|
chartsContainerProps: premiumContainerProps,
|
|
@@ -39,7 +39,8 @@ export function useBarChartPremiumProps(props) {
|
|
|
39
39
|
onItemClick: props.onItemClick,
|
|
40
40
|
slots: props.slots,
|
|
41
41
|
slotProps: props.slotProps,
|
|
42
|
-
borderRadius: props.borderRadius
|
|
42
|
+
borderRadius: props.borderRadius,
|
|
43
|
+
renderer: renderer === 'webgl' ? 'webgl' : undefined
|
|
43
44
|
};
|
|
44
45
|
return _extends({}, barChartProps, {
|
|
45
46
|
chartsContainerProps: premiumContainerProps,
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { type ChartDrawingArea } from '@mui/x-charts/hooks';
|
|
2
2
|
import { type ProcessedBarSeriesData } from '@mui/x-charts/internals';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
halfSizes: Float32Array;
|
|
6
|
-
colors: Uint8Array;
|
|
7
|
-
cornerRadii: Float32Array;
|
|
8
|
-
count: number;
|
|
9
|
-
}
|
|
3
|
+
import { type WebGLBarLikePlotData } from "./useWebGLBarLikePlotData.mjs";
|
|
4
|
+
export type BarWebGLPlotData = WebGLBarLikePlotData;
|
|
10
5
|
export declare function useBarWebGLPlotData(drawingArea: ChartDrawingArea, completedData: ProcessedBarSeriesData[], borderRadius: number): BarWebGLPlotData;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { type ChartDrawingArea } from '@mui/x-charts/hooks';
|
|
2
2
|
import { type ProcessedBarSeriesData } from '@mui/x-charts/internals';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
halfSizes: Float32Array;
|
|
6
|
-
colors: Uint8Array;
|
|
7
|
-
cornerRadii: Float32Array;
|
|
8
|
-
count: number;
|
|
9
|
-
}
|
|
3
|
+
import { type WebGLBarLikePlotData } from "./useWebGLBarLikePlotData.js";
|
|
4
|
+
export type BarWebGLPlotData = WebGLBarLikePlotData;
|
|
10
5
|
export declare function useBarWebGLPlotData(drawingArea: ChartDrawingArea, completedData: ProcessedBarSeriesData[], borderRadius: number): BarWebGLPlotData;
|
|
@@ -1,160 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.useBarWebGLPlotData = useBarWebGLPlotData;
|
|
9
|
-
var
|
|
10
|
-
var _internals = require("@mui/x-charts/internals");
|
|
11
|
-
var _parseColor = require("../../utils/webgl/parseColor");
|
|
12
|
-
const EMPTY_FLOAT32 = new Float32Array(0);
|
|
13
|
-
const EMPTY_UINT8 = new Uint8Array(0);
|
|
14
|
-
const EMPTY_DATA = {
|
|
15
|
-
centers: EMPTY_FLOAT32,
|
|
16
|
-
halfSizes: EMPTY_FLOAT32,
|
|
17
|
-
colors: EMPTY_UINT8,
|
|
18
|
-
cornerRadii: EMPTY_FLOAT32,
|
|
19
|
-
count: 0
|
|
20
|
-
};
|
|
21
|
-
function ensureCapacity(pool, maxCount) {
|
|
22
|
-
if (pool !== null && pool.colors.length >= maxCount * 4) {
|
|
23
|
-
return pool;
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
centers: new Float32Array(maxCount * 2),
|
|
27
|
-
halfSizes: new Float32Array(maxCount * 2),
|
|
28
|
-
colors: new Uint8Array(maxCount * 4),
|
|
29
|
-
cornerRadii: new Float32Array(maxCount * 4)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Mirrors SVG highlight styling: highlighted -> CSS `brightness(120%)`,
|
|
34
|
-
// faded -> opacity 0.3. Baking these into the per-bar color array means we
|
|
35
|
-
// don't need a separate per-instance attribute on the GPU side.
|
|
36
|
-
const HIGHLIGHTED_BRIGHTNESS = 1.2;
|
|
37
|
-
const FADED_OPACITY = 0.3;
|
|
38
|
-
function setCornerRadii(radius, side, target, offset) {
|
|
39
|
-
// CSS order: top-left, top-right, bottom-right, bottom-left.
|
|
40
|
-
let tl = 0;
|
|
41
|
-
let tr = 0;
|
|
42
|
-
let br = 0;
|
|
43
|
-
let bl = 0;
|
|
44
|
-
if (radius > 0) {
|
|
45
|
-
if (side === 'top') {
|
|
46
|
-
tl = radius;
|
|
47
|
-
tr = radius;
|
|
48
|
-
} else if (side === 'bottom') {
|
|
49
|
-
br = radius;
|
|
50
|
-
bl = radius;
|
|
51
|
-
} else if (side === 'left') {
|
|
52
|
-
tl = radius;
|
|
53
|
-
bl = radius;
|
|
54
|
-
} else if (side === 'right') {
|
|
55
|
-
tr = radius;
|
|
56
|
-
br = radius;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
target[offset] = tl;
|
|
60
|
-
target[offset + 1] = tr;
|
|
61
|
-
target[offset + 2] = br;
|
|
62
|
-
target[offset + 3] = bl;
|
|
63
|
-
}
|
|
8
|
+
var _useWebGLBarLikePlotData = require("./useWebGLBarLikePlotData");
|
|
64
9
|
function useBarWebGLPlotData(drawingArea, completedData, borderRadius) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return React.useMemo(() => {
|
|
69
|
-
let maxCount = 0;
|
|
70
|
-
for (let s = 0; s < completedData.length; s += 1) {
|
|
71
|
-
maxCount += completedData[s].data.length;
|
|
72
|
-
}
|
|
73
|
-
if (maxCount === 0) {
|
|
74
|
-
return EMPTY_DATA;
|
|
75
|
-
}
|
|
76
|
-
const pool = ensureCapacity(poolRef.current, maxCount);
|
|
77
|
-
poolRef.current = pool;
|
|
78
|
-
|
|
79
|
-
// Hoist invariants out of the hot loop.
|
|
80
|
-
const {
|
|
81
|
-
centers,
|
|
82
|
-
halfSizes,
|
|
83
|
-
colors,
|
|
84
|
-
cornerRadii
|
|
85
|
-
} = pool;
|
|
86
|
-
const drawingAreaLeft = drawingArea.left;
|
|
87
|
-
const drawingAreaTop = drawingArea.top;
|
|
88
|
-
let cursor = 0;
|
|
89
|
-
for (let s = 0; s < completedData.length; s += 1) {
|
|
90
|
-
const processed = completedData[s];
|
|
91
|
-
const seriesId = processed.seriesId;
|
|
92
|
-
const data = processed.data;
|
|
93
|
-
const dataLength = data.length;
|
|
94
|
-
for (let i = 0; i < dataLength; i += 1) {
|
|
95
|
-
const bar = data[i];
|
|
96
|
-
if (bar.hidden) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const value = bar.value;
|
|
100
|
-
if (value == null) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const w = bar.width;
|
|
104
|
-
const h = bar.height;
|
|
105
|
-
if (w <= 0 || h <= 0) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const halfW = w * 0.5;
|
|
109
|
-
const halfH = h * 0.5;
|
|
110
|
-
const c2 = cursor * 2;
|
|
111
|
-
centers[c2] = bar.x + halfW - drawingAreaLeft;
|
|
112
|
-
centers[c2 + 1] = bar.y + halfH - drawingAreaTop;
|
|
113
|
-
halfSizes[c2] = halfW;
|
|
114
|
-
halfSizes[c2 + 1] = halfH;
|
|
115
|
-
const rgba = (0, _parseColor.parseColor)(bar.color);
|
|
116
|
-
const c4 = cursor * 4;
|
|
117
|
-
let r = rgba[0];
|
|
118
|
-
let g = rgba[1];
|
|
119
|
-
let b = rgba[2];
|
|
120
|
-
let a = rgba[3];
|
|
121
|
-
const highlightState = getHighlightState({
|
|
122
|
-
type: 'bar',
|
|
123
|
-
seriesId,
|
|
124
|
-
dataIndex: bar.dataIndex
|
|
125
|
-
});
|
|
126
|
-
if (highlightState === 'highlighted') {
|
|
127
|
-
r = Math.min(255, r * HIGHLIGHTED_BRIGHTNESS);
|
|
128
|
-
g = Math.min(255, g * HIGHLIGHTED_BRIGHTNESS);
|
|
129
|
-
b = Math.min(255, b * HIGHLIGHTED_BRIGHTNESS);
|
|
130
|
-
} else if (highlightState === 'faded') {
|
|
131
|
-
a *= FADED_OPACITY;
|
|
132
|
-
}
|
|
133
|
-
colors[c4] = r;
|
|
134
|
-
colors[c4 + 1] = g;
|
|
135
|
-
colors[c4 + 2] = b;
|
|
136
|
-
colors[c4 + 3] = a;
|
|
137
|
-
const effectiveRadius = Math.min(borderRadius, halfW, halfH);
|
|
138
|
-
setCornerRadii(effectiveRadius, bar.borderRadiusSide, cornerRadii, c4);
|
|
139
|
-
cursor += 1;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (cursor === 0) {
|
|
143
|
-
return EMPTY_DATA;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Return fresh subarray views over the pooled buffers. New view refs each call
|
|
147
|
-
// (so React memoisation is correct and consumers can detect a change), but no
|
|
148
|
-
// new bytes allocated on the JS heap. The GPU upload short-circuits via the
|
|
149
|
-
// `lastUploaded === data` ref check on the program side when we hand the
|
|
150
|
-
// exact same view back across renders -- it won't fire here since each call
|
|
151
|
-
// produces a new view, but the contents have changed anyway in that case.
|
|
152
|
-
return {
|
|
153
|
-
centers: new Float32Array(centers.buffer, centers.byteOffset, cursor * 2),
|
|
154
|
-
halfSizes: new Float32Array(halfSizes.buffer, halfSizes.byteOffset, cursor * 2),
|
|
155
|
-
colors: new Uint8Array(colors.buffer, colors.byteOffset, cursor * 4),
|
|
156
|
-
cornerRadii: new Float32Array(cornerRadii.buffer, cornerRadii.byteOffset, cursor * 4),
|
|
157
|
-
count: cursor
|
|
158
|
-
};
|
|
159
|
-
}, [borderRadius, completedData, drawingArea.left, drawingArea.top, getHighlightState]);
|
|
10
|
+
return (0, _useWebGLBarLikePlotData.useWebGLBarLikePlotData)(drawingArea, completedData, borderRadius, {
|
|
11
|
+
highlightType: 'bar'
|
|
12
|
+
});
|
|
160
13
|
}
|
|
@@ -1,154 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { selectorChartsHighlightStateCallback, useStore } from '@mui/x-charts/internals';
|
|
5
|
-
import { parseColor } from "../../utils/webgl/parseColor.mjs";
|
|
6
|
-
const EMPTY_FLOAT32 = new Float32Array(0);
|
|
7
|
-
const EMPTY_UINT8 = new Uint8Array(0);
|
|
8
|
-
const EMPTY_DATA = {
|
|
9
|
-
centers: EMPTY_FLOAT32,
|
|
10
|
-
halfSizes: EMPTY_FLOAT32,
|
|
11
|
-
colors: EMPTY_UINT8,
|
|
12
|
-
cornerRadii: EMPTY_FLOAT32,
|
|
13
|
-
count: 0
|
|
14
|
-
};
|
|
15
|
-
function ensureCapacity(pool, maxCount) {
|
|
16
|
-
if (pool !== null && pool.colors.length >= maxCount * 4) {
|
|
17
|
-
return pool;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
centers: new Float32Array(maxCount * 2),
|
|
21
|
-
halfSizes: new Float32Array(maxCount * 2),
|
|
22
|
-
colors: new Uint8Array(maxCount * 4),
|
|
23
|
-
cornerRadii: new Float32Array(maxCount * 4)
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Mirrors SVG highlight styling: highlighted -> CSS `brightness(120%)`,
|
|
28
|
-
// faded -> opacity 0.3. Baking these into the per-bar color array means we
|
|
29
|
-
// don't need a separate per-instance attribute on the GPU side.
|
|
30
|
-
const HIGHLIGHTED_BRIGHTNESS = 1.2;
|
|
31
|
-
const FADED_OPACITY = 0.3;
|
|
32
|
-
function setCornerRadii(radius, side, target, offset) {
|
|
33
|
-
// CSS order: top-left, top-right, bottom-right, bottom-left.
|
|
34
|
-
let tl = 0;
|
|
35
|
-
let tr = 0;
|
|
36
|
-
let br = 0;
|
|
37
|
-
let bl = 0;
|
|
38
|
-
if (radius > 0) {
|
|
39
|
-
if (side === 'top') {
|
|
40
|
-
tl = radius;
|
|
41
|
-
tr = radius;
|
|
42
|
-
} else if (side === 'bottom') {
|
|
43
|
-
br = radius;
|
|
44
|
-
bl = radius;
|
|
45
|
-
} else if (side === 'left') {
|
|
46
|
-
tl = radius;
|
|
47
|
-
bl = radius;
|
|
48
|
-
} else if (side === 'right') {
|
|
49
|
-
tr = radius;
|
|
50
|
-
br = radius;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
target[offset] = tl;
|
|
54
|
-
target[offset + 1] = tr;
|
|
55
|
-
target[offset + 2] = br;
|
|
56
|
-
target[offset + 3] = bl;
|
|
57
|
-
}
|
|
3
|
+
import { useWebGLBarLikePlotData } from "./useWebGLBarLikePlotData.mjs";
|
|
58
4
|
export function useBarWebGLPlotData(drawingArea, completedData, borderRadius) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return React.useMemo(() => {
|
|
63
|
-
let maxCount = 0;
|
|
64
|
-
for (let s = 0; s < completedData.length; s += 1) {
|
|
65
|
-
maxCount += completedData[s].data.length;
|
|
66
|
-
}
|
|
67
|
-
if (maxCount === 0) {
|
|
68
|
-
return EMPTY_DATA;
|
|
69
|
-
}
|
|
70
|
-
const pool = ensureCapacity(poolRef.current, maxCount);
|
|
71
|
-
poolRef.current = pool;
|
|
72
|
-
|
|
73
|
-
// Hoist invariants out of the hot loop.
|
|
74
|
-
const {
|
|
75
|
-
centers,
|
|
76
|
-
halfSizes,
|
|
77
|
-
colors,
|
|
78
|
-
cornerRadii
|
|
79
|
-
} = pool;
|
|
80
|
-
const drawingAreaLeft = drawingArea.left;
|
|
81
|
-
const drawingAreaTop = drawingArea.top;
|
|
82
|
-
let cursor = 0;
|
|
83
|
-
for (let s = 0; s < completedData.length; s += 1) {
|
|
84
|
-
const processed = completedData[s];
|
|
85
|
-
const seriesId = processed.seriesId;
|
|
86
|
-
const data = processed.data;
|
|
87
|
-
const dataLength = data.length;
|
|
88
|
-
for (let i = 0; i < dataLength; i += 1) {
|
|
89
|
-
const bar = data[i];
|
|
90
|
-
if (bar.hidden) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const value = bar.value;
|
|
94
|
-
if (value == null) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
const w = bar.width;
|
|
98
|
-
const h = bar.height;
|
|
99
|
-
if (w <= 0 || h <= 0) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
const halfW = w * 0.5;
|
|
103
|
-
const halfH = h * 0.5;
|
|
104
|
-
const c2 = cursor * 2;
|
|
105
|
-
centers[c2] = bar.x + halfW - drawingAreaLeft;
|
|
106
|
-
centers[c2 + 1] = bar.y + halfH - drawingAreaTop;
|
|
107
|
-
halfSizes[c2] = halfW;
|
|
108
|
-
halfSizes[c2 + 1] = halfH;
|
|
109
|
-
const rgba = parseColor(bar.color);
|
|
110
|
-
const c4 = cursor * 4;
|
|
111
|
-
let r = rgba[0];
|
|
112
|
-
let g = rgba[1];
|
|
113
|
-
let b = rgba[2];
|
|
114
|
-
let a = rgba[3];
|
|
115
|
-
const highlightState = getHighlightState({
|
|
116
|
-
type: 'bar',
|
|
117
|
-
seriesId,
|
|
118
|
-
dataIndex: bar.dataIndex
|
|
119
|
-
});
|
|
120
|
-
if (highlightState === 'highlighted') {
|
|
121
|
-
r = Math.min(255, r * HIGHLIGHTED_BRIGHTNESS);
|
|
122
|
-
g = Math.min(255, g * HIGHLIGHTED_BRIGHTNESS);
|
|
123
|
-
b = Math.min(255, b * HIGHLIGHTED_BRIGHTNESS);
|
|
124
|
-
} else if (highlightState === 'faded') {
|
|
125
|
-
a *= FADED_OPACITY;
|
|
126
|
-
}
|
|
127
|
-
colors[c4] = r;
|
|
128
|
-
colors[c4 + 1] = g;
|
|
129
|
-
colors[c4 + 2] = b;
|
|
130
|
-
colors[c4 + 3] = a;
|
|
131
|
-
const effectiveRadius = Math.min(borderRadius, halfW, halfH);
|
|
132
|
-
setCornerRadii(effectiveRadius, bar.borderRadiusSide, cornerRadii, c4);
|
|
133
|
-
cursor += 1;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (cursor === 0) {
|
|
137
|
-
return EMPTY_DATA;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Return fresh subarray views over the pooled buffers. New view refs each call
|
|
141
|
-
// (so React memoisation is correct and consumers can detect a change), but no
|
|
142
|
-
// new bytes allocated on the JS heap. The GPU upload short-circuits via the
|
|
143
|
-
// `lastUploaded === data` ref check on the program side when we hand the
|
|
144
|
-
// exact same view back across renders -- it won't fire here since each call
|
|
145
|
-
// produces a new view, but the contents have changed anyway in that case.
|
|
146
|
-
return {
|
|
147
|
-
centers: new Float32Array(centers.buffer, centers.byteOffset, cursor * 2),
|
|
148
|
-
halfSizes: new Float32Array(halfSizes.buffer, halfSizes.byteOffset, cursor * 2),
|
|
149
|
-
colors: new Uint8Array(colors.buffer, colors.byteOffset, cursor * 4),
|
|
150
|
-
cornerRadii: new Float32Array(cornerRadii.buffer, cornerRadii.byteOffset, cursor * 4),
|
|
151
|
-
count: cursor
|
|
152
|
-
};
|
|
153
|
-
}, [borderRadius, completedData, drawingArea.left, drawingArea.top, getHighlightState]);
|
|
5
|
+
return useWebGLBarLikePlotData(drawingArea, completedData, borderRadius, {
|
|
6
|
+
highlightType: 'bar'
|
|
7
|
+
});
|
|
154
8
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ChartDrawingArea } from '@mui/x-charts/hooks';
|
|
2
|
+
import { type BorderRadiusSide } from '@mui/x-charts/internals';
|
|
3
|
+
import { type SeriesId } from '@mui/x-charts/models';
|
|
4
|
+
export interface WebGLBarLikeItem {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
value: unknown;
|
|
10
|
+
hidden: boolean;
|
|
11
|
+
color: string;
|
|
12
|
+
dataIndex: number;
|
|
13
|
+
borderRadiusSide?: BorderRadiusSide;
|
|
14
|
+
}
|
|
15
|
+
export interface WebGLBarLikeSeries<T extends WebGLBarLikeItem> {
|
|
16
|
+
seriesId: SeriesId;
|
|
17
|
+
data: readonly T[];
|
|
18
|
+
}
|
|
19
|
+
export interface WebGLBarLikePlotData {
|
|
20
|
+
centers: Float32Array;
|
|
21
|
+
halfSizes: Float32Array;
|
|
22
|
+
colors: Uint8Array;
|
|
23
|
+
cornerRadii: Float32Array;
|
|
24
|
+
count: number;
|
|
25
|
+
}
|
|
26
|
+
export interface UseWebGLBarLikePlotDataOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Series identifier passed to the highlight selector. Allows the shared
|
|
29
|
+
* implementation to be used for both `'bar'` and `'rangeBar'` series.
|
|
30
|
+
*/
|
|
31
|
+
highlightType: 'bar' | 'rangeBar';
|
|
32
|
+
/**
|
|
33
|
+
* When true, the border radius is applied to all four corners regardless of
|
|
34
|
+
* the per-item `borderRadiusSide` value. Range bars use this since they
|
|
35
|
+
* aren't stacked.
|
|
36
|
+
*/
|
|
37
|
+
fullRoundedCorners?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function useWebGLBarLikePlotData<T extends WebGLBarLikeItem>(drawingArea: ChartDrawingArea, completedData: readonly WebGLBarLikeSeries<T>[], borderRadius: number, options: UseWebGLBarLikePlotDataOptions): WebGLBarLikePlotData;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ChartDrawingArea } from '@mui/x-charts/hooks';
|
|
2
|
+
import { type BorderRadiusSide } from '@mui/x-charts/internals';
|
|
3
|
+
import { type SeriesId } from '@mui/x-charts/models';
|
|
4
|
+
export interface WebGLBarLikeItem {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
value: unknown;
|
|
10
|
+
hidden: boolean;
|
|
11
|
+
color: string;
|
|
12
|
+
dataIndex: number;
|
|
13
|
+
borderRadiusSide?: BorderRadiusSide;
|
|
14
|
+
}
|
|
15
|
+
export interface WebGLBarLikeSeries<T extends WebGLBarLikeItem> {
|
|
16
|
+
seriesId: SeriesId;
|
|
17
|
+
data: readonly T[];
|
|
18
|
+
}
|
|
19
|
+
export interface WebGLBarLikePlotData {
|
|
20
|
+
centers: Float32Array;
|
|
21
|
+
halfSizes: Float32Array;
|
|
22
|
+
colors: Uint8Array;
|
|
23
|
+
cornerRadii: Float32Array;
|
|
24
|
+
count: number;
|
|
25
|
+
}
|
|
26
|
+
export interface UseWebGLBarLikePlotDataOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Series identifier passed to the highlight selector. Allows the shared
|
|
29
|
+
* implementation to be used for both `'bar'` and `'rangeBar'` series.
|
|
30
|
+
*/
|
|
31
|
+
highlightType: 'bar' | 'rangeBar';
|
|
32
|
+
/**
|
|
33
|
+
* When true, the border radius is applied to all four corners regardless of
|
|
34
|
+
* the per-item `borderRadiusSide` value. Range bars use this since they
|
|
35
|
+
* aren't stacked.
|
|
36
|
+
*/
|
|
37
|
+
fullRoundedCorners?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function useWebGLBarLikePlotData<T extends WebGLBarLikeItem>(drawingArea: ChartDrawingArea, completedData: readonly WebGLBarLikeSeries<T>[], borderRadius: number, options: UseWebGLBarLikePlotDataOptions): WebGLBarLikePlotData;
|