@mui/x-charts-premium 9.0.2 → 9.0.4
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/RangeBar/FocusedRangeBar.js +3 -0
- package/BarChartPremium/RangeBar/FocusedRangeBar.mjs +3 -0
- package/CHANGELOG.md +223 -0
- package/CandlestickChart/CandlestickPlot.js +27 -31
- package/CandlestickChart/CandlestickPlot.mjs +27 -31
- package/CandlestickChart/CandlestickWebGLProgram.js +0 -3
- package/CandlestickChart/CandlestickWebGLProgram.mjs +0 -3
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.mts +35 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.ts +35 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +126 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +120 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.plugins.d.mts +5 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.plugins.d.ts +5 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.plugins.js +9 -0
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.plugins.mjs +3 -0
- package/ChartsRadialDataProviderPremium/index.d.mts +3 -0
- package/ChartsRadialDataProviderPremium/index.d.ts +3 -0
- package/ChartsRadialDataProviderPremium/index.js +20 -0
- package/ChartsRadialDataProviderPremium/index.mjs +3 -0
- package/ChartsRadialDataProviderPremium/useChartsRadialDataProviderPremiumProps.d.mts +10 -0
- package/ChartsRadialDataProviderPremium/useChartsRadialDataProviderPremiumProps.d.ts +10 -0
- package/ChartsRadialDataProviderPremium/useChartsRadialDataProviderPremiumProps.js +25 -0
- package/ChartsRadialDataProviderPremium/useChartsRadialDataProviderPremiumProps.mjs +19 -0
- package/ChartsRadiusAxis/index.d.mts +1 -0
- package/ChartsRadiusAxis/index.d.ts +1 -0
- package/ChartsRadiusAxis/index.js +16 -0
- package/ChartsRadiusAxis/index.mjs +2 -0
- package/ChartsRotationAxis/index.d.mts +1 -0
- package/ChartsRotationAxis/index.d.ts +1 -0
- package/ChartsRotationAxis/index.js +16 -0
- package/ChartsRotationAxis/index.mjs +2 -0
- package/ChartsWebGLLayer/ChartsWebGLContext.d.mts +5 -0
- package/ChartsWebGLLayer/ChartsWebGLContext.d.ts +5 -0
- package/ChartsWebGLLayer/ChartsWebGLContext.js +31 -0
- package/ChartsWebGLLayer/ChartsWebGLContext.mjs +23 -0
- package/ChartsWebGLLayer/ChartsWebGLLayer.d.mts +0 -1
- package/ChartsWebGLLayer/ChartsWebGLLayer.d.ts +0 -1
- package/ChartsWebGLLayer/ChartsWebGLLayer.js +63 -12
- package/ChartsWebGLLayer/ChartsWebGLLayer.mjs +62 -10
- package/ChartsWebGLLayer/ChartsWebGLLayer.types.d.mts +26 -0
- package/ChartsWebGLLayer/ChartsWebGLLayer.types.d.ts +26 -0
- package/ChartsWebGLLayer/ChartsWebGLLayer.types.js +5 -0
- package/ChartsWebGLLayer/ChartsWebGLLayer.types.mjs +1 -0
- package/ChartsWebGLLayer/ChartsWebGLOrderContext.d.mts +6 -0
- package/ChartsWebGLLayer/ChartsWebGLOrderContext.d.ts +6 -0
- package/ChartsWebGLLayer/ChartsWebGLOrderContext.js +15 -0
- package/ChartsWebGLLayer/ChartsWebGLOrderContext.mjs +10 -0
- package/HeatmapPremium/HeatmapPlotPremium.js +2 -2
- package/HeatmapPremium/HeatmapPlotPremium.mjs +2 -2
- package/HeatmapPremium/webgl/HeatmapWebGLPlot.js +26 -33
- package/HeatmapPremium/webgl/HeatmapWebGLPlot.mjs +26 -33
- package/HeatmapPremium/webgl/shaders.d.mts +1 -1
- package/HeatmapPremium/webgl/shaders.d.ts +1 -1
- package/HeatmapPremium/webgl/shaders.js +1 -1
- package/HeatmapPremium/webgl/shaders.mjs +1 -1
- package/RadialBarChart/seriesConfig/axisTooltipGetter.d.mts +2 -0
- package/RadialBarChart/seriesConfig/axisTooltipGetter.d.ts +2 -0
- package/RadialBarChart/seriesConfig/axisTooltipGetter.js +13 -0
- package/RadialBarChart/seriesConfig/axisTooltipGetter.mjs +6 -0
- package/RadialBarChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/RadialBarChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/RadialBarChart/seriesConfig/descriptionGetter.js +34 -0
- package/RadialBarChart/seriesConfig/descriptionGetter.mjs +28 -0
- package/RadialBarChart/seriesConfig/extremums.d.mts +3 -0
- package/RadialBarChart/seriesConfig/extremums.d.ts +3 -0
- package/RadialBarChart/seriesConfig/extremums.js +44 -0
- package/RadialBarChart/seriesConfig/extremums.mjs +36 -0
- package/RadialBarChart/seriesConfig/getColor.d.mts +3 -0
- package/RadialBarChart/seriesConfig/getColor.d.ts +3 -0
- package/RadialBarChart/seriesConfig/getColor.js +61 -0
- package/RadialBarChart/seriesConfig/getColor.mjs +55 -0
- package/RadialBarChart/seriesConfig/getSeriesWithDefaultValues.d.mts +3 -0
- package/RadialBarChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
- package/RadialBarChart/seriesConfig/getSeriesWithDefaultValues.js +16 -0
- package/RadialBarChart/seriesConfig/getSeriesWithDefaultValues.mjs +9 -0
- package/RadialBarChart/seriesConfig/index.d.mts +2 -0
- package/RadialBarChart/seriesConfig/index.d.ts +2 -0
- package/RadialBarChart/seriesConfig/index.js +37 -0
- package/RadialBarChart/seriesConfig/index.mjs +30 -0
- package/RadialBarChart/seriesConfig/keyboardFocusHandler.d.mts +3 -0
- package/RadialBarChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/RadialBarChart/seriesConfig/keyboardFocusHandler.js +9 -0
- package/RadialBarChart/seriesConfig/keyboardFocusHandler.mjs +3 -0
- package/RadialBarChart/seriesConfig/legend.d.mts +3 -0
- package/RadialBarChart/seriesConfig/legend.d.ts +3 -0
- package/RadialBarChart/seriesConfig/legend.js +9 -0
- package/RadialBarChart/seriesConfig/legend.mjs +3 -0
- package/RadialBarChart/seriesConfig/seriesProcessor.d.mts +3 -0
- package/RadialBarChart/seriesConfig/seriesProcessor.d.ts +3 -0
- package/RadialBarChart/seriesConfig/seriesProcessor.js +137 -0
- package/RadialBarChart/seriesConfig/seriesProcessor.mjs +130 -0
- package/RadialBarChart/seriesConfig/tooltip.d.mts +3 -0
- package/RadialBarChart/seriesConfig/tooltip.d.ts +3 -0
- package/RadialBarChart/seriesConfig/tooltip.js +34 -0
- package/RadialBarChart/seriesConfig/tooltip.mjs +28 -0
- package/RadialBarChart/seriesConfig/tooltipPosition.d.mts +3 -0
- package/RadialBarChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/RadialBarChart/seriesConfig/tooltipPosition.js +11 -0
- package/RadialBarChart/seriesConfig/tooltipPosition.mjs +5 -0
- package/RadialLineChart/RadialArea.d.mts +12 -0
- package/RadialLineChart/RadialArea.d.ts +12 -0
- package/RadialLineChart/RadialArea.js +33 -0
- package/RadialLineChart/RadialArea.mjs +26 -0
- package/RadialLineChart/RadialAreaPlot.d.mts +5 -0
- package/RadialLineChart/RadialAreaPlot.d.ts +5 -0
- package/RadialLineChart/RadialAreaPlot.js +51 -0
- package/RadialLineChart/RadialAreaPlot.mjs +45 -0
- package/RadialLineChart/RadialLine.d.mts +12 -0
- package/RadialLineChart/RadialLine.d.ts +12 -0
- package/RadialLineChart/RadialLine.js +33 -0
- package/RadialLineChart/RadialLine.mjs +26 -0
- package/RadialLineChart/RadialLineChart.d.mts +62 -0
- package/RadialLineChart/RadialLineChart.d.ts +62 -0
- package/RadialLineChart/RadialLineChart.js +967 -0
- package/RadialLineChart/RadialLineChart.mjs +960 -0
- package/RadialLineChart/RadialLineChart.plugins.d.mts +4 -0
- package/RadialLineChart/RadialLineChart.plugins.d.ts +4 -0
- package/RadialLineChart/RadialLineChart.plugins.js +9 -0
- package/RadialLineChart/RadialLineChart.plugins.mjs +3 -0
- package/RadialLineChart/RadialLinePlot.d.mts +5 -0
- package/RadialLineChart/RadialLinePlot.d.ts +5 -0
- package/RadialLineChart/RadialLinePlot.js +50 -0
- package/RadialLineChart/RadialLinePlot.mjs +44 -0
- package/RadialLineChart/RadialMarkPlot.d.mts +5 -0
- package/RadialLineChart/RadialMarkPlot.d.ts +5 -0
- package/RadialLineChart/RadialMarkPlot.js +62 -0
- package/RadialLineChart/RadialMarkPlot.mjs +56 -0
- package/RadialLineChart/index.d.mts +4 -0
- package/RadialLineChart/index.d.ts +4 -0
- package/RadialLineChart/index.js +49 -0
- package/RadialLineChart/index.mjs +4 -0
- package/RadialLineChart/radialLineClasses.d.mts +25 -0
- package/RadialLineChart/radialLineClasses.d.ts +25 -0
- package/RadialLineChart/radialLineClasses.js +30 -0
- package/RadialLineChart/radialLineClasses.mjs +21 -0
- package/RadialLineChart/seriesConfig/axisTooltipGetter.d.mts +2 -0
- package/RadialLineChart/seriesConfig/axisTooltipGetter.d.ts +2 -0
- package/RadialLineChart/seriesConfig/axisTooltipGetter.js +13 -0
- package/RadialLineChart/seriesConfig/axisTooltipGetter.mjs +6 -0
- package/RadialLineChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/RadialLineChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/RadialLineChart/seriesConfig/descriptionGetter.js +39 -0
- package/RadialLineChart/seriesConfig/descriptionGetter.mjs +33 -0
- package/RadialLineChart/seriesConfig/extremums.d.mts +3 -0
- package/RadialLineChart/seriesConfig/extremums.d.ts +3 -0
- package/RadialLineChart/seriesConfig/extremums.js +48 -0
- package/RadialLineChart/seriesConfig/extremums.mjs +40 -0
- package/RadialLineChart/seriesConfig/getColor.d.mts +3 -0
- package/RadialLineChart/seriesConfig/getColor.d.ts +3 -0
- package/RadialLineChart/seriesConfig/getColor.js +61 -0
- package/RadialLineChart/seriesConfig/getColor.mjs +55 -0
- package/RadialLineChart/seriesConfig/getSeriesWithDefaultValues.d.mts +3 -0
- package/RadialLineChart/seriesConfig/getSeriesWithDefaultValues.d.ts +3 -0
- package/RadialLineChart/seriesConfig/getSeriesWithDefaultValues.js +13 -0
- package/RadialLineChart/seriesConfig/getSeriesWithDefaultValues.mjs +6 -0
- package/RadialLineChart/seriesConfig/index.d.mts +2 -0
- package/RadialLineChart/seriesConfig/index.d.ts +2 -0
- package/RadialLineChart/seriesConfig/index.js +37 -0
- package/RadialLineChart/seriesConfig/index.mjs +30 -0
- package/RadialLineChart/seriesConfig/keyboardFocusHandler.d.mts +3 -0
- package/RadialLineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/RadialLineChart/seriesConfig/keyboardFocusHandler.js +9 -0
- package/RadialLineChart/seriesConfig/keyboardFocusHandler.mjs +3 -0
- package/RadialLineChart/seriesConfig/legend.d.mts +3 -0
- package/RadialLineChart/seriesConfig/legend.d.ts +3 -0
- package/RadialLineChart/seriesConfig/legend.js +29 -0
- package/RadialLineChart/seriesConfig/legend.mjs +23 -0
- package/RadialLineChart/seriesConfig/seriesProcessor.d.mts +3 -0
- package/RadialLineChart/seriesConfig/seriesProcessor.d.ts +3 -0
- package/RadialLineChart/seriesConfig/seriesProcessor.js +142 -0
- package/RadialLineChart/seriesConfig/seriesProcessor.mjs +135 -0
- package/RadialLineChart/seriesConfig/tooltip.d.mts +3 -0
- package/RadialLineChart/seriesConfig/tooltip.d.ts +3 -0
- package/RadialLineChart/seriesConfig/tooltip.js +32 -0
- package/RadialLineChart/seriesConfig/tooltip.mjs +26 -0
- package/RadialLineChart/seriesConfig/tooltipPosition.d.mts +3 -0
- package/RadialLineChart/seriesConfig/tooltipPosition.d.ts +3 -0
- package/RadialLineChart/seriesConfig/tooltipPosition.js +11 -0
- package/RadialLineChart/seriesConfig/tooltipPosition.mjs +5 -0
- package/RadialLineChart/useRadialLineChartProps.d.mts +28 -0
- package/RadialLineChart/useRadialLineChartProps.d.ts +28 -0
- package/RadialLineChart/useRadialLineChartProps.js +99 -0
- package/RadialLineChart/useRadialLineChartProps.mjs +92 -0
- package/RadialLineChart/useRadialLinePlotData.d.mts +21 -0
- package/RadialLineChart/useRadialLinePlotData.d.ts +21 -0
- package/RadialLineChart/useRadialLinePlotData.js +82 -0
- package/RadialLineChart/useRadialLinePlotData.mjs +75 -0
- package/hooks/useRadialLineSeries.d.mts +34 -0
- package/hooks/useRadialLineSeries.d.ts +34 -0
- package/hooks/useRadialLineSeries.js +45 -0
- package/hooks/useRadialLineSeries.mjs +40 -0
- package/index.d.mts +7 -1
- package/index.d.ts +7 -1
- package/index.js +69 -1
- package/index.mjs +8 -2
- package/models/seriesType/index.d.mts +3 -1
- package/models/seriesType/index.d.ts +3 -1
- package/models/seriesType/index.js +22 -0
- package/models/seriesType/index.mjs +3 -1
- package/models/seriesType/radialBar.d.mts +23 -0
- package/models/seriesType/radialBar.d.ts +23 -0
- package/models/seriesType/radialBar.js +5 -0
- package/models/seriesType/radialBar.mjs +1 -0
- package/models/seriesType/radialLine.d.mts +26 -0
- package/models/seriesType/radialLine.d.ts +26 -0
- package/models/seriesType/radialLine.js +5 -0
- package/models/seriesType/radialLine.mjs +1 -0
- package/package.json +62 -6
- package/typeOverloads/modules.d.mts +48 -2
- package/typeOverloads/modules.d.ts +48 -2
- package/utils/webgl/useWebGLResizeObserver.d.mts +3 -2
- package/utils/webgl/useWebGLResizeObserver.d.ts +3 -2
- package/utils/webgl/useWebGLResizeObserver.js +3 -4
- package/utils/webgl/useWebGLResizeObserver.mjs +3 -4
- package/HeatmapPremium/webgl/HeatmapWebGLRenderer.d.mts +0 -4
- package/HeatmapPremium/webgl/HeatmapWebGLRenderer.d.ts +0 -4
- package/HeatmapPremium/webgl/HeatmapWebGLRenderer.js +0 -21
- package/HeatmapPremium/webgl/HeatmapWebGLRenderer.mjs +0 -15
|
@@ -8,23 +8,67 @@ import * as React from 'react';
|
|
|
8
8
|
import useForkRef from '@mui/utils/useForkRef';
|
|
9
9
|
import { selectorChartSvgHeight, selectorChartSvgWidth, useStore } from '@mui/x-charts/internals';
|
|
10
10
|
import { useDrawingArea, useChartRootRef } from '@mui/x-charts/hooks';
|
|
11
|
+
import { useWebGLResizeObserver } from "../utils/webgl/useWebGLResizeObserver.mjs";
|
|
12
|
+
import { ChartsWebGLContext } from "./ChartsWebGLContext.mjs";
|
|
13
|
+
import { ChartsWebGLOrderContext } from "./ChartsWebGLOrderContext.mjs";
|
|
11
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
const ChartsWebGLContext = /*#__PURE__*/React.createContext(null);
|
|
13
|
-
if (process.env.NODE_ENV !== "production") ChartsWebGLContext.displayName = "ChartsWebGLContext";
|
|
14
|
-
export function useWebGLContext() {
|
|
15
|
-
return React.useContext(ChartsWebGLContext);
|
|
16
|
-
}
|
|
17
15
|
export const ChartsWebGLLayer = /*#__PURE__*/React.forwardRef(function WebGLProvider(_ref, ref) {
|
|
18
16
|
let {
|
|
19
17
|
children
|
|
20
18
|
} = _ref,
|
|
21
19
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
20
|
const canvasRef = React.useRef(null);
|
|
23
|
-
const [
|
|
21
|
+
const [glContext, setGlContext] = React.useState(null);
|
|
24
22
|
const handleRef = useForkRef(canvasRef, ref);
|
|
25
23
|
const chartRoot = useChartRootRef().current;
|
|
26
24
|
const drawingArea = useDrawingArea();
|
|
27
25
|
const [, rerender] = React.useReducer(s => s + 1, 0);
|
|
26
|
+
const drawEntriesRef = React.useRef([]);
|
|
27
|
+
const renderScheduledRef = React.useRef(false);
|
|
28
|
+
const renderAll = React.useCallback(() => {
|
|
29
|
+
if (!glContext) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
renderScheduledRef.current = false;
|
|
33
|
+
glContext.clearColor(0, 0, 0, 0.0);
|
|
34
|
+
glContext.clear(glContext.COLOR_BUFFER_BIT);
|
|
35
|
+
// Sort by order so z-order matches children's position in ChartsWebGLLayer,
|
|
36
|
+
// stable across remount.
|
|
37
|
+
const sorted = [...drawEntriesRef.current].sort((a, b) => a.order - b.order);
|
|
38
|
+
for (const {
|
|
39
|
+
drawRef
|
|
40
|
+
} of sorted) {
|
|
41
|
+
drawRef.current?.();
|
|
42
|
+
}
|
|
43
|
+
}, [glContext]);
|
|
44
|
+
const registerDraw = React.useCallback((drawRef, order) => {
|
|
45
|
+
const entry = {
|
|
46
|
+
drawRef,
|
|
47
|
+
order
|
|
48
|
+
};
|
|
49
|
+
drawEntriesRef.current.push(entry);
|
|
50
|
+
return () => {
|
|
51
|
+
const idx = drawEntriesRef.current.indexOf(entry);
|
|
52
|
+
if (idx >= 0) {
|
|
53
|
+
drawEntriesRef.current.splice(idx, 1);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
const requestRender = React.useCallback(() => {
|
|
58
|
+
renderScheduledRef.current = true;
|
|
59
|
+
// Trigger a re-render so the flush effect runs, even if only a child's state changed
|
|
60
|
+
rerender();
|
|
61
|
+
}, []);
|
|
62
|
+
|
|
63
|
+
// Centralized resize handling — render all plots on canvas resize
|
|
64
|
+
useWebGLResizeObserver(glContext, renderAll);
|
|
65
|
+
|
|
66
|
+
// Flush scheduled renders after all children's effects have run
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (renderScheduledRef.current) {
|
|
69
|
+
renderAll();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
28
72
|
React.useEffect(() => {
|
|
29
73
|
/* The chart root isn't available on first render because the ref is only set after mounting the root component. */
|
|
30
74
|
if (!chartRoot) {
|
|
@@ -40,7 +84,7 @@ export const ChartsWebGLLayer = /*#__PURE__*/React.forwardRef(function WebGLProv
|
|
|
40
84
|
// Must prevent default otherwise the context won't be marked as restorable
|
|
41
85
|
// https://registry.khronos.org/webgl/extensions/WEBGL_lose_context/
|
|
42
86
|
event.preventDefault();
|
|
43
|
-
|
|
87
|
+
setGlContext(null);
|
|
44
88
|
};
|
|
45
89
|
const initializeContext = () => {
|
|
46
90
|
const ctx = canvas.getContext('webgl2', {
|
|
@@ -52,7 +96,7 @@ export const ChartsWebGLLayer = /*#__PURE__*/React.forwardRef(function WebGLProv
|
|
|
52
96
|
if (!ctx) {
|
|
53
97
|
return;
|
|
54
98
|
}
|
|
55
|
-
|
|
99
|
+
setGlContext(ctx);
|
|
56
100
|
};
|
|
57
101
|
canvas.addEventListener('webglcontextlost', handleContextLost);
|
|
58
102
|
canvas.addEventListener('webglcontextrestored', initializeContext);
|
|
@@ -62,11 +106,16 @@ export const ChartsWebGLLayer = /*#__PURE__*/React.forwardRef(function WebGLProv
|
|
|
62
106
|
canvas.removeEventListener('webglcontextrestored', initializeContext);
|
|
63
107
|
};
|
|
64
108
|
}, [chartRoot]);
|
|
109
|
+
const contextValue = React.useMemo(() => glContext ? {
|
|
110
|
+
gl: glContext,
|
|
111
|
+
registerDraw,
|
|
112
|
+
requestRender
|
|
113
|
+
} : null, [glContext, registerDraw, requestRender]);
|
|
65
114
|
if (!chartRoot) {
|
|
66
115
|
return null;
|
|
67
116
|
}
|
|
68
117
|
return /*#__PURE__*/_jsxs(ChartsWebGLContext.Provider, {
|
|
69
|
-
value:
|
|
118
|
+
value: contextValue,
|
|
70
119
|
children: [/*#__PURE__*/_jsx(CanvasPositioner, {
|
|
71
120
|
"aria-hidden": "true",
|
|
72
121
|
children: /*#__PURE__*/_jsx("canvas", _extends({
|
|
@@ -80,7 +129,10 @@ export const ChartsWebGLLayer = /*#__PURE__*/React.forwardRef(function WebGLProv
|
|
|
80
129
|
height: drawingArea.height
|
|
81
130
|
}
|
|
82
131
|
}))
|
|
83
|
-
}), children
|
|
132
|
+
}), React.Children.map(children, (child, index) => /*#__PURE__*/_jsx(ChartsWebGLOrderContext.Provider, {
|
|
133
|
+
value: index,
|
|
134
|
+
children: child
|
|
135
|
+
}))]
|
|
84
136
|
});
|
|
85
137
|
});
|
|
86
138
|
if (process.env.NODE_ENV !== "production") ChartsWebGLLayer.displayName = "ChartsWebGLLayer";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export type DrawEntry = {
|
|
3
|
+
drawRef: React.RefObject<(() => void) | null>;
|
|
4
|
+
order: number;
|
|
5
|
+
};
|
|
6
|
+
export interface ChartsWebGLContextValue {
|
|
7
|
+
gl: WebGL2RenderingContext;
|
|
8
|
+
/**
|
|
9
|
+
* Register a draw callback ref. Returns an unregister function.
|
|
10
|
+
* Callbacks are sorted by the provided `order` number so z-order follows the children's position
|
|
11
|
+
* in `ChartsWebGLLayer`, stable across unmount/remount (e.g. toggled via series visibility).
|
|
12
|
+
* @param {React.RefObject} drawRef A ref object whose current property is a draw callback function. The callback will be called with the WebGL context already set to this layer's canvas. Set to null to temporarily disable drawing without unregistering.
|
|
13
|
+
* @param {number} order Z-order index. Lower values draw first (behind higher values).
|
|
14
|
+
* @returns {Function} Unregister function to remove the draw callback from the layer.
|
|
15
|
+
*/
|
|
16
|
+
registerDraw: (drawRef: React.RefObject<(() => void) | null>, order: number) => () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Request a render frame. The layer will clear once, then call all registered draw callbacks in order.
|
|
19
|
+
*/
|
|
20
|
+
requestRender: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface UseWebGLLayerValue {
|
|
23
|
+
gl: WebGL2RenderingContext;
|
|
24
|
+
registerDraw: (drawRef: React.RefObject<(() => void) | null>) => () => void;
|
|
25
|
+
requestRender: () => void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export type DrawEntry = {
|
|
3
|
+
drawRef: React.RefObject<(() => void) | null>;
|
|
4
|
+
order: number;
|
|
5
|
+
};
|
|
6
|
+
export interface ChartsWebGLContextValue {
|
|
7
|
+
gl: WebGL2RenderingContext;
|
|
8
|
+
/**
|
|
9
|
+
* Register a draw callback ref. Returns an unregister function.
|
|
10
|
+
* Callbacks are sorted by the provided `order` number so z-order follows the children's position
|
|
11
|
+
* in `ChartsWebGLLayer`, stable across unmount/remount (e.g. toggled via series visibility).
|
|
12
|
+
* @param {React.RefObject} drawRef A ref object whose current property is a draw callback function. The callback will be called with the WebGL context already set to this layer's canvas. Set to null to temporarily disable drawing without unregistering.
|
|
13
|
+
* @param {number} order Z-order index. Lower values draw first (behind higher values).
|
|
14
|
+
* @returns {Function} Unregister function to remove the draw callback from the layer.
|
|
15
|
+
*/
|
|
16
|
+
registerDraw: (drawRef: React.RefObject<(() => void) | null>, order: number) => () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Request a render frame. The layer will clear once, then call all registered draw callbacks in order.
|
|
19
|
+
*/
|
|
20
|
+
requestRender: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface UseWebGLLayerValue {
|
|
23
|
+
gl: WebGL2RenderingContext;
|
|
24
|
+
registerDraw: (drawRef: React.RefObject<(() => void) | null>) => () => void;
|
|
25
|
+
requestRender: () => void;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the z-order index for a plot based on its position in `ChartsWebGLLayer`'s children.
|
|
4
|
+
* `useWebGLLayer` reads this and auto-binds it to `registerDraw` so consumers don't pass it manually.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ChartsWebGLOrderContext: React.Context<number>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the z-order index for a plot based on its position in `ChartsWebGLLayer`'s children.
|
|
4
|
+
* `useWebGLLayer` reads this and auto-binds it to `registerDraw` so consumers don't pass it manually.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ChartsWebGLOrderContext: React.Context<number>;
|
|
@@ -0,0 +1,15 @@
|
|
|
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.ChartsWebGLOrderContext = void 0;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
/**
|
|
11
|
+
* Provides the z-order index for a plot based on its position in `ChartsWebGLLayer`'s children.
|
|
12
|
+
* `useWebGLLayer` reads this and auto-binds it to `registerDraw` so consumers don't pass it manually.
|
|
13
|
+
*/
|
|
14
|
+
const ChartsWebGLOrderContext = exports.ChartsWebGLOrderContext = /*#__PURE__*/React.createContext(0);
|
|
15
|
+
if (process.env.NODE_ENV !== "production") ChartsWebGLOrderContext.displayName = "ChartsWebGLOrderContext";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides the z-order index for a plot based on its position in `ChartsWebGLLayer`'s children.
|
|
7
|
+
* `useWebGLLayer` reads this and auto-binds it to `registerDraw` so consumers don't pass it manually.
|
|
8
|
+
*/
|
|
9
|
+
export const ChartsWebGLOrderContext = /*#__PURE__*/React.createContext(0);
|
|
10
|
+
if (process.env.NODE_ENV !== "production") ChartsWebGLOrderContext.displayName = "ChartsWebGLOrderContext";
|
|
@@ -9,7 +9,7 @@ exports.HeatmapPlotPremium = HeatmapPlotPremium;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
11
|
var _internals = require("@mui/x-charts-pro/internals");
|
|
12
|
-
var
|
|
12
|
+
var _HeatmapWebGLPlot = require("./webgl/HeatmapWebGLPlot");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
const _excluded = ["renderer", "borderRadius"];
|
|
15
15
|
function HeatmapPlotPremium(_ref) {
|
|
@@ -19,7 +19,7 @@ function HeatmapPlotPremium(_ref) {
|
|
|
19
19
|
} = _ref,
|
|
20
20
|
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
21
21
|
if (renderer === 'webgl') {
|
|
22
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
22
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeatmapWebGLPlot.HeatmapWebGLPlot, {
|
|
23
23
|
borderRadius: borderRadius
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
5
|
const _excluded = ["renderer", "borderRadius"];
|
|
6
6
|
import { HeatmapSVGPlot } from '@mui/x-charts-pro/internals';
|
|
7
|
-
import {
|
|
7
|
+
import { HeatmapWebGLPlot } from "./webgl/HeatmapWebGLPlot.mjs";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export function HeatmapPlotPremium(_ref) {
|
|
10
10
|
let {
|
|
@@ -13,7 +13,7 @@ export function HeatmapPlotPremium(_ref) {
|
|
|
13
13
|
} = _ref,
|
|
14
14
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
15
|
if (renderer === 'webgl') {
|
|
16
|
-
return /*#__PURE__*/_jsx(
|
|
16
|
+
return /*#__PURE__*/_jsx(HeatmapWebGLPlot, {
|
|
17
17
|
borderRadius: borderRadius
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -10,24 +10,25 @@ exports.HeatmapWebGLPlot = HeatmapWebGLPlot;
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _hooks = require("@mui/x-charts/hooks");
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
|
-
var
|
|
13
|
+
var _ChartsWebGLContext = require("../../ChartsWebGLLayer/ChartsWebGLContext");
|
|
14
14
|
var _hooks2 = require("../../hooks");
|
|
15
15
|
var _shaders = require("./shaders");
|
|
16
|
-
var _useWebGLResizeObserver = require("../../utils/webgl/useWebGLResizeObserver");
|
|
17
16
|
var _utils = require("../../utils/webgl/utils");
|
|
18
17
|
var _useHeatmapPlotData = require("./useHeatmapPlotData");
|
|
19
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
19
|
function HeatmapWebGLPlot({
|
|
21
20
|
borderRadius
|
|
22
21
|
}) {
|
|
23
|
-
const
|
|
22
|
+
const layer = (0, _ChartsWebGLContext.useWebGLLayer)();
|
|
24
23
|
const series = (0, _hooks2.useHeatmapSeriesContext)();
|
|
25
24
|
const seriesToDisplay = series?.series[series.seriesOrder[0]];
|
|
26
|
-
if (!
|
|
25
|
+
if (!layer || !seriesToDisplay) {
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
28
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HeatmapWebGLPlotImpl, {
|
|
30
|
-
gl: gl,
|
|
29
|
+
gl: layer.gl,
|
|
30
|
+
registerDraw: layer.registerDraw,
|
|
31
|
+
requestRender: layer.requestRender,
|
|
31
32
|
borderRadius: borderRadius ?? 0,
|
|
32
33
|
series: seriesToDisplay
|
|
33
34
|
});
|
|
@@ -35,6 +36,8 @@ function HeatmapWebGLPlot({
|
|
|
35
36
|
function HeatmapWebGLPlotImpl(props) {
|
|
36
37
|
const {
|
|
37
38
|
gl,
|
|
39
|
+
registerDraw,
|
|
40
|
+
requestRender,
|
|
38
41
|
borderRadius,
|
|
39
42
|
series
|
|
40
43
|
} = props;
|
|
@@ -49,21 +52,16 @@ function HeatmapWebGLPlotImpl(props) {
|
|
|
49
52
|
});
|
|
50
53
|
const [quadBuffer] = React.useState(() => (0, _utils.uploadQuadBuffer)(gl));
|
|
51
54
|
const dataLength = series.data.length;
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
renderScheduledRef.current = true;
|
|
63
|
-
}, []);
|
|
64
|
-
|
|
65
|
-
// On resize render directly to avoid a frame where the canvas is blank
|
|
66
|
-
(0, _useWebGLResizeObserver.useWebGLResizeObserver)(render);
|
|
55
|
+
const drawRef = React.useRef(null);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
drawRef.current = () => {
|
|
58
|
+
gl.drawArraysInstanced(gl.TRIANGLE_STRIP, 0, 4, dataLength);
|
|
59
|
+
};
|
|
60
|
+
}, [gl, dataLength]);
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
const unregister = registerDraw(drawRef);
|
|
63
|
+
return unregister;
|
|
64
|
+
}, [registerDraw]);
|
|
67
65
|
React.useEffect(() => {
|
|
68
66
|
/* Enable blending for transparency
|
|
69
67
|
* These are global to the WebGL context and need to be set only once */
|
|
@@ -160,26 +158,21 @@ function HeatmapWebGLPlotImpl(props) {
|
|
|
160
158
|
} else {
|
|
161
159
|
setupBorderRadiusUniform();
|
|
162
160
|
}
|
|
163
|
-
|
|
164
|
-
}, [gl, program,
|
|
161
|
+
requestRender();
|
|
162
|
+
}, [gl, program, requestRender, seriesBorderRadius, setupBorderRadiusUniform,
|
|
165
163
|
// We use the event callback versions here because we only want this effect to trigger when the border radius changes
|
|
166
164
|
setupAttributesEvent, setupUniformsEvent, vertexShader]);
|
|
167
165
|
React.useEffect(() => {
|
|
168
166
|
setupResolutionUniform();
|
|
169
|
-
|
|
170
|
-
}, [setupResolutionUniform,
|
|
167
|
+
requestRender();
|
|
168
|
+
}, [setupResolutionUniform, requestRender]);
|
|
171
169
|
React.useEffect(() => {
|
|
172
170
|
setupRectDimensionsUniform();
|
|
173
|
-
|
|
174
|
-
}, [setupRectDimensionsUniform,
|
|
171
|
+
requestRender();
|
|
172
|
+
}, [setupRectDimensionsUniform, requestRender]);
|
|
175
173
|
React.useEffect(() => {
|
|
176
174
|
setupAttributes();
|
|
177
|
-
|
|
178
|
-
}, [
|
|
179
|
-
React.useEffect(() => {
|
|
180
|
-
if (renderScheduledRef.current) {
|
|
181
|
-
render();
|
|
182
|
-
}
|
|
183
|
-
});
|
|
175
|
+
requestRender();
|
|
176
|
+
}, [requestRender, setupAttributes]);
|
|
184
177
|
return null;
|
|
185
178
|
}
|
|
@@ -3,24 +3,25 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useDrawingArea, useXScale, useYScale } from '@mui/x-charts/hooks';
|
|
5
5
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
|
-
import {
|
|
6
|
+
import { useWebGLLayer } from "../../ChartsWebGLLayer/ChartsWebGLContext.mjs";
|
|
7
7
|
import { useHeatmapSeriesContext } from "../../hooks/index.mjs";
|
|
8
8
|
import { heatmapFragmentShaderSourceNoBorderRadius, heatmapFragmentShaderSourceWithBorderRadius, heatmapVertexShaderSource } from "./shaders.mjs";
|
|
9
|
-
import { useWebGLResizeObserver } from "../../utils/webgl/useWebGLResizeObserver.mjs";
|
|
10
9
|
import { attachShader, bindQuadBuffer, compileShader, logWebGLErrors, uploadQuadBuffer } from "../../utils/webgl/utils.mjs";
|
|
11
10
|
import { useHeatmapPlotData } from "./useHeatmapPlotData.mjs";
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
export function HeatmapWebGLPlot({
|
|
14
13
|
borderRadius
|
|
15
14
|
}) {
|
|
16
|
-
const
|
|
15
|
+
const layer = useWebGLLayer();
|
|
17
16
|
const series = useHeatmapSeriesContext();
|
|
18
17
|
const seriesToDisplay = series?.series[series.seriesOrder[0]];
|
|
19
|
-
if (!
|
|
18
|
+
if (!layer || !seriesToDisplay) {
|
|
20
19
|
return null;
|
|
21
20
|
}
|
|
22
21
|
return /*#__PURE__*/_jsx(HeatmapWebGLPlotImpl, {
|
|
23
|
-
gl: gl,
|
|
22
|
+
gl: layer.gl,
|
|
23
|
+
registerDraw: layer.registerDraw,
|
|
24
|
+
requestRender: layer.requestRender,
|
|
24
25
|
borderRadius: borderRadius ?? 0,
|
|
25
26
|
series: seriesToDisplay
|
|
26
27
|
});
|
|
@@ -28,6 +29,8 @@ export function HeatmapWebGLPlot({
|
|
|
28
29
|
function HeatmapWebGLPlotImpl(props) {
|
|
29
30
|
const {
|
|
30
31
|
gl,
|
|
32
|
+
registerDraw,
|
|
33
|
+
requestRender,
|
|
31
34
|
borderRadius,
|
|
32
35
|
series
|
|
33
36
|
} = props;
|
|
@@ -42,21 +45,16 @@ function HeatmapWebGLPlotImpl(props) {
|
|
|
42
45
|
});
|
|
43
46
|
const [quadBuffer] = React.useState(() => uploadQuadBuffer(gl));
|
|
44
47
|
const dataLength = series.data.length;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
renderScheduledRef.current = true;
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
// On resize render directly to avoid a frame where the canvas is blank
|
|
59
|
-
useWebGLResizeObserver(render);
|
|
48
|
+
const drawRef = React.useRef(null);
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
drawRef.current = () => {
|
|
51
|
+
gl.drawArraysInstanced(gl.TRIANGLE_STRIP, 0, 4, dataLength);
|
|
52
|
+
};
|
|
53
|
+
}, [gl, dataLength]);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
const unregister = registerDraw(drawRef);
|
|
56
|
+
return unregister;
|
|
57
|
+
}, [registerDraw]);
|
|
60
58
|
React.useEffect(() => {
|
|
61
59
|
/* Enable blending for transparency
|
|
62
60
|
* These are global to the WebGL context and need to be set only once */
|
|
@@ -153,26 +151,21 @@ function HeatmapWebGLPlotImpl(props) {
|
|
|
153
151
|
} else {
|
|
154
152
|
setupBorderRadiusUniform();
|
|
155
153
|
}
|
|
156
|
-
|
|
157
|
-
}, [gl, program,
|
|
154
|
+
requestRender();
|
|
155
|
+
}, [gl, program, requestRender, seriesBorderRadius, setupBorderRadiusUniform,
|
|
158
156
|
// We use the event callback versions here because we only want this effect to trigger when the border radius changes
|
|
159
157
|
setupAttributesEvent, setupUniformsEvent, vertexShader]);
|
|
160
158
|
React.useEffect(() => {
|
|
161
159
|
setupResolutionUniform();
|
|
162
|
-
|
|
163
|
-
}, [setupResolutionUniform,
|
|
160
|
+
requestRender();
|
|
161
|
+
}, [setupResolutionUniform, requestRender]);
|
|
164
162
|
React.useEffect(() => {
|
|
165
163
|
setupRectDimensionsUniform();
|
|
166
|
-
|
|
167
|
-
}, [setupRectDimensionsUniform,
|
|
164
|
+
requestRender();
|
|
165
|
+
}, [setupRectDimensionsUniform, requestRender]);
|
|
168
166
|
React.useEffect(() => {
|
|
169
167
|
setupAttributes();
|
|
170
|
-
|
|
171
|
-
}, [
|
|
172
|
-
React.useEffect(() => {
|
|
173
|
-
if (renderScheduledRef.current) {
|
|
174
|
-
render();
|
|
175
|
-
}
|
|
176
|
-
});
|
|
168
|
+
requestRender();
|
|
169
|
+
}, [requestRender, setupAttributes]);
|
|
177
170
|
return null;
|
|
178
171
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const heatmapVertexShaderSource = "\n precision mediump float;\n \n attribute vec2 a_position;\n attribute vec2 a_center;\n attribute vec4 a_color;\n attribute float a_saturation;\n \n varying vec4 v_color;\n varying vec2 v_pos;\n \n uniform vec2 u_dimensions;\n uniform vec2 u_resolution;\n \n // https://tsev.dev/posts/2020-06-19-colour-correction-with-webgl/\n vec3 adjust_saturation(vec3 color, float value) {\n // https://www.w3.org/TR/
|
|
1
|
+
export declare const heatmapVertexShaderSource = "\n precision mediump float;\n \n attribute vec2 a_position;\n attribute vec2 a_center;\n attribute vec4 a_color;\n attribute float a_saturation;\n \n varying vec4 v_color;\n varying vec2 v_pos;\n \n uniform vec2 u_dimensions;\n uniform vec2 u_resolution;\n \n // https://tsev.dev/posts/2020-06-19-colour-correction-with-webgl/\n vec3 adjust_saturation(vec3 color, float value) {\n // https://www.w3.org/TR/WCAG22/#dfn-relative-luminance\n const vec3 luminosityFactor = vec3(0.2126, 0.7152, 0.0722);\n vec3 grayscale = vec3(dot(color, luminosityFactor));\n \n return mix(grayscale, color, 1.0 + value);\n }\n \n void main() {\n // Convert from pixels to clip space (-1 to 1)\n vec2 position = a_center + a_position * u_dimensions / 2.0;\n vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0;\n gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);\n \n v_color = vec4(adjust_saturation(a_color.rgb, a_saturation), 1.0);\n v_pos = a_position * u_dimensions / 2.0;\n }\n ";
|
|
2
2
|
export declare const heatmapFragmentShaderSourceNoBorderRadius = "\n precision mediump float;\n \n varying vec4 v_color;\n \n void main() {\n gl_FragColor = v_color;\n }\n ";
|
|
3
3
|
export declare const heatmapFragmentShaderSourceWithBorderRadius = "\n precision mediump float;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n\n uniform vec2 u_dimensions;\n uniform float u_borderRadius;\n\n float roundedBoxSDF(vec2 pos, vec2 half_size, float radius) {\n vec2 q = abs(pos) - half_size + radius;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius;\n }\n\n void main() {\n // Calculate distance from rounded rectangle edge\n float dist = roundedBoxSDF(v_pos, u_dimensions / 2.0, u_borderRadius);\n \n // Create smooth alpha based on distance\n float alpha = 1.0 - smoothstep(-0.5, 0.5, dist);\n \n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\n }\n ";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const heatmapVertexShaderSource = "\n precision mediump float;\n \n attribute vec2 a_position;\n attribute vec2 a_center;\n attribute vec4 a_color;\n attribute float a_saturation;\n \n varying vec4 v_color;\n varying vec2 v_pos;\n \n uniform vec2 u_dimensions;\n uniform vec2 u_resolution;\n \n // https://tsev.dev/posts/2020-06-19-colour-correction-with-webgl/\n vec3 adjust_saturation(vec3 color, float value) {\n // https://www.w3.org/TR/
|
|
1
|
+
export declare const heatmapVertexShaderSource = "\n precision mediump float;\n \n attribute vec2 a_position;\n attribute vec2 a_center;\n attribute vec4 a_color;\n attribute float a_saturation;\n \n varying vec4 v_color;\n varying vec2 v_pos;\n \n uniform vec2 u_dimensions;\n uniform vec2 u_resolution;\n \n // https://tsev.dev/posts/2020-06-19-colour-correction-with-webgl/\n vec3 adjust_saturation(vec3 color, float value) {\n // https://www.w3.org/TR/WCAG22/#dfn-relative-luminance\n const vec3 luminosityFactor = vec3(0.2126, 0.7152, 0.0722);\n vec3 grayscale = vec3(dot(color, luminosityFactor));\n \n return mix(grayscale, color, 1.0 + value);\n }\n \n void main() {\n // Convert from pixels to clip space (-1 to 1)\n vec2 position = a_center + a_position * u_dimensions / 2.0;\n vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0;\n gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);\n \n v_color = vec4(adjust_saturation(a_color.rgb, a_saturation), 1.0);\n v_pos = a_position * u_dimensions / 2.0;\n }\n ";
|
|
2
2
|
export declare const heatmapFragmentShaderSourceNoBorderRadius = "\n precision mediump float;\n \n varying vec4 v_color;\n \n void main() {\n gl_FragColor = v_color;\n }\n ";
|
|
3
3
|
export declare const heatmapFragmentShaderSourceWithBorderRadius = "\n precision mediump float;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n\n uniform vec2 u_dimensions;\n uniform float u_borderRadius;\n\n float roundedBoxSDF(vec2 pos, vec2 half_size, float radius) {\n vec2 q = abs(pos) - half_size + radius;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius;\n }\n\n void main() {\n // Calculate distance from rounded rectangle edge\n float dist = roundedBoxSDF(v_pos, u_dimensions / 2.0, u_borderRadius);\n \n // Create smooth alpha based on distance\n float alpha = 1.0 - smoothstep(-0.5, 0.5, dist);\n \n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\n }\n ";
|
|
@@ -21,7 +21,7 @@ const heatmapVertexShaderSource = exports.heatmapVertexShaderSource = /* glsl */
|
|
|
21
21
|
|
|
22
22
|
// https://tsev.dev/posts/2020-06-19-colour-correction-with-webgl/
|
|
23
23
|
vec3 adjust_saturation(vec3 color, float value) {
|
|
24
|
-
// https://www.w3.org/TR/
|
|
24
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
25
25
|
const vec3 luminosityFactor = vec3(0.2126, 0.7152, 0.0722);
|
|
26
26
|
vec3 grayscale = vec3(dot(color, luminosityFactor));
|
|
27
27
|
|
|
@@ -15,7 +15,7 @@ export const heatmapVertexShaderSource = /* glsl */`
|
|
|
15
15
|
|
|
16
16
|
// https://tsev.dev/posts/2020-06-19-colour-correction-with-webgl/
|
|
17
17
|
vec3 adjust_saturation(vec3 color, float value) {
|
|
18
|
-
// https://www.w3.org/TR/
|
|
18
|
+
// https://www.w3.org/TR/WCAG22/#dfn-relative-luminance
|
|
19
19
|
const vec3 luminosityFactor = vec3(0.2126, 0.7152, 0.0722);
|
|
20
20
|
vec3 grayscale = vec3(dot(color, luminosityFactor));
|
|
21
21
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.axisTooltipGetter = void 0;
|
|
7
|
+
const axisTooltipGetter = series => {
|
|
8
|
+
return Object.values(series).map(s => ({
|
|
9
|
+
direction: 'rotation',
|
|
10
|
+
axisId: 'rotationAxisId' in s ? s.rotationAxisId : undefined
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
exports.axisTooltipGetter = axisTooltipGetter;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _internals = require("@mui/x-charts/internals");
|
|
8
|
+
const descriptionGetter = params => {
|
|
9
|
+
const {
|
|
10
|
+
identifier,
|
|
11
|
+
series,
|
|
12
|
+
rotationAxis,
|
|
13
|
+
localeText
|
|
14
|
+
} = params;
|
|
15
|
+
const label = (0, _internals.getLabel)(series.label, 'tooltip');
|
|
16
|
+
const dataIndex = identifier.dataIndex;
|
|
17
|
+
const value = series.data[dataIndex] ?? null;
|
|
18
|
+
const categoryValue = rotationAxis.data?.[dataIndex] ?? null;
|
|
19
|
+
const formattedValue = series.valueFormatter(value, {
|
|
20
|
+
dataIndex
|
|
21
|
+
});
|
|
22
|
+
const formattedCategory = rotationAxis.valueFormatter?.(categoryValue, {
|
|
23
|
+
location: 'tooltip',
|
|
24
|
+
scale: rotationAxis.scale
|
|
25
|
+
});
|
|
26
|
+
return localeText.barDescription({
|
|
27
|
+
value,
|
|
28
|
+
formattedValue: formattedValue ?? '',
|
|
29
|
+
categoryValue,
|
|
30
|
+
formattedCategoryValue: formattedCategory ?? '',
|
|
31
|
+
seriesLabel: label
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var _default = exports.default = descriptionGetter;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getLabel } from '@mui/x-charts/internals';
|
|
2
|
+
const descriptionGetter = params => {
|
|
3
|
+
const {
|
|
4
|
+
identifier,
|
|
5
|
+
series,
|
|
6
|
+
rotationAxis,
|
|
7
|
+
localeText
|
|
8
|
+
} = params;
|
|
9
|
+
const label = getLabel(series.label, 'tooltip');
|
|
10
|
+
const dataIndex = identifier.dataIndex;
|
|
11
|
+
const value = series.data[dataIndex] ?? null;
|
|
12
|
+
const categoryValue = rotationAxis.data?.[dataIndex] ?? null;
|
|
13
|
+
const formattedValue = series.valueFormatter(value, {
|
|
14
|
+
dataIndex
|
|
15
|
+
});
|
|
16
|
+
const formattedCategory = rotationAxis.valueFormatter?.(categoryValue, {
|
|
17
|
+
location: 'tooltip',
|
|
18
|
+
scale: rotationAxis.scale
|
|
19
|
+
});
|
|
20
|
+
return localeText.barDescription({
|
|
21
|
+
value,
|
|
22
|
+
formattedValue: formattedValue ?? '',
|
|
23
|
+
categoryValue,
|
|
24
|
+
formattedCategoryValue: formattedCategory ?? '',
|
|
25
|
+
seriesLabel: label
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export default descriptionGetter;
|