@mui/x-charts-premium 9.7.0 → 9.9.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.d.mts +1 -1
- package/BarChartPremium/BarChartPremium.d.ts +1 -1
- package/BarChartPremium/BarChartPremium.js +14 -3
- package/BarChartPremium/BarChartPremium.mjs +14 -3
- package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.mts +2 -1
- package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.ts +2 -1
- package/BarChartPremium/RangeBar/FocusedRangeBar.d.mts +1 -1
- package/BarChartPremium/RangeBar/FocusedRangeBar.d.ts +1 -1
- package/BarChartPremium/RangeBar/seriesConfig/index.js +2 -2
- package/BarChartPremium/RangeBar/seriesConfig/index.mjs +2 -2
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.mts +2 -3
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.ts +2 -3
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.js +12 -15
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.mjs +11 -14
- package/BarChartPremium/webgl/BarWebGLProgram.d.mts +4 -5
- package/BarChartPremium/webgl/BarWebGLProgram.d.ts +4 -5
- package/BarChartPremium/webgl/BarWebGLProgram.js +24 -65
- package/BarChartPremium/webgl/BarWebGLProgram.mjs +24 -65
- package/BarChartPremium/webgl/shaders.d.mts +1 -1
- package/BarChartPremium/webgl/shaders.d.ts +1 -1
- package/BarChartPremium/webgl/shaders.js +2 -15
- package/BarChartPremium/webgl/shaders.mjs +3 -15
- package/CHANGELOG.md +249 -1
- package/CandlestickChart/CandlestickPlot.d.mts +2 -1
- package/CandlestickChart/CandlestickPlot.d.ts +2 -1
- package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.mts +2 -1
- package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.ts +2 -1
- package/CandlestickChart/seriesConfig/index.js +2 -2
- package/CandlestickChart/seriesConfig/index.mjs +2 -2
- package/CandlestickChart/seriesConfig/tooltipPosition.d.mts +2 -3
- package/CandlestickChart/seriesConfig/tooltipPosition.d.ts +2 -3
- package/CandlestickChart/seriesConfig/tooltipPosition.js +10 -14
- package/CandlestickChart/seriesConfig/tooltipPosition.mjs +10 -14
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.mts +1 -1
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.ts +1 -1
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.mts +1 -1
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.ts +1 -1
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.js +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.mjs +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.mts +4 -3
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.ts +4 -3
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.js +2 -1
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.mjs +2 -1
- package/ChartsGeoDataProviderPremium/index.d.mts +2 -1
- package/ChartsGeoDataProviderPremium/index.d.ts +2 -1
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.mts +2 -1
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.ts +2 -1
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +2 -2
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +2 -2
- package/ChartsRenderer/components/PaletteOption.d.mts +1 -1
- package/ChartsRenderer/components/PaletteOption.d.ts +1 -1
- package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.mts +2 -1
- package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.ts +2 -1
- package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.mts +1 -1
- package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.ts +1 -1
- package/HeatmapPremium/HeatmapPlotPremium.d.mts +1 -1
- package/HeatmapPremium/HeatmapPlotPremium.d.ts +1 -1
- package/HeatmapPremium/webgl/HeatmapWebGLProgram.js +12 -37
- package/HeatmapPremium/webgl/HeatmapWebGLProgram.mjs +12 -37
- package/HeatmapPremium/webgl/shaders.d.mts +3 -3
- package/HeatmapPremium/webgl/shaders.d.ts +3 -3
- package/HeatmapPremium/webgl/shaders.js +12 -15
- package/HeatmapPremium/webgl/shaders.mjs +13 -15
- package/HeatmapPremium/webgl/useHeatmapPlotData.js +3 -8
- package/HeatmapPremium/webgl/useHeatmapPlotData.mjs +3 -8
- package/Map/FocusedMapShape.d.mts +2 -1
- package/Map/FocusedMapShape.d.ts +2 -1
- package/Map/FocusedMapShape.js +5 -1
- package/Map/FocusedMapShape.mjs +5 -1
- package/Map/GeoDataPlot.d.mts +1 -1
- package/Map/GeoDataPlot.d.ts +1 -1
- package/Map/Graticule.d.mts +1 -1
- package/Map/Graticule.d.ts +1 -1
- package/Map/MapImagePlot.d.mts +39 -0
- package/Map/MapImagePlot.d.ts +39 -0
- package/Map/MapImagePlot.js +138 -0
- package/Map/MapImagePlot.mjs +132 -0
- package/Map/MapShape.d.mts +2 -2
- package/Map/MapShape.d.ts +2 -2
- package/Map/MapShape.js +6 -6
- package/Map/MapShape.mjs +6 -6
- package/Map/MapShapePlot.d.mts +9 -1
- package/Map/MapShapePlot.d.ts +9 -1
- package/Map/MapShapePlot.js +17 -5
- package/Map/MapShapePlot.mjs +17 -5
- package/Map/index.d.mts +2 -3
- package/Map/index.d.ts +2 -3
- package/Map/index.js +11 -0
- package/Map/index.mjs +1 -0
- package/Map/reprojectEquirectangularImage.d.mts +60 -0
- package/Map/reprojectEquirectangularImage.d.ts +60 -0
- package/Map/reprojectEquirectangularImage.js +116 -0
- package/Map/reprojectEquirectangularImage.mjs +110 -0
- package/Map/seriesConfig/descriptionGetter.js +5 -1
- package/Map/seriesConfig/descriptionGetter.mjs +5 -1
- package/Map/seriesConfig/getColor.js +18 -6
- package/Map/seriesConfig/getColor.mjs +18 -6
- package/Map/seriesConfig/highlight.d.mts +10 -0
- package/Map/seriesConfig/highlight.d.ts +10 -0
- package/Map/seriesConfig/highlight.js +52 -0
- package/Map/seriesConfig/highlight.mjs +45 -0
- package/Map/seriesConfig/identifierCleaner.d.mts +3 -0
- package/Map/seriesConfig/identifierCleaner.d.ts +3 -0
- package/Map/seriesConfig/identifierCleaner.js +14 -0
- package/Map/seriesConfig/identifierCleaner.mjs +8 -0
- package/Map/seriesConfig/identifierSerializer.d.mts +3 -0
- package/Map/seriesConfig/identifierSerializer.d.ts +3 -0
- package/Map/seriesConfig/identifierSerializer.js +12 -0
- package/Map/seriesConfig/identifierSerializer.mjs +6 -0
- package/Map/seriesConfig/index.js +8 -6
- package/Map/seriesConfig/index.mjs +7 -5
- package/Map/seriesConfig/keyboardFocusHandler.d.mts +0 -6
- package/Map/seriesConfig/keyboardFocusHandler.d.ts +0 -6
- package/Map/seriesConfig/keyboardFocusHandler.js +40 -7
- package/Map/seriesConfig/keyboardFocusHandler.mjs +41 -8
- package/Map/seriesConfig/seriesProcessor.js +11 -2
- package/Map/seriesConfig/seriesProcessor.mjs +11 -2
- package/Map/seriesConfig/tooltip.js +8 -4
- package/Map/seriesConfig/tooltip.mjs +8 -4
- package/Map/seriesConfig/tooltipPosition.d.mts +8 -3
- package/Map/seriesConfig/tooltipPosition.d.ts +8 -3
- package/Map/seriesConfig/tooltipPosition.js +15 -27
- package/Map/seriesConfig/tooltipPosition.mjs +16 -27
- package/RadialBarChart/RadialBarElement.d.mts +1 -1
- package/RadialBarChart/RadialBarElement.d.ts +1 -1
- package/RadialBarChart/seriesConfig/index.js +2 -2
- package/RadialBarChart/seriesConfig/index.mjs +2 -2
- package/RadialBarChart/seriesConfig/tooltipPosition.d.mts +2 -3
- package/RadialBarChart/seriesConfig/tooltipPosition.d.ts +2 -3
- package/RadialBarChart/seriesConfig/tooltipPosition.js +4 -6
- package/RadialBarChart/seriesConfig/tooltipPosition.mjs +2 -5
- package/RadialLineChart/RadialArea.d.mts +2 -1
- package/RadialLineChart/RadialArea.d.ts +2 -1
- package/RadialLineChart/RadialAreaPlot.d.mts +1 -1
- package/RadialLineChart/RadialAreaPlot.d.ts +1 -1
- package/RadialLineChart/RadialLine.d.mts +1 -1
- package/RadialLineChart/RadialLine.d.ts +1 -1
- package/RadialLineChart/RadialLineHighlightElement.d.mts +1 -1
- package/RadialLineChart/RadialLineHighlightElement.d.ts +1 -1
- package/RadialLineChart/RadialLineHighlightPlot.d.mts +1 -1
- package/RadialLineChart/RadialLineHighlightPlot.d.ts +1 -1
- package/RadialLineChart/RadialLinePlot.d.mts +1 -1
- package/RadialLineChart/RadialLinePlot.d.ts +1 -1
- package/RadialLineChart/RadialMarkPlot.d.mts +1 -1
- package/RadialLineChart/RadialMarkPlot.d.ts +1 -1
- package/RadialLineChart/seriesConfig/index.js +2 -2
- package/RadialLineChart/seriesConfig/index.mjs +2 -2
- package/RadialLineChart/seriesConfig/tooltipPosition.d.mts +2 -3
- package/RadialLineChart/seriesConfig/tooltipPosition.d.ts +2 -3
- package/RadialLineChart/seriesConfig/tooltipPosition.js +4 -6
- package/RadialLineChart/seriesConfig/tooltipPosition.mjs +2 -5
- package/ScatterChartPremium/ScatterPlotPremium.d.mts +2 -1
- package/ScatterChartPremium/ScatterPlotPremium.d.ts +2 -1
- package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.mts +2 -1
- package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.ts +2 -1
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.mts +0 -2
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.ts +0 -2
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.js +23 -81
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.mjs +23 -81
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/createGetVisibleCoordinate.d.mts +14 -0
- package/internals/createGetVisibleCoordinate.d.ts +14 -0
- package/internals/createGetVisibleCoordinate.js +66 -0
- package/internals/createGetVisibleCoordinate.mjs +60 -0
- package/internals/plugins/useGeoProjection/factories.d.mts +3 -0
- package/internals/plugins/useGeoProjection/factories.d.ts +3 -0
- package/internals/plugins/useGeoProjection/factories.js +29 -0
- package/internals/plugins/useGeoProjection/factories.mjs +23 -0
- package/internals/plugins/useGeoProjection/projection.utils.d.mts +17 -0
- package/internals/plugins/useGeoProjection/projection.utils.d.ts +17 -0
- package/internals/plugins/useGeoProjection/projection.utils.js +67 -0
- package/internals/plugins/useGeoProjection/projection.utils.mjs +59 -0
- package/internals/plugins/useGeoProjection/useGeoProjection.js +7 -40
- package/internals/plugins/useGeoProjection/useGeoProjection.mjs +7 -40
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.mts +47 -11
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.ts +47 -11
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.js +118 -8
- package/internals/plugins/useGeoProjection/useGeoProjection.selectors.mjs +117 -8
- package/internals/plugins/useGeoProjection/useGeoProjection.types.d.mts +63 -2
- package/internals/plugins/useGeoProjection/useGeoProjection.types.d.ts +63 -2
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.mts +11 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.ts +11 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.js +65 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.mjs +58 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.mts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.ts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.js +62 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.mjs +56 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.mts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.ts +13 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.js +64 -0
- package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.mjs +58 -0
- package/internals/plugins/useGeoProjectionZoom/index.d.mts +2 -0
- package/internals/plugins/useGeoProjectionZoom/index.d.ts +2 -0
- package/internals/plugins/useGeoProjectionZoom/index.js +12 -0
- package/internals/plugins/useGeoProjectionZoom/index.mjs +1 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.mts +31 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.ts +31 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.js +187 -0
- package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.mjs +177 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.d.mts +23 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.d.ts +23 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.js +190 -0
- package/internals/plugins/useGeoProjectionZoom/rotationMath.mjs +182 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.mts +3 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.ts +3 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.js +174 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.mjs +166 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.mts +152 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.ts +152 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.js +5 -0
- package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.mjs +1 -0
- package/models/seriesType/mapShape.d.mts +2 -1
- package/models/seriesType/mapShape.d.ts +2 -1
- package/package.json +6 -6
- package/utils/webgl/glsl.d.mts +15 -0
- package/utils/webgl/glsl.d.ts +15 -0
- package/utils/webgl/glsl.js +34 -0
- package/utils/webgl/glsl.mjs +28 -0
- package/utils/webgl/instancedAttribute.d.mts +28 -0
- package/utils/webgl/instancedAttribute.d.ts +28 -0
- package/utils/webgl/instancedAttribute.js +57 -0
- package/utils/webgl/instancedAttribute.mjs +50 -0
- package/utils/webgl/utils.d.mts +21 -2
- package/utils/webgl/utils.d.ts +21 -2
- package/utils/webgl/utils.js +44 -8
- package/utils/webgl/utils.mjs +41 -7
|
@@ -8,7 +8,7 @@ import type { ChartsContainerPremiumProps } from "../ChartsContainerPremium/inde
|
|
|
8
8
|
export type RangeBarSeries = RangeBarSeriesType;
|
|
9
9
|
export interface BarChartPremiumSlots extends BarChartProSlots {}
|
|
10
10
|
export interface BarChartPremiumSlotProps extends BarChartProSlotProps {}
|
|
11
|
-
export interface BarChartPremiumProps extends Omit<BarChartProProps, 'apiRef' | 'slots' | 'slotProps' | 'seriesConfig' | 'plugins' | 'series' | 'renderer'>, Omit<ChartsContainerPremiumProps<'bar', BarChartPremiumPluginSignatures>, 'series' | 'slots' | 'slotProps'>, Pick<BarPlotPremiumProps, 'renderer'> {
|
|
11
|
+
export interface BarChartPremiumProps extends Omit<BarChartProProps, 'apiRef' | 'slots' | 'slotProps' | 'seriesConfig' | 'plugins' | 'series' | 'renderer'>, Omit<ChartsContainerPremiumProps<'bar', BarChartPremiumPluginSignatures>, 'series' | 'slots' | 'slotProps' | 'sampling'>, Pick<BarPlotPremiumProps, 'renderer'> {
|
|
12
12
|
/**
|
|
13
13
|
* Overridable component slots.
|
|
14
14
|
* @default {}
|
|
@@ -8,7 +8,7 @@ import type { ChartsContainerPremiumProps } from "../ChartsContainerPremium/inde
|
|
|
8
8
|
export type RangeBarSeries = RangeBarSeriesType;
|
|
9
9
|
export interface BarChartPremiumSlots extends BarChartProSlots {}
|
|
10
10
|
export interface BarChartPremiumSlotProps extends BarChartProSlotProps {}
|
|
11
|
-
export interface BarChartPremiumProps extends Omit<BarChartProProps, 'apiRef' | 'slots' | 'slotProps' | 'seriesConfig' | 'plugins' | 'series' | 'renderer'>, Omit<ChartsContainerPremiumProps<'bar', BarChartPremiumPluginSignatures>, 'series' | 'slots' | 'slotProps'>, Pick<BarPlotPremiumProps, 'renderer'> {
|
|
11
|
+
export interface BarChartPremiumProps extends Omit<BarChartProProps, 'apiRef' | 'slots' | 'slotProps' | 'seriesConfig' | 'plugins' | 'series' | 'renderer'>, Omit<ChartsContainerPremiumProps<'bar', BarChartPremiumPluginSignatures>, 'series' | 'slots' | 'slotProps' | 'sampling'>, Pick<BarPlotPremiumProps, 'renderer'> {
|
|
12
12
|
/**
|
|
13
13
|
* Overridable component slots.
|
|
14
14
|
* @default {}
|
|
@@ -35,7 +35,7 @@ var _ChartsDataProviderPremium = require("../ChartsDataProviderPremium");
|
|
|
35
35
|
var _RangeBarPlot = require("./RangeBar/RangeBarPlot");
|
|
36
36
|
var _FocusedRangeBar = require("./RangeBar/FocusedRangeBar");
|
|
37
37
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
38
|
-
const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef", "showToolbar"];
|
|
38
|
+
const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef", "showToolbar", "sampling"];
|
|
39
39
|
/**
|
|
40
40
|
* Demos:
|
|
41
41
|
*
|
|
@@ -57,7 +57,8 @@ const BarChartPremium = exports.BarChartPremium = /*#__PURE__*/React.forwardRef(
|
|
|
57
57
|
zoomData,
|
|
58
58
|
onZoomChange,
|
|
59
59
|
apiRef,
|
|
60
|
-
showToolbar
|
|
60
|
+
showToolbar,
|
|
61
|
+
sampling
|
|
61
62
|
} = props,
|
|
62
63
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
63
64
|
const {
|
|
@@ -83,7 +84,10 @@ const BarChartPremium = exports.BarChartPremium = /*#__PURE__*/React.forwardRef(
|
|
|
83
84
|
onZoomChange,
|
|
84
85
|
apiRef,
|
|
85
86
|
plugins: _BarChartPremium2.BAR_CHART_PREMIUM_PLUGINS
|
|
86
|
-
})
|
|
87
|
+
}), {
|
|
88
|
+
seriesType: 'bar',
|
|
89
|
+
method: sampling
|
|
90
|
+
});
|
|
87
91
|
const Tooltip = props.slots?.tooltip ?? _ChartsTooltip.ChartsTooltip;
|
|
88
92
|
const Toolbar = props.slots?.toolbar ?? _ChartsToolbarPro.ChartsToolbarPro;
|
|
89
93
|
const renderer = barPlotPremiumProps.renderer;
|
|
@@ -382,6 +386,13 @@ process.env.NODE_ENV !== "production" ? BarChartPremium.propTypes /* remove-prop
|
|
|
382
386
|
* @default 'svg-single'
|
|
383
387
|
*/
|
|
384
388
|
renderer: _propTypes.default.oneOf(['svg-batch', 'svg-single', 'webgl']),
|
|
389
|
+
/**
|
|
390
|
+
* Sampling method used to render large datasets when zoomed out.
|
|
391
|
+
* - `'none'`: render every bar (no sampling).
|
|
392
|
+
* - `'minmax'`: keep the min and max per bucket and draw one merged bar.
|
|
393
|
+
* @default 'none'
|
|
394
|
+
*/
|
|
395
|
+
sampling: _propTypes.default.oneOf(['minmax', 'none']),
|
|
385
396
|
/**
|
|
386
397
|
* The series to display in the bar chart.
|
|
387
398
|
* An array of [[BarSeries]] or [[RangeBarSeries]] objects.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef", "showToolbar"];
|
|
5
|
+
const _excluded = ["initialZoom", "zoomData", "onZoomChange", "apiRef", "showToolbar", "sampling"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useThemeProps } from '@mui/material/styles';
|
|
@@ -50,7 +50,8 @@ const BarChartPremium = /*#__PURE__*/React.forwardRef(function BarChartPremium(i
|
|
|
50
50
|
zoomData,
|
|
51
51
|
onZoomChange,
|
|
52
52
|
apiRef,
|
|
53
|
-
showToolbar
|
|
53
|
+
showToolbar,
|
|
54
|
+
sampling
|
|
54
55
|
} = props,
|
|
55
56
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
56
57
|
const {
|
|
@@ -76,7 +77,10 @@ const BarChartPremium = /*#__PURE__*/React.forwardRef(function BarChartPremium(i
|
|
|
76
77
|
onZoomChange,
|
|
77
78
|
apiRef,
|
|
78
79
|
plugins: BAR_CHART_PREMIUM_PLUGINS
|
|
79
|
-
})
|
|
80
|
+
}), {
|
|
81
|
+
seriesType: 'bar',
|
|
82
|
+
method: sampling
|
|
83
|
+
});
|
|
80
84
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
81
85
|
const Toolbar = props.slots?.toolbar ?? ChartsToolbarPro;
|
|
82
86
|
const renderer = barPlotPremiumProps.renderer;
|
|
@@ -375,6 +379,13 @@ process.env.NODE_ENV !== "production" ? BarChartPremium.propTypes /* remove-prop
|
|
|
375
379
|
* @default 'svg-single'
|
|
376
380
|
*/
|
|
377
381
|
renderer: PropTypes.oneOf(['svg-batch', 'svg-single', 'webgl']),
|
|
382
|
+
/**
|
|
383
|
+
* Sampling method used to render large datasets when zoomed out.
|
|
384
|
+
* - `'none'`: render every bar (no sampling).
|
|
385
|
+
* - `'minmax'`: keep the min and max per bucket and draw one merged bar.
|
|
386
|
+
* @default 'none'
|
|
387
|
+
*/
|
|
388
|
+
sampling: PropTypes.oneOf(['minmax', 'none']),
|
|
378
389
|
/**
|
|
379
390
|
* The series to display in the bar chart.
|
|
380
391
|
* An array of [[BarSeries]] or [[RangeBarSeries]] objects.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { BarProps } from '@mui/x-charts/BarChart';
|
|
2
3
|
export interface AnimatedRangeBarElementProps extends BarProps {
|
|
3
4
|
/**
|
|
@@ -5,4 +6,4 @@ export interface AnimatedRangeBarElementProps extends BarProps {
|
|
|
5
6
|
*/
|
|
6
7
|
hidden?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare function AnimatedRangeBarElement(props: AnimatedRangeBarElementProps):
|
|
9
|
+
export declare function AnimatedRangeBarElement(props: AnimatedRangeBarElementProps): React.JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { BarProps } from '@mui/x-charts/BarChart';
|
|
2
3
|
export interface AnimatedRangeBarElementProps extends BarProps {
|
|
3
4
|
/**
|
|
@@ -5,4 +6,4 @@ export interface AnimatedRangeBarElementProps extends BarProps {
|
|
|
5
6
|
*/
|
|
6
7
|
hidden?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare function AnimatedRangeBarElement(props: AnimatedRangeBarElementProps):
|
|
9
|
+
export declare function AnimatedRangeBarElement(props: AnimatedRangeBarElementProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare function FocusedRangeBar(props: React.SVGAttributes<SVGRectElement>):
|
|
2
|
+
export declare function FocusedRangeBar(props: React.SVGAttributes<SVGRectElement>): React.JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare function FocusedRangeBar(props: React.SVGAttributes<SVGRectElement>):
|
|
2
|
+
export declare function FocusedRangeBar(props: React.SVGAttributes<SVGRectElement>): React.JSX.Element | null;
|
|
@@ -14,7 +14,7 @@ var _seriesProcessor = _interopRequireDefault(require("./seriesProcessor"));
|
|
|
14
14
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
15
15
|
var _legend = _interopRequireDefault(require("./legend"));
|
|
16
16
|
var _keyboardFocusHandler = _interopRequireDefault(require("./keyboardFocusHandler"));
|
|
17
|
-
var _tooltipPosition =
|
|
17
|
+
var _tooltipPosition = require("./tooltipPosition");
|
|
18
18
|
var _getSeriesWithDefaultValues = require("./getSeriesWithDefaultValues");
|
|
19
19
|
var _descriptionGetter = _interopRequireDefault(require("./descriptionGetter"));
|
|
20
20
|
var _RangeBarPreviewPlot = require("../../../ChartsZoomSlider/internals/previews/RangeBarPreviewPlot");
|
|
@@ -23,7 +23,7 @@ const rangeBarSeriesConfig = exports.rangeBarSeriesConfig = {
|
|
|
23
23
|
colorProcessor: _getColor.default,
|
|
24
24
|
legendGetter: _legend.default,
|
|
25
25
|
tooltipGetter: _tooltip.default,
|
|
26
|
-
|
|
26
|
+
selectorTooltipItemPosition: _tooltipPosition.selectorTooltipItemPosition,
|
|
27
27
|
axisTooltipGetter: _tooltip.axisTooltipGetter,
|
|
28
28
|
xExtremumGetter: _extrema.getExtremumX,
|
|
29
29
|
yExtremumGetter: _extrema.getExtremumY,
|
|
@@ -6,7 +6,7 @@ import seriesProcessor from "./seriesProcessor.mjs";
|
|
|
6
6
|
import getColor from "./getColor.mjs";
|
|
7
7
|
import legendGetter from "./legend.mjs";
|
|
8
8
|
import keyboardFocusHandler from "./keyboardFocusHandler.mjs";
|
|
9
|
-
import
|
|
9
|
+
import { selectorTooltipItemPosition } from "./tooltipPosition.mjs";
|
|
10
10
|
import { getSeriesWithDefaultValues } from "./getSeriesWithDefaultValues.mjs";
|
|
11
11
|
import descriptionGetter from "./descriptionGetter.mjs";
|
|
12
12
|
import { RangeBarPreviewPlot } from "../../../ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.mjs";
|
|
@@ -15,7 +15,7 @@ export const rangeBarSeriesConfig = {
|
|
|
15
15
|
colorProcessor: getColor,
|
|
16
16
|
legendGetter,
|
|
17
17
|
tooltipGetter,
|
|
18
|
-
|
|
18
|
+
selectorTooltipItemPosition,
|
|
19
19
|
axisTooltipGetter,
|
|
20
20
|
xExtremumGetter: getExtremumX,
|
|
21
21
|
yExtremumGetter: getExtremumY,
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const
|
|
3
|
-
export default tooltipItemPositionGetter;
|
|
1
|
+
import type { TooltipItemPositionSelector } from '@mui/x-charts/internals';
|
|
2
|
+
export declare const selectorTooltipItemPosition: TooltipItemPositionSelector<'rangeBar'>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const
|
|
3
|
-
export default tooltipItemPositionGetter;
|
|
1
|
+
import type { TooltipItemPositionSelector } from '@mui/x-charts/internals';
|
|
2
|
+
export declare const selectorTooltipItemPosition: TooltipItemPositionSelector<'rangeBar'>;
|
|
@@ -3,29 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.selectorTooltipItemPosition = void 0;
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
|
+
var _internals = require("@mui/x-charts/internals");
|
|
7
9
|
var _createGetRangeBarDimensions = require("../createGetRangeBarDimensions");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
series,
|
|
11
|
-
identifier,
|
|
12
|
-
axesConfig,
|
|
13
|
-
placement
|
|
14
|
-
} = params;
|
|
15
|
-
if (!identifier || identifier.dataIndex === undefined) {
|
|
10
|
+
const selectorTooltipItemPosition = exports.selectorTooltipItemPosition = (0, _store.createSelectorMemoized)(_internals.selectorChartsTooltipItem, _internals.selectorChartSeriesProcessed, _internals.selectorChartXAxis, _internals.selectorChartYAxis, function selectorTooltipItemPosition(identifier, series, xAxes, yAxes, placement) {
|
|
11
|
+
if (!identifier || identifier.type !== 'rangeBar' || identifier.dataIndex === undefined) {
|
|
16
12
|
return null;
|
|
17
13
|
}
|
|
18
14
|
const itemSeries = series.rangeBar?.series[identifier.seriesId];
|
|
19
|
-
if (series.rangeBar
|
|
15
|
+
if (!series.rangeBar || !itemSeries) {
|
|
20
16
|
return null;
|
|
21
17
|
}
|
|
22
|
-
|
|
18
|
+
const xAxis = xAxes.axis[itemSeries.xAxisId ?? xAxes.axisIds[0]];
|
|
19
|
+
const yAxis = yAxes.axis[itemSeries.yAxisId ?? yAxes.axisIds[0]];
|
|
20
|
+
if (xAxis === undefined || yAxis === undefined) {
|
|
23
21
|
return null;
|
|
24
22
|
}
|
|
25
23
|
const dimensions = (0, _createGetRangeBarDimensions.createGetRangeBarDimensions)({
|
|
26
24
|
verticalLayout: itemSeries.layout === 'vertical',
|
|
27
|
-
xAxisConfig:
|
|
28
|
-
yAxisConfig:
|
|
25
|
+
xAxisConfig: xAxis,
|
|
26
|
+
yAxisConfig: yAxis,
|
|
29
27
|
series: itemSeries,
|
|
30
28
|
numberOfGroups: series.rangeBar.seriesOrder.length
|
|
31
29
|
})(identifier.dataIndex, series.rangeBar.seriesOrder.findIndex(id => id === itemSeries.id));
|
|
@@ -61,5 +59,4 @@ const tooltipItemPositionGetter = params => {
|
|
|
61
59
|
y
|
|
62
60
|
};
|
|
63
61
|
}
|
|
64
|
-
};
|
|
65
|
-
var _default = exports.default = tooltipItemPositionGetter;
|
|
62
|
+
});
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
import { createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
|
+
import { selectorChartsTooltipItem, selectorChartSeriesProcessed, selectorChartXAxis, selectorChartYAxis } from '@mui/x-charts/internals';
|
|
1
3
|
import { createGetRangeBarDimensions } from "../createGetRangeBarDimensions.mjs";
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
series,
|
|
5
|
-
identifier,
|
|
6
|
-
axesConfig,
|
|
7
|
-
placement
|
|
8
|
-
} = params;
|
|
9
|
-
if (!identifier || identifier.dataIndex === undefined) {
|
|
4
|
+
export const selectorTooltipItemPosition = createSelectorMemoized(selectorChartsTooltipItem, selectorChartSeriesProcessed, selectorChartXAxis, selectorChartYAxis, function selectorTooltipItemPosition(identifier, series, xAxes, yAxes, placement) {
|
|
5
|
+
if (!identifier || identifier.type !== 'rangeBar' || identifier.dataIndex === undefined) {
|
|
10
6
|
return null;
|
|
11
7
|
}
|
|
12
8
|
const itemSeries = series.rangeBar?.series[identifier.seriesId];
|
|
13
|
-
if (series.rangeBar
|
|
9
|
+
if (!series.rangeBar || !itemSeries) {
|
|
14
10
|
return null;
|
|
15
11
|
}
|
|
16
|
-
|
|
12
|
+
const xAxis = xAxes.axis[itemSeries.xAxisId ?? xAxes.axisIds[0]];
|
|
13
|
+
const yAxis = yAxes.axis[itemSeries.yAxisId ?? yAxes.axisIds[0]];
|
|
14
|
+
if (xAxis === undefined || yAxis === undefined) {
|
|
17
15
|
return null;
|
|
18
16
|
}
|
|
19
17
|
const dimensions = createGetRangeBarDimensions({
|
|
20
18
|
verticalLayout: itemSeries.layout === 'vertical',
|
|
21
|
-
xAxisConfig:
|
|
22
|
-
yAxisConfig:
|
|
19
|
+
xAxisConfig: xAxis,
|
|
20
|
+
yAxisConfig: yAxis,
|
|
23
21
|
series: itemSeries,
|
|
24
22
|
numberOfGroups: series.rangeBar.seriesOrder.length
|
|
25
23
|
})(identifier.dataIndex, series.rangeBar.seriesOrder.findIndex(id => id === itemSeries.id));
|
|
@@ -55,5 +53,4 @@ const tooltipItemPositionGetter = params => {
|
|
|
55
53
|
y
|
|
56
54
|
};
|
|
57
55
|
}
|
|
58
|
-
};
|
|
59
|
-
export default tooltipItemPositionGetter;
|
|
56
|
+
});
|
|
@@ -5,11 +5,10 @@ export declare class BarWebGLProgram {
|
|
|
5
5
|
private readonly program;
|
|
6
6
|
private readonly vao;
|
|
7
7
|
private readonly quadBuffer;
|
|
8
|
-
private readonly
|
|
9
|
-
private readonly
|
|
10
|
-
private readonly
|
|
11
|
-
private readonly
|
|
12
|
-
private readonly cornerRadiiBuffer;
|
|
8
|
+
private readonly centers;
|
|
9
|
+
private readonly halfSizes;
|
|
10
|
+
private readonly colors;
|
|
11
|
+
private readonly cornerRadii;
|
|
13
12
|
private readonly uResolution;
|
|
14
13
|
constructor(gl: WebGL2RenderingContext);
|
|
15
14
|
setResolution(width: number, height: number): void;
|
|
@@ -5,11 +5,10 @@ export declare class BarWebGLProgram {
|
|
|
5
5
|
private readonly program;
|
|
6
6
|
private readonly vao;
|
|
7
7
|
private readonly quadBuffer;
|
|
8
|
-
private readonly
|
|
9
|
-
private readonly
|
|
10
|
-
private readonly
|
|
11
|
-
private readonly
|
|
12
|
-
private readonly cornerRadiiBuffer;
|
|
8
|
+
private readonly centers;
|
|
9
|
+
private readonly halfSizes;
|
|
10
|
+
private readonly colors;
|
|
11
|
+
private readonly cornerRadii;
|
|
13
12
|
private readonly uResolution;
|
|
14
13
|
constructor(gl: WebGL2RenderingContext);
|
|
15
14
|
setResolution(width: number, height: number): void;
|
|
@@ -5,36 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.BarWebGLProgram = void 0;
|
|
7
7
|
var _utils = require("../../utils/webgl/utils");
|
|
8
|
+
var _instancedAttribute = require("../../utils/webgl/instancedAttribute");
|
|
8
9
|
var _shaders = require("./shaders");
|
|
9
10
|
class BarWebGLProgram {
|
|
10
11
|
shaders = [];
|
|
12
|
+
|
|
13
|
+
/* Colors come in as Uint8 [0, 255]; normalized=true makes the GPU read them back as vec4 in [0, 1]. */
|
|
14
|
+
|
|
11
15
|
constructor(gl) {
|
|
12
16
|
this.gl = gl;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.program =
|
|
16
|
-
|
|
17
|
-
const fragmentShader = (0, _utils.compileShader)(gl, _shaders.barFragmentShaderSource, gl.FRAGMENT_SHADER);
|
|
18
|
-
gl.attachShader(this.program, vertexShader);
|
|
19
|
-
gl.attachShader(this.program, fragmentShader);
|
|
20
|
-
gl.linkProgram(this.program);
|
|
21
|
-
this.shaders.push(vertexShader, fragmentShader);
|
|
22
|
-
if (process.env.NODE_ENV !== 'production' && !gl.getProgramParameter(this.program, gl.LINK_STATUS)) {
|
|
23
|
-
console.error(`Program linking failed: ${gl.getProgramInfoLog(this.program)}`);
|
|
24
|
-
console.error(`Vertex info-log: ${gl.getShaderInfoLog(vertexShader)}`);
|
|
25
|
-
console.error(`Fragment info-log: ${gl.getShaderInfoLog(fragmentShader)}`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Cache locations once.
|
|
17
|
+
(0, _utils.setupStandardBlending)(gl);
|
|
18
|
+
const linked = (0, _utils.linkProgram)(gl, _shaders.barVertexShaderSource, _shaders.barFragmentShaderSource);
|
|
19
|
+
this.program = linked.program;
|
|
20
|
+
this.shaders.push(...linked.shaders);
|
|
29
21
|
this.uResolution = gl.getUniformLocation(this.program, 'u_resolution');
|
|
30
|
-
this.aPositionLocation = gl.getAttribLocation(this.program, 'a_position');
|
|
31
22
|
this.quadBuffer = (0, _utils.uploadQuadBuffer)(gl);
|
|
32
23
|
this.vao = gl.createVertexArray();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
24
|
+
gl.bindVertexArray(this.vao);
|
|
25
|
+
(0, _utils.bindQuadBuffer)(gl, this.program, this.quadBuffer);
|
|
26
|
+
this.centers = (0, _instancedAttribute.createInstancedAttribute)(gl, this.program, 'a_center', 2);
|
|
27
|
+
this.halfSizes = (0, _instancedAttribute.createInstancedAttribute)(gl, this.program, 'a_halfSize', 2);
|
|
28
|
+
this.colors = (0, _instancedAttribute.createInstancedAttribute)(gl, this.program, 'a_color', 4, gl.UNSIGNED_BYTE, true);
|
|
29
|
+
this.cornerRadii = (0, _instancedAttribute.createInstancedAttribute)(gl, this.program, 'a_cornerRadii', 4);
|
|
30
|
+
gl.bindVertexArray(null);
|
|
38
31
|
}
|
|
39
32
|
setResolution(width, height) {
|
|
40
33
|
this.gl.useProgram(this.program);
|
|
@@ -42,18 +35,10 @@ class BarWebGLProgram {
|
|
|
42
35
|
}
|
|
43
36
|
plot(plotData) {
|
|
44
37
|
const gl = this.gl;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer);
|
|
50
|
-
gl.enableVertexAttribArray(this.aPositionLocation);
|
|
51
|
-
gl.vertexAttribPointer(this.aPositionLocation, 2, gl.FLOAT, false, 0, 0);
|
|
52
|
-
uploadAndBindInstanced(gl, this.centersBuffer, plotData.centers);
|
|
53
|
-
uploadAndBindInstanced(gl, this.halfSizesBuffer, plotData.halfSizes);
|
|
54
|
-
uploadAndBindInstanced(gl, this.colorsBuffer, plotData.colors);
|
|
55
|
-
uploadAndBindInstanced(gl, this.cornerRadiiBuffer, plotData.cornerRadii);
|
|
56
|
-
gl.bindVertexArray(null);
|
|
38
|
+
(0, _utils.uploadGrowableBuffer)(gl, this.centers.buffer, plotData.centers);
|
|
39
|
+
(0, _utils.uploadGrowableBuffer)(gl, this.halfSizes.buffer, plotData.halfSizes);
|
|
40
|
+
(0, _utils.uploadGrowableBuffer)(gl, this.colors.buffer, plotData.colors);
|
|
41
|
+
(0, _utils.uploadGrowableBuffer)(gl, this.cornerRadii.buffer, plotData.cornerRadii);
|
|
57
42
|
(0, _utils.logWebGLErrors)(gl);
|
|
58
43
|
}
|
|
59
44
|
render(count) {
|
|
@@ -71,37 +56,11 @@ class BarWebGLProgram {
|
|
|
71
56
|
gl.deleteProgram(this.program);
|
|
72
57
|
gl.deleteVertexArray(this.vao);
|
|
73
58
|
gl.deleteBuffer(this.quadBuffer);
|
|
74
|
-
gl.deleteBuffer(this.
|
|
75
|
-
gl.deleteBuffer(this.
|
|
76
|
-
gl.deleteBuffer(this.
|
|
77
|
-
gl.deleteBuffer(this.
|
|
59
|
+
gl.deleteBuffer(this.centers.buffer.buffer);
|
|
60
|
+
gl.deleteBuffer(this.halfSizes.buffer.buffer);
|
|
61
|
+
gl.deleteBuffer(this.colors.buffer.buffer);
|
|
62
|
+
gl.deleteBuffer(this.cornerRadii.buffer.buffer);
|
|
78
63
|
this.shaders.forEach(shader => gl.deleteShader(shader));
|
|
79
64
|
}
|
|
80
65
|
}
|
|
81
|
-
exports.BarWebGLProgram = BarWebGLProgram;
|
|
82
|
-
function createInstancedBuffer(gl, program, name, size, glType, normalized) {
|
|
83
|
-
return {
|
|
84
|
-
buffer: gl.createBuffer(),
|
|
85
|
-
capacityBytes: 0,
|
|
86
|
-
lastUploaded: null,
|
|
87
|
-
location: gl.getAttribLocation(program, name),
|
|
88
|
-
size,
|
|
89
|
-
glType,
|
|
90
|
-
normalized
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function uploadAndBindInstanced(gl, target, data) {
|
|
94
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, target.buffer);
|
|
95
|
-
if (target.lastUploaded !== data) {
|
|
96
|
-
if (data.byteLength <= target.capacityBytes) {
|
|
97
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, 0, data);
|
|
98
|
-
} else {
|
|
99
|
-
gl.bufferData(gl.ARRAY_BUFFER, data, gl.DYNAMIC_DRAW);
|
|
100
|
-
target.capacityBytes = data.byteLength;
|
|
101
|
-
}
|
|
102
|
-
target.lastUploaded = data;
|
|
103
|
-
}
|
|
104
|
-
gl.enableVertexAttribArray(target.location);
|
|
105
|
-
gl.vertexAttribPointer(target.location, target.size, target.glType, target.normalized, 0, 0);
|
|
106
|
-
gl.vertexAttribDivisor(target.location, 1);
|
|
107
|
-
}
|
|
66
|
+
exports.BarWebGLProgram = BarWebGLProgram;
|
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bindQuadBuffer, linkProgram, logWebGLErrors, setupStandardBlending, uploadGrowableBuffer, uploadQuadBuffer } from "../../utils/webgl/utils.mjs";
|
|
2
|
+
import { createInstancedAttribute } from "../../utils/webgl/instancedAttribute.mjs";
|
|
2
3
|
import { barFragmentShaderSource, barVertexShaderSource } from "./shaders.mjs";
|
|
3
4
|
export class BarWebGLProgram {
|
|
4
5
|
shaders = [];
|
|
6
|
+
|
|
7
|
+
/* Colors come in as Uint8 [0, 255]; normalized=true makes the GPU read them back as vec4 in [0, 1]. */
|
|
8
|
+
|
|
5
9
|
constructor(gl) {
|
|
6
10
|
this.gl = gl;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.program =
|
|
10
|
-
|
|
11
|
-
const fragmentShader = compileShader(gl, barFragmentShaderSource, gl.FRAGMENT_SHADER);
|
|
12
|
-
gl.attachShader(this.program, vertexShader);
|
|
13
|
-
gl.attachShader(this.program, fragmentShader);
|
|
14
|
-
gl.linkProgram(this.program);
|
|
15
|
-
this.shaders.push(vertexShader, fragmentShader);
|
|
16
|
-
if (process.env.NODE_ENV !== 'production' && !gl.getProgramParameter(this.program, gl.LINK_STATUS)) {
|
|
17
|
-
console.error(`Program linking failed: ${gl.getProgramInfoLog(this.program)}`);
|
|
18
|
-
console.error(`Vertex info-log: ${gl.getShaderInfoLog(vertexShader)}`);
|
|
19
|
-
console.error(`Fragment info-log: ${gl.getShaderInfoLog(fragmentShader)}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Cache locations once.
|
|
11
|
+
setupStandardBlending(gl);
|
|
12
|
+
const linked = linkProgram(gl, barVertexShaderSource, barFragmentShaderSource);
|
|
13
|
+
this.program = linked.program;
|
|
14
|
+
this.shaders.push(...linked.shaders);
|
|
23
15
|
this.uResolution = gl.getUniformLocation(this.program, 'u_resolution');
|
|
24
|
-
this.aPositionLocation = gl.getAttribLocation(this.program, 'a_position');
|
|
25
16
|
this.quadBuffer = uploadQuadBuffer(gl);
|
|
26
17
|
this.vao = gl.createVertexArray();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
18
|
+
gl.bindVertexArray(this.vao);
|
|
19
|
+
bindQuadBuffer(gl, this.program, this.quadBuffer);
|
|
20
|
+
this.centers = createInstancedAttribute(gl, this.program, 'a_center', 2);
|
|
21
|
+
this.halfSizes = createInstancedAttribute(gl, this.program, 'a_halfSize', 2);
|
|
22
|
+
this.colors = createInstancedAttribute(gl, this.program, 'a_color', 4, gl.UNSIGNED_BYTE, true);
|
|
23
|
+
this.cornerRadii = createInstancedAttribute(gl, this.program, 'a_cornerRadii', 4);
|
|
24
|
+
gl.bindVertexArray(null);
|
|
32
25
|
}
|
|
33
26
|
setResolution(width, height) {
|
|
34
27
|
this.gl.useProgram(this.program);
|
|
@@ -36,18 +29,10 @@ export class BarWebGLProgram {
|
|
|
36
29
|
}
|
|
37
30
|
plot(plotData) {
|
|
38
31
|
const gl = this.gl;
|
|
39
|
-
gl
|
|
40
|
-
gl
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer);
|
|
44
|
-
gl.enableVertexAttribArray(this.aPositionLocation);
|
|
45
|
-
gl.vertexAttribPointer(this.aPositionLocation, 2, gl.FLOAT, false, 0, 0);
|
|
46
|
-
uploadAndBindInstanced(gl, this.centersBuffer, plotData.centers);
|
|
47
|
-
uploadAndBindInstanced(gl, this.halfSizesBuffer, plotData.halfSizes);
|
|
48
|
-
uploadAndBindInstanced(gl, this.colorsBuffer, plotData.colors);
|
|
49
|
-
uploadAndBindInstanced(gl, this.cornerRadiiBuffer, plotData.cornerRadii);
|
|
50
|
-
gl.bindVertexArray(null);
|
|
32
|
+
uploadGrowableBuffer(gl, this.centers.buffer, plotData.centers);
|
|
33
|
+
uploadGrowableBuffer(gl, this.halfSizes.buffer, plotData.halfSizes);
|
|
34
|
+
uploadGrowableBuffer(gl, this.colors.buffer, plotData.colors);
|
|
35
|
+
uploadGrowableBuffer(gl, this.cornerRadii.buffer, plotData.cornerRadii);
|
|
51
36
|
logWebGLErrors(gl);
|
|
52
37
|
}
|
|
53
38
|
render(count) {
|
|
@@ -65,36 +50,10 @@ export class BarWebGLProgram {
|
|
|
65
50
|
gl.deleteProgram(this.program);
|
|
66
51
|
gl.deleteVertexArray(this.vao);
|
|
67
52
|
gl.deleteBuffer(this.quadBuffer);
|
|
68
|
-
gl.deleteBuffer(this.
|
|
69
|
-
gl.deleteBuffer(this.
|
|
70
|
-
gl.deleteBuffer(this.
|
|
71
|
-
gl.deleteBuffer(this.
|
|
53
|
+
gl.deleteBuffer(this.centers.buffer.buffer);
|
|
54
|
+
gl.deleteBuffer(this.halfSizes.buffer.buffer);
|
|
55
|
+
gl.deleteBuffer(this.colors.buffer.buffer);
|
|
56
|
+
gl.deleteBuffer(this.cornerRadii.buffer.buffer);
|
|
72
57
|
this.shaders.forEach(shader => gl.deleteShader(shader));
|
|
73
58
|
}
|
|
74
|
-
}
|
|
75
|
-
function createInstancedBuffer(gl, program, name, size, glType, normalized) {
|
|
76
|
-
return {
|
|
77
|
-
buffer: gl.createBuffer(),
|
|
78
|
-
capacityBytes: 0,
|
|
79
|
-
lastUploaded: null,
|
|
80
|
-
location: gl.getAttribLocation(program, name),
|
|
81
|
-
size,
|
|
82
|
-
glType,
|
|
83
|
-
normalized
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function uploadAndBindInstanced(gl, target, data) {
|
|
87
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, target.buffer);
|
|
88
|
-
if (target.lastUploaded !== data) {
|
|
89
|
-
if (data.byteLength <= target.capacityBytes) {
|
|
90
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, 0, data);
|
|
91
|
-
} else {
|
|
92
|
-
gl.bufferData(gl.ARRAY_BUFFER, data, gl.DYNAMIC_DRAW);
|
|
93
|
-
target.capacityBytes = data.byteLength;
|
|
94
|
-
}
|
|
95
|
-
target.lastUploaded = data;
|
|
96
|
-
}
|
|
97
|
-
gl.enableVertexAttribArray(target.location);
|
|
98
|
-
gl.vertexAttribPointer(target.location, target.size, target.glType, target.normalized, 0, 0);
|
|
99
|
-
gl.vertexAttribDivisor(target.location, 1);
|
|
100
59
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const barVertexShaderSource = "\n precision mediump float;\n\n attribute vec2 a_position;\n attribute vec2 a_center;\n attribute vec2 a_halfSize;\n attribute vec4 a_color;\n attribute vec4 a_cornerRadii;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n varying vec2 v_halfSize;\n varying vec4 v_cornerRadii;\n\n uniform vec2 u_resolution;\n\n void main() {\n vec2 position = a_center + a_position * a_halfSize;\n vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0;\n gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);\n\n v_color = a_color;\n v_pos = a_position * a_halfSize;\n v_halfSize = a_halfSize;\n v_cornerRadii = a_cornerRadii;\n }\n ";
|
|
2
|
-
export declare const barFragmentShaderSource = "\n precision mediump float;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n varying vec2 v_halfSize;\n varying vec4 v_cornerRadii;\n\n float roundedBoxSDF(vec2 pos, vec2 halfSize, vec4 r) {\n float radius;\n if (pos.x < 0.0) {\n radius = pos.y < 0.0 ? r.x : r.w;\n } else {\n radius = pos.y < 0.0 ? r.y : r.z;\n }\n\n vec2 q = abs(pos) - halfSize + radius;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius;\n }\n\n void main() {\n float dist = roundedBoxSDF(v_pos, v_halfSize, v_cornerRadii);\n // Anti-alias only outside the SDF (dist >= 0). Starting smoothstep at 0\n // keeps interior pixels at full color instead of fading them.\n float alpha = 1.0 - smoothstep(0.0, 0.5, dist);\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\n }\n ";
|
|
2
|
+
export declare const barFragmentShaderSource = "\n precision mediump float;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n varying vec2 v_halfSize;\n varying vec4 v_cornerRadii;\n\n \n float roundedBoxSDF(vec2 pos, vec2 halfSize, vec4 r) {\n float radius;\n if (pos.x < 0.0) {\n radius = pos.y < 0.0 ? r.x : r.w;\n } else {\n radius = pos.y < 0.0 ? r.y : r.z;\n }\n\n vec2 q = abs(pos) - halfSize + radius;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius;\n }\n \n\n void main() {\n float dist = roundedBoxSDF(v_pos, v_halfSize, v_cornerRadii);\n // Anti-alias only outside the SDF (dist >= 0). Starting smoothstep at 0\n // keeps interior pixels at full color instead of fading them.\n float alpha = 1.0 - smoothstep(0.0, 0.5, dist);\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\n }\n ";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const barVertexShaderSource = "\n precision mediump float;\n\n attribute vec2 a_position;\n attribute vec2 a_center;\n attribute vec2 a_halfSize;\n attribute vec4 a_color;\n attribute vec4 a_cornerRadii;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n varying vec2 v_halfSize;\n varying vec4 v_cornerRadii;\n\n uniform vec2 u_resolution;\n\n void main() {\n vec2 position = a_center + a_position * a_halfSize;\n vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0;\n gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);\n\n v_color = a_color;\n v_pos = a_position * a_halfSize;\n v_halfSize = a_halfSize;\n v_cornerRadii = a_cornerRadii;\n }\n ";
|
|
2
|
-
export declare const barFragmentShaderSource = "\n precision mediump float;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n varying vec2 v_halfSize;\n varying vec4 v_cornerRadii;\n\n float roundedBoxSDF(vec2 pos, vec2 halfSize, vec4 r) {\n float radius;\n if (pos.x < 0.0) {\n radius = pos.y < 0.0 ? r.x : r.w;\n } else {\n radius = pos.y < 0.0 ? r.y : r.z;\n }\n\n vec2 q = abs(pos) - halfSize + radius;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius;\n }\n\n void main() {\n float dist = roundedBoxSDF(v_pos, v_halfSize, v_cornerRadii);\n // Anti-alias only outside the SDF (dist >= 0). Starting smoothstep at 0\n // keeps interior pixels at full color instead of fading them.\n float alpha = 1.0 - smoothstep(0.0, 0.5, dist);\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\n }\n ";
|
|
2
|
+
export declare const barFragmentShaderSource = "\n precision mediump float;\n\n varying vec4 v_color;\n varying vec2 v_pos;\n varying vec2 v_halfSize;\n varying vec4 v_cornerRadii;\n\n \n float roundedBoxSDF(vec2 pos, vec2 halfSize, vec4 r) {\n float radius;\n if (pos.x < 0.0) {\n radius = pos.y < 0.0 ? r.x : r.w;\n } else {\n radius = pos.y < 0.0 ? r.y : r.z;\n }\n\n vec2 q = abs(pos) - halfSize + radius;\n return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius;\n }\n \n\n void main() {\n float dist = roundedBoxSDF(v_pos, v_halfSize, v_cornerRadii);\n // Anti-alias only outside the SDF (dist >= 0). Starting smoothstep at 0\n // keeps interior pixels at full color instead of fading them.\n float alpha = 1.0 - smoothstep(0.0, 0.5, dist);\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);\n }\n ";
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.barVertexShaderSource = exports.barFragmentShaderSource = void 0;
|
|
7
|
+
var _glsl = require("../../utils/webgl/glsl");
|
|
7
8
|
// language=Glsl
|
|
8
9
|
const barVertexShaderSource = exports.barVertexShaderSource = /* glsl */`
|
|
9
10
|
precision mediump float;
|
|
@@ -34,10 +35,6 @@ const barVertexShaderSource = exports.barVertexShaderSource = /* glsl */`
|
|
|
34
35
|
`;
|
|
35
36
|
|
|
36
37
|
// language=Glsl
|
|
37
|
-
// Per-corner radii ordering follows CSS: top-left, top-right, bottom-right, bottom-left.
|
|
38
|
-
// Screen-space conventions after the y-flip in the vertex stage:
|
|
39
|
-
// v_pos.y < 0 -> top, v_pos.y > 0 -> bottom
|
|
40
|
-
// v_pos.x < 0 -> left, v_pos.x > 0 -> right
|
|
41
38
|
const barFragmentShaderSource = exports.barFragmentShaderSource = /* glsl */`
|
|
42
39
|
precision mediump float;
|
|
43
40
|
|
|
@@ -46,17 +43,7 @@ const barFragmentShaderSource = exports.barFragmentShaderSource = /* glsl */`
|
|
|
46
43
|
varying vec2 v_halfSize;
|
|
47
44
|
varying vec4 v_cornerRadii;
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
float radius;
|
|
51
|
-
if (pos.x < 0.0) {
|
|
52
|
-
radius = pos.y < 0.0 ? r.x : r.w;
|
|
53
|
-
} else {
|
|
54
|
-
radius = pos.y < 0.0 ? r.y : r.z;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
vec2 q = abs(pos) - halfSize + radius;
|
|
58
|
-
return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius;
|
|
59
|
-
}
|
|
46
|
+
${_glsl.ROUNDED_BOX_SDF_GLSL}
|
|
60
47
|
|
|
61
48
|
void main() {
|
|
62
49
|
float dist = roundedBoxSDF(v_pos, v_halfSize, v_cornerRadii);
|