@mui/x-charts 7.2.0 → 7.3.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/BarChart/BarChart.js +32 -2
- package/BarChart/BarPlot.js +12 -5
- package/BarChart/getColor.d.ts +3 -0
- package/BarChart/getColor.js +33 -0
- package/CHANGELOG.md +125 -0
- package/ChartContainer/ChartContainer.js +35 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsClipPath/ChartsClipPath.js +2 -2
- package/ChartsLegend/ChartsLegend.js +2 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +4 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -2
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +6 -0
- package/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -3
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +13 -4
- package/ChartsTooltip/utils.d.ts +5 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/ChartsXAxis/ChartsXAxis.js +2 -2
- package/ChartsYAxis/ChartsYAxis.js +2 -2
- package/Gauge/GaugeProvider.js +5 -5
- package/LineChart/AnimatedArea.js +6 -5
- package/LineChart/AnimatedLine.js +7 -5
- package/LineChart/AreaElement.d.ts +1 -0
- package/LineChart/AreaElement.js +4 -1
- package/LineChart/AreaPlot.js +7 -1
- package/LineChart/LineChart.js +32 -2
- package/LineChart/LineElement.d.ts +1 -0
- package/LineChart/LineElement.js +4 -1
- package/LineChart/LineHighlightPlot.js +4 -1
- package/LineChart/LinePlot.js +7 -1
- package/LineChart/MarkPlot.js +5 -5
- package/LineChart/getColor.d.ts +3 -0
- package/LineChart/getColor.js +31 -0
- package/PieChart/PieChart.js +32 -2
- package/PieChart/PiePlot.js +26 -6
- package/PieChart/formatter.js +4 -2
- package/PieChart/getColor.d.ts +2 -0
- package/PieChart/getColor.js +11 -0
- package/PieChart/getPieCoordinates.d.ts +7 -0
- package/PieChart/getPieCoordinates.js +25 -0
- package/PieChart/index.d.ts +1 -0
- package/PieChart/index.js +11 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -2
- package/ScatterChart/Scatter.d.ts +1 -0
- package/ScatterChart/Scatter.js +6 -3
- package/ScatterChart/ScatterChart.js +32 -2
- package/ScatterChart/ScatterPlot.js +3 -0
- package/ScatterChart/getColor.d.ts +3 -0
- package/ScatterChart/getColor.js +31 -0
- package/SparkLineChart/SparkLineChart.js +15 -0
- package/context/CartesianContextProvider.d.ts +2 -2
- package/context/CartesianContextProvider.js +23 -8
- package/esm/BarChart/BarChart.js +32 -2
- package/esm/BarChart/BarPlot.js +13 -5
- package/esm/BarChart/getColor.js +27 -0
- package/esm/ChartContainer/ChartContainer.js +36 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsClipPath/ChartsClipPath.js +2 -2
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -3
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +13 -4
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/Gauge/GaugeProvider.js +5 -5
- package/esm/LineChart/AnimatedArea.js +6 -5
- package/esm/LineChart/AnimatedLine.js +7 -5
- package/esm/LineChart/AreaElement.js +4 -1
- package/esm/LineChart/AreaPlot.js +7 -1
- package/esm/LineChart/LineChart.js +32 -2
- package/esm/LineChart/LineElement.js +4 -1
- package/esm/LineChart/LineHighlightPlot.js +4 -1
- package/esm/LineChart/LinePlot.js +7 -1
- package/esm/LineChart/MarkPlot.js +5 -5
- package/esm/LineChart/getColor.js +25 -0
- package/esm/PieChart/PieChart.js +32 -2
- package/esm/PieChart/PiePlot.js +26 -6
- package/esm/PieChart/formatter.js +4 -2
- package/esm/PieChart/getColor.js +5 -0
- package/esm/PieChart/getPieCoordinates.js +19 -0
- package/esm/PieChart/index.js +2 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -2
- package/esm/ScatterChart/Scatter.js +6 -3
- package/esm/ScatterChart/ScatterChart.js +32 -2
- package/esm/ScatterChart/ScatterPlot.js +3 -0
- package/esm/ScatterChart/getColor.js +25 -0
- package/esm/SparkLineChart/SparkLineChart.js +15 -0
- package/esm/context/CartesianContextProvider.js +23 -8
- package/esm/hooks/index.js +4 -1
- package/esm/hooks/useAxisEvents.js +7 -6
- package/esm/hooks/useChartId.js +8 -0
- package/esm/hooks/useSeries.js +64 -0
- package/esm/hooks/useSvgRef.js +9 -0
- package/esm/internals/colorGetter.js +22 -0
- package/esm/internals/colorScale.js +16 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +96 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +41 -0
- package/esm/internals/components/ChartsAxesGradients/index.js +1 -0
- package/esm/models/colorMapping.js +1 -0
- package/esm/models/seriesType/index.js +6 -1
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +65 -1
- package/hooks/useAxisEvents.js +7 -6
- package/hooks/useChartId.d.ts +1 -0
- package/hooks/useChartId.js +16 -0
- package/hooks/useSeries.d.ts +45 -0
- package/hooks/useSeries.js +75 -0
- package/hooks/useSvgRef.d.ts +2 -0
- package/hooks/useSvgRef.js +17 -0
- package/index.js +1 -1
- package/internals/colorGetter.d.ts +5 -0
- package/internals/colorGetter.js +29 -0
- package/internals/colorScale.d.ts +5 -0
- package/internals/colorScale.js +24 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +3 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +105 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +63 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +12 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +48 -0
- package/internals/components/ChartsAxesGradients/index.d.ts +1 -0
- package/internals/components/ChartsAxesGradients/index.js +16 -0
- package/internals/defaultizeColor.d.ts +4 -4
- package/internals/defaultizeValueFormatter.d.ts +5 -5
- package/internals/getScale.d.ts +2 -2
- package/models/axis.d.ts +44 -4
- package/models/colorMapping.d.ts +45 -0
- package/models/colorMapping.js +5 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/common.d.ts +10 -2
- package/models/seriesType/index.d.ts +2 -0
- package/models/seriesType/index.js +17 -1
- package/modern/BarChart/BarChart.js +32 -2
- package/modern/BarChart/BarPlot.js +13 -5
- package/modern/BarChart/getColor.js +27 -0
- package/modern/ChartContainer/ChartContainer.js +36 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsClipPath/ChartsClipPath.js +2 -2
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -3
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +13 -4
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/Gauge/GaugeProvider.js +5 -5
- package/modern/LineChart/AnimatedArea.js +6 -5
- package/modern/LineChart/AnimatedLine.js +7 -5
- package/modern/LineChart/AreaElement.js +4 -1
- package/modern/LineChart/AreaPlot.js +7 -1
- package/modern/LineChart/LineChart.js +32 -2
- package/modern/LineChart/LineElement.js +4 -1
- package/modern/LineChart/LineHighlightPlot.js +4 -1
- package/modern/LineChart/LinePlot.js +7 -1
- package/modern/LineChart/MarkPlot.js +5 -5
- package/modern/LineChart/getColor.js +25 -0
- package/modern/PieChart/PieChart.js +32 -2
- package/modern/PieChart/PiePlot.js +26 -6
- package/modern/PieChart/formatter.js +4 -2
- package/modern/PieChart/getColor.js +5 -0
- package/modern/PieChart/getPieCoordinates.js +19 -0
- package/modern/PieChart/index.js +2 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -2
- package/modern/ScatterChart/Scatter.js +6 -3
- package/modern/ScatterChart/ScatterChart.js +32 -2
- package/modern/ScatterChart/ScatterPlot.js +3 -0
- package/modern/ScatterChart/getColor.js +25 -0
- package/modern/SparkLineChart/SparkLineChart.js +15 -0
- package/modern/context/CartesianContextProvider.js +23 -8
- package/modern/hooks/index.js +4 -1
- package/modern/hooks/useAxisEvents.js +7 -6
- package/modern/hooks/useChartId.js +8 -0
- package/modern/hooks/useSeries.js +64 -0
- package/modern/hooks/useSvgRef.js +9 -0
- package/modern/index.js +1 -1
- package/modern/internals/colorGetter.js +22 -0
- package/modern/internals/colorScale.js +16 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +96 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +41 -0
- package/modern/internals/components/ChartsAxesGradients/index.js +1 -0
- package/modern/models/colorMapping.js +1 -0
- package/modern/models/seriesType/index.js +6 -1
- package/package.json +1 -1
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
3
3
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
4
|
-
import { SvgContext, DrawingContext } from '../context/DrawingProvider';
|
|
5
4
|
import { isBandScale } from '../internals/isBandScale';
|
|
6
5
|
import { getSVGPoint } from '../internals/utils';
|
|
6
|
+
import { useSvgRef } from './useSvgRef';
|
|
7
|
+
import { useDrawingArea } from './useDrawingArea';
|
|
7
8
|
function getAsANumber(value) {
|
|
8
9
|
return value instanceof Date ? value.getTime() : value;
|
|
9
10
|
}
|
|
10
11
|
export const useAxisEvents = disableAxisListener => {
|
|
11
|
-
const svgRef =
|
|
12
|
+
const svgRef = useSvgRef();
|
|
12
13
|
const {
|
|
13
|
-
|
|
14
|
-
height,
|
|
14
|
+
left,
|
|
15
15
|
top,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
width,
|
|
17
|
+
height
|
|
18
|
+
} = useDrawingArea();
|
|
18
19
|
const {
|
|
19
20
|
xAxis,
|
|
20
21
|
yAxis,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get access to the internal state of series.
|
|
6
|
+
* Structured by type of series:
|
|
7
|
+
* { seriesType?: { series: { id1: precessedValue, ... }, seriesOrder: [id1, ...] } }
|
|
8
|
+
* @returns FormattedSeries series
|
|
9
|
+
*/
|
|
10
|
+
export function useSeries() {
|
|
11
|
+
const series = React.useContext(SeriesContext);
|
|
12
|
+
if (series === undefined) {
|
|
13
|
+
throw new Error(['MUI X: Could not find the series ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
14
|
+
}
|
|
15
|
+
return series;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get access to the internal state of pie series.
|
|
20
|
+
* The returned object contains:
|
|
21
|
+
* - series: a mapping from ids to series attributes.
|
|
22
|
+
* - seriesOrder: the array of series ids.
|
|
23
|
+
* @returns { series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined pieSeries
|
|
24
|
+
*/
|
|
25
|
+
export function usePieSeries() {
|
|
26
|
+
const series = useSeries();
|
|
27
|
+
return React.useMemo(() => series.pie, [series.pie]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get access to the internal state of line series.
|
|
32
|
+
* The returned object contains:
|
|
33
|
+
* - series: a mapping from ids to series attributes.
|
|
34
|
+
* - seriesOrder: the array of series ids.
|
|
35
|
+
* @returns { series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined lineSeries
|
|
36
|
+
*/
|
|
37
|
+
export function useLineSeries() {
|
|
38
|
+
const series = useSeries();
|
|
39
|
+
return React.useMemo(() => series.line, [series.line]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get access to the internal state of bar series.
|
|
44
|
+
* The returned object contains:
|
|
45
|
+
* - series: a mapping from ids to series attributes.
|
|
46
|
+
* - seriesOrder: the array of series ids.
|
|
47
|
+
* @returns { series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined barSeries
|
|
48
|
+
*/
|
|
49
|
+
export function useBarSeries() {
|
|
50
|
+
const series = useSeries();
|
|
51
|
+
return React.useMemo(() => series.bar, [series.bar]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get access to the internal state of scatter series.
|
|
56
|
+
* The returned object contains:
|
|
57
|
+
* - series: a mapping from ids to series attributes.
|
|
58
|
+
* - seriesOrder: the array of series ids.
|
|
59
|
+
* @returns { series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined scatterSeries
|
|
60
|
+
*/
|
|
61
|
+
export function useScatterSeries() {
|
|
62
|
+
const series = useSeries();
|
|
63
|
+
return React.useMemo(() => series.scatter, [series.scatter]);
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SvgContext } from '../context/DrawingProvider';
|
|
3
|
+
export function useSvgRef() {
|
|
4
|
+
const svgRef = React.useContext(SvgContext);
|
|
5
|
+
if (svgRef === undefined) {
|
|
6
|
+
throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
7
|
+
}
|
|
8
|
+
return svgRef;
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import getBarColor from '../BarChart/getColor';
|
|
2
|
+
import getLineColor from '../LineChart/getColor';
|
|
3
|
+
import getScatterColor from '../ScatterChart/getColor';
|
|
4
|
+
import getPieColor from '../PieChart/getColor';
|
|
5
|
+
function getColor(series, xAxis, yAxis) {
|
|
6
|
+
if (xAxis !== undefined && yAxis !== undefined) {
|
|
7
|
+
if (series.type === 'bar') {
|
|
8
|
+
return getBarColor(series, xAxis, yAxis);
|
|
9
|
+
}
|
|
10
|
+
if (series.type === 'line') {
|
|
11
|
+
return getLineColor(series, xAxis, yAxis);
|
|
12
|
+
}
|
|
13
|
+
if (series.type === 'scatter') {
|
|
14
|
+
return getScatterColor(series, xAxis, yAxis);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (series.type === 'pie') {
|
|
18
|
+
return getPieColor(series);
|
|
19
|
+
}
|
|
20
|
+
throw Error(`MUI X Charts: getColor called with unexpected arguments for series with id "${series.id}"`);
|
|
21
|
+
}
|
|
22
|
+
export default getColor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { scaleOrdinal, scaleThreshold, scaleSequential } from 'd3-scale';
|
|
2
|
+
export function getSequentialColorScale(config) {
|
|
3
|
+
if (config.type === 'piecewise') {
|
|
4
|
+
return scaleThreshold(config.thresholds, config.colors);
|
|
5
|
+
}
|
|
6
|
+
return scaleSequential([config.min ?? 0, config.max ?? 100], config.color);
|
|
7
|
+
}
|
|
8
|
+
export function getOrdinalColorScale(config) {
|
|
9
|
+
if (config.values) {
|
|
10
|
+
return scaleOrdinal(config.values, config.colors).unknown(config.unknownColor ?? null);
|
|
11
|
+
}
|
|
12
|
+
return scaleOrdinal(config.colors.map((_, index) => index), config.colors).unknown(config.unknownColor ?? null);
|
|
13
|
+
}
|
|
14
|
+
export function getColorScale(config) {
|
|
15
|
+
return config.type === 'ordinal' ? getOrdinalColorScale(config) : getSequentialColorScale(config);
|
|
16
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CartesianContext } from '../../../context/CartesianContextProvider';
|
|
3
|
+
import { DrawingContext } from '../../../context/DrawingProvider';
|
|
4
|
+
import { useDrawingArea } from '../../../hooks';
|
|
5
|
+
import ChartsPiecewiseGradient from './ChartsPiecewiseGradient';
|
|
6
|
+
import ChartsContinuousGradient from './ChartsContinuousGradient';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export function useChartGradient() {
|
|
10
|
+
const {
|
|
11
|
+
chartId
|
|
12
|
+
} = React.useContext(DrawingContext);
|
|
13
|
+
return React.useCallback((axisId, direction) => `${chartId}-graient-${direction}-${axisId}`, [chartId]);
|
|
14
|
+
}
|
|
15
|
+
export function ChartsAxesGradients() {
|
|
16
|
+
const {
|
|
17
|
+
top,
|
|
18
|
+
height,
|
|
19
|
+
bottom,
|
|
20
|
+
left,
|
|
21
|
+
width,
|
|
22
|
+
right
|
|
23
|
+
} = useDrawingArea();
|
|
24
|
+
const svgHeight = top + height + bottom;
|
|
25
|
+
const svgWidth = left + width + right;
|
|
26
|
+
const getGradientId = useChartGradient();
|
|
27
|
+
const {
|
|
28
|
+
xAxisIds,
|
|
29
|
+
xAxis,
|
|
30
|
+
yAxisIds,
|
|
31
|
+
yAxis
|
|
32
|
+
} = React.useContext(CartesianContext);
|
|
33
|
+
return /*#__PURE__*/_jsxs("defs", {
|
|
34
|
+
children: [yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined).map(axisId => {
|
|
35
|
+
const gradientId = getGradientId(axisId, 'y');
|
|
36
|
+
const {
|
|
37
|
+
colorMap,
|
|
38
|
+
scale,
|
|
39
|
+
colorScale,
|
|
40
|
+
reverse
|
|
41
|
+
} = yAxis[axisId];
|
|
42
|
+
if (colorMap?.type === 'piecewise') {
|
|
43
|
+
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
44
|
+
isReveresed: !reverse,
|
|
45
|
+
scale: scale,
|
|
46
|
+
colorMap: colorMap,
|
|
47
|
+
size: svgHeight,
|
|
48
|
+
gradientId: gradientId,
|
|
49
|
+
direction: "y"
|
|
50
|
+
}, gradientId);
|
|
51
|
+
}
|
|
52
|
+
if (colorMap?.type === 'continuous') {
|
|
53
|
+
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
54
|
+
isReveresed: !reverse,
|
|
55
|
+
scale: scale,
|
|
56
|
+
colorScale: colorScale,
|
|
57
|
+
colorMap: colorMap,
|
|
58
|
+
size: svgHeight,
|
|
59
|
+
gradientId: gradientId,
|
|
60
|
+
direction: "y"
|
|
61
|
+
}, gradientId);
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}), xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined).map(axisId => {
|
|
65
|
+
const gradientId = getGradientId(axisId, 'x');
|
|
66
|
+
const {
|
|
67
|
+
colorMap,
|
|
68
|
+
scale,
|
|
69
|
+
reverse,
|
|
70
|
+
colorScale
|
|
71
|
+
} = xAxis[axisId];
|
|
72
|
+
if (colorMap?.type === 'piecewise') {
|
|
73
|
+
return /*#__PURE__*/_jsx(ChartsPiecewiseGradient, {
|
|
74
|
+
isReveresed: reverse,
|
|
75
|
+
scale: scale,
|
|
76
|
+
colorMap: colorMap,
|
|
77
|
+
size: svgWidth,
|
|
78
|
+
gradientId: gradientId,
|
|
79
|
+
direction: "x"
|
|
80
|
+
}, gradientId);
|
|
81
|
+
}
|
|
82
|
+
if (colorMap?.type === 'continuous') {
|
|
83
|
+
return /*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
84
|
+
isReveresed: reverse,
|
|
85
|
+
scale: scale,
|
|
86
|
+
colorScale: colorScale,
|
|
87
|
+
colorMap: colorMap,
|
|
88
|
+
size: svgWidth,
|
|
89
|
+
gradientId: gradientId,
|
|
90
|
+
direction: "x"
|
|
91
|
+
}, gradientId);
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { interpolateDate, interpolateNumber } from 'd3-interpolate';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const PX_PRECISION = 10;
|
|
5
|
+
export default function ChartsContinuousGradient(props) {
|
|
6
|
+
const {
|
|
7
|
+
isReveresed,
|
|
8
|
+
gradientId,
|
|
9
|
+
size,
|
|
10
|
+
direction,
|
|
11
|
+
scale,
|
|
12
|
+
colorScale,
|
|
13
|
+
colorMap
|
|
14
|
+
} = props;
|
|
15
|
+
const extremValues = [colorMap.min ?? 0, colorMap.max ?? 100];
|
|
16
|
+
const extremPositions = extremValues.map(scale).filter(p => p !== undefined);
|
|
17
|
+
if (extremPositions.length !== 2) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const interpolator = typeof extremValues[0] === 'number' ? interpolateNumber(extremValues[0], extremValues[1]) : interpolateDate(extremValues[0], extremValues[1]);
|
|
21
|
+
const numberOfPoints = Math.round((Math.max(...extremPositions) - Math.min(...extremPositions)) / PX_PRECISION);
|
|
22
|
+
const keyPrefix = `${extremValues[0]}-${extremValues[1]}-`;
|
|
23
|
+
return /*#__PURE__*/_jsx("linearGradient", {
|
|
24
|
+
id: gradientId,
|
|
25
|
+
x1: "0",
|
|
26
|
+
x2: "0",
|
|
27
|
+
y1: "0",
|
|
28
|
+
y2: "0",
|
|
29
|
+
[`${direction}${isReveresed ? 1 : 2}`]: `${size}px`,
|
|
30
|
+
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
31
|
+
,
|
|
32
|
+
children: Array.from({
|
|
33
|
+
length: numberOfPoints + 1
|
|
34
|
+
}, (_, index) => {
|
|
35
|
+
const value = interpolator(index / numberOfPoints);
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const x = scale(value);
|
|
40
|
+
if (x === undefined) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const offset = isReveresed ? 1 - x / size : x / size;
|
|
44
|
+
const color = colorScale(value);
|
|
45
|
+
if (color === null) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/_jsx("stop", {
|
|
49
|
+
offset: offset,
|
|
50
|
+
stopColor: color,
|
|
51
|
+
stopOpacity: 1
|
|
52
|
+
}, keyPrefix + index);
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
export default function ChartsPiecewiseGradient(props) {
|
|
5
|
+
const {
|
|
6
|
+
isReveresed,
|
|
7
|
+
gradientId,
|
|
8
|
+
size,
|
|
9
|
+
direction,
|
|
10
|
+
scale,
|
|
11
|
+
colorMap
|
|
12
|
+
} = props;
|
|
13
|
+
return /*#__PURE__*/_jsx("linearGradient", {
|
|
14
|
+
id: gradientId,
|
|
15
|
+
x1: "0",
|
|
16
|
+
x2: "0",
|
|
17
|
+
y1: "0",
|
|
18
|
+
y2: "0",
|
|
19
|
+
[`${direction}${isReveresed ? 1 : 2}`]: `${size}px`,
|
|
20
|
+
gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
|
|
21
|
+
,
|
|
22
|
+
children: colorMap.thresholds.map((threshold, index) => {
|
|
23
|
+
const x = scale(threshold);
|
|
24
|
+
if (x === undefined) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const offset = isReveresed ? 1 - x / size : x / size;
|
|
28
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
29
|
+
children: [/*#__PURE__*/_jsx("stop", {
|
|
30
|
+
offset: offset,
|
|
31
|
+
stopColor: colorMap.colors[index],
|
|
32
|
+
stopOpacity: 1
|
|
33
|
+
}), /*#__PURE__*/_jsx("stop", {
|
|
34
|
+
offset: offset,
|
|
35
|
+
stopColor: colorMap.colors[index + 1],
|
|
36
|
+
stopOpacity: 1
|
|
37
|
+
})]
|
|
38
|
+
}, threshold.toString() + index);
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChartsAxesGradients';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,4 +2,9 @@ export * from './line';
|
|
|
2
2
|
export * from './bar';
|
|
3
3
|
export * from './scatter';
|
|
4
4
|
export * from './pie';
|
|
5
|
-
export {
|
|
5
|
+
export function isDefaultizedBarSeries(series) {
|
|
6
|
+
return series.type === 'bar';
|
|
7
|
+
}
|
|
8
|
+
export function isBarSeries(series) {
|
|
9
|
+
return series.type === 'bar';
|
|
10
|
+
}
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export * from './useDrawingArea';
|
|
2
|
+
export * from './useChartId';
|
|
2
3
|
export * from './useScale';
|
|
4
|
+
export * from './useSvgRef';
|
|
5
|
+
export { useSeries as unstable_useSeries, usePieSeries as unstable_usePieSeries, useLineSeries as unstable_useLineSeries, useBarSeries as unstable_useBarSeries, useScatterSeries as unstable_useScatterSeries, } from './useSeries';
|
package/hooks/index.js
CHANGED
|
@@ -3,9 +3,47 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
unstable_useSeries: true,
|
|
8
|
+
unstable_usePieSeries: true,
|
|
9
|
+
unstable_useLineSeries: true,
|
|
10
|
+
unstable_useBarSeries: true,
|
|
11
|
+
unstable_useScatterSeries: true
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "unstable_useBarSeries", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _useSeries.useBarSeries;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "unstable_useLineSeries", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _useSeries.useLineSeries;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "unstable_usePieSeries", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _useSeries.usePieSeries;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "unstable_useScatterSeries", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _useSeries.useScatterSeries;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "unstable_useSeries", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _useSeries.useSeries;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
6
43
|
var _useDrawingArea = require("./useDrawingArea");
|
|
7
44
|
Object.keys(_useDrawingArea).forEach(function (key) {
|
|
8
45
|
if (key === "default" || key === "__esModule") return;
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
9
47
|
if (key in exports && exports[key] === _useDrawingArea[key]) return;
|
|
10
48
|
Object.defineProperty(exports, key, {
|
|
11
49
|
enumerable: true,
|
|
@@ -14,9 +52,22 @@ Object.keys(_useDrawingArea).forEach(function (key) {
|
|
|
14
52
|
}
|
|
15
53
|
});
|
|
16
54
|
});
|
|
55
|
+
var _useChartId = require("./useChartId");
|
|
56
|
+
Object.keys(_useChartId).forEach(function (key) {
|
|
57
|
+
if (key === "default" || key === "__esModule") return;
|
|
58
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
59
|
+
if (key in exports && exports[key] === _useChartId[key]) return;
|
|
60
|
+
Object.defineProperty(exports, key, {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _useChartId[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
17
67
|
var _useScale = require("./useScale");
|
|
18
68
|
Object.keys(_useScale).forEach(function (key) {
|
|
19
69
|
if (key === "default" || key === "__esModule") return;
|
|
70
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
71
|
if (key in exports && exports[key] === _useScale[key]) return;
|
|
21
72
|
Object.defineProperty(exports, key, {
|
|
22
73
|
enumerable: true,
|
|
@@ -24,4 +75,17 @@ Object.keys(_useScale).forEach(function (key) {
|
|
|
24
75
|
return _useScale[key];
|
|
25
76
|
}
|
|
26
77
|
});
|
|
27
|
-
});
|
|
78
|
+
});
|
|
79
|
+
var _useSvgRef = require("./useSvgRef");
|
|
80
|
+
Object.keys(_useSvgRef).forEach(function (key) {
|
|
81
|
+
if (key === "default" || key === "__esModule") return;
|
|
82
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
83
|
+
if (key in exports && exports[key] === _useSvgRef[key]) return;
|
|
84
|
+
Object.defineProperty(exports, key, {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _useSvgRef[key];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
var _useSeries = require("./useSeries");
|
package/hooks/useAxisEvents.js
CHANGED
|
@@ -7,22 +7,23 @@ exports.useAxisEvents = void 0;
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
9
9
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
10
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
11
10
|
var _isBandScale = require("../internals/isBandScale");
|
|
12
11
|
var _utils = require("../internals/utils");
|
|
12
|
+
var _useSvgRef = require("./useSvgRef");
|
|
13
|
+
var _useDrawingArea = require("./useDrawingArea");
|
|
13
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
16
|
function getAsANumber(value) {
|
|
16
17
|
return value instanceof Date ? value.getTime() : value;
|
|
17
18
|
}
|
|
18
19
|
const useAxisEvents = disableAxisListener => {
|
|
19
|
-
const svgRef =
|
|
20
|
+
const svgRef = (0, _useSvgRef.useSvgRef)();
|
|
20
21
|
const {
|
|
21
|
-
|
|
22
|
-
height,
|
|
22
|
+
left,
|
|
23
23
|
top,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
width,
|
|
25
|
+
height
|
|
26
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
26
27
|
const {
|
|
27
28
|
xAxis,
|
|
28
29
|
yAxis,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useChartId(): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChartId = useChartId;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _DrawingProvider = require("../context/DrawingProvider");
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function useChartId() {
|
|
12
|
+
const {
|
|
13
|
+
chartId
|
|
14
|
+
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
15
|
+
return React.useMemo(() => chartId, [chartId]);
|
|
16
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get access to the internal state of series.
|
|
3
|
+
* Structured by type of series:
|
|
4
|
+
* { seriesType?: { series: { id1: precessedValue, ... }, seriesOrder: [id1, ...] } }
|
|
5
|
+
* @returns FormattedSeries series
|
|
6
|
+
*/
|
|
7
|
+
export declare function useSeries(): import("../context/SeriesContextProvider").FormattedSeries;
|
|
8
|
+
/**
|
|
9
|
+
* Get access to the internal state of pie series.
|
|
10
|
+
* The returned object contains:
|
|
11
|
+
* - series: a mapping from ids to series attributes.
|
|
12
|
+
* - seriesOrder: the array of series ids.
|
|
13
|
+
* @returns { series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined pieSeries
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePieSeries(): {
|
|
16
|
+
series: Record<import("../models/seriesType/common").SeriesId, import("..").DefaultizedPieSeriesType>;
|
|
17
|
+
seriesOrder: import("../models/seriesType/common").SeriesId[];
|
|
18
|
+
} | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get access to the internal state of line series.
|
|
21
|
+
* The returned object contains:
|
|
22
|
+
* - series: a mapping from ids to series attributes.
|
|
23
|
+
* - seriesOrder: the array of series ids.
|
|
24
|
+
* @returns { series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined lineSeries
|
|
25
|
+
*/
|
|
26
|
+
export declare function useLineSeries(): import("../models/seriesType/config").FormatterResult<"line"> | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get access to the internal state of bar series.
|
|
29
|
+
* The returned object contains:
|
|
30
|
+
* - series: a mapping from ids to series attributes.
|
|
31
|
+
* - seriesOrder: the array of series ids.
|
|
32
|
+
* @returns { series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined barSeries
|
|
33
|
+
*/
|
|
34
|
+
export declare function useBarSeries(): import("../models/seriesType/config").FormatterResult<"bar"> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Get access to the internal state of scatter series.
|
|
37
|
+
* The returned object contains:
|
|
38
|
+
* - series: a mapping from ids to series attributes.
|
|
39
|
+
* - seriesOrder: the array of series ids.
|
|
40
|
+
* @returns { series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined scatterSeries
|
|
41
|
+
*/
|
|
42
|
+
export declare function useScatterSeries(): {
|
|
43
|
+
series: Record<import("../models/seriesType/common").SeriesId, import("..").DefaultizedScatterSeriesType>;
|
|
44
|
+
seriesOrder: import("../models/seriesType/common").SeriesId[];
|
|
45
|
+
} | undefined;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useBarSeries = useBarSeries;
|
|
7
|
+
exports.useLineSeries = useLineSeries;
|
|
8
|
+
exports.usePieSeries = usePieSeries;
|
|
9
|
+
exports.useScatterSeries = useScatterSeries;
|
|
10
|
+
exports.useSeries = useSeries;
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
/**
|
|
16
|
+
* Get access to the internal state of series.
|
|
17
|
+
* Structured by type of series:
|
|
18
|
+
* { seriesType?: { series: { id1: precessedValue, ... }, seriesOrder: [id1, ...] } }
|
|
19
|
+
* @returns FormattedSeries series
|
|
20
|
+
*/
|
|
21
|
+
function useSeries() {
|
|
22
|
+
const series = React.useContext(_SeriesContextProvider.SeriesContext);
|
|
23
|
+
if (series === undefined) {
|
|
24
|
+
throw new Error(['MUI X: Could not find the series ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
25
|
+
}
|
|
26
|
+
return series;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get access to the internal state of pie series.
|
|
31
|
+
* The returned object contains:
|
|
32
|
+
* - series: a mapping from ids to series attributes.
|
|
33
|
+
* - seriesOrder: the array of series ids.
|
|
34
|
+
* @returns { series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined pieSeries
|
|
35
|
+
*/
|
|
36
|
+
function usePieSeries() {
|
|
37
|
+
const series = useSeries();
|
|
38
|
+
return React.useMemo(() => series.pie, [series.pie]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get access to the internal state of line series.
|
|
43
|
+
* The returned object contains:
|
|
44
|
+
* - series: a mapping from ids to series attributes.
|
|
45
|
+
* - seriesOrder: the array of series ids.
|
|
46
|
+
* @returns { series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined lineSeries
|
|
47
|
+
*/
|
|
48
|
+
function useLineSeries() {
|
|
49
|
+
const series = useSeries();
|
|
50
|
+
return React.useMemo(() => series.line, [series.line]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get access to the internal state of bar series.
|
|
55
|
+
* The returned object contains:
|
|
56
|
+
* - series: a mapping from ids to series attributes.
|
|
57
|
+
* - seriesOrder: the array of series ids.
|
|
58
|
+
* @returns { series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined barSeries
|
|
59
|
+
*/
|
|
60
|
+
function useBarSeries() {
|
|
61
|
+
const series = useSeries();
|
|
62
|
+
return React.useMemo(() => series.bar, [series.bar]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get access to the internal state of scatter series.
|
|
67
|
+
* The returned object contains:
|
|
68
|
+
* - series: a mapping from ids to series attributes.
|
|
69
|
+
* - seriesOrder: the array of series ids.
|
|
70
|
+
* @returns { series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined scatterSeries
|
|
71
|
+
*/
|
|
72
|
+
function useScatterSeries() {
|
|
73
|
+
const series = useSeries();
|
|
74
|
+
return React.useMemo(() => series.scatter, [series.scatter]);
|
|
75
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSvgRef = useSvgRef;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _DrawingProvider = require("../context/DrawingProvider");
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
function useSvgRef() {
|
|
12
|
+
const svgRef = React.useContext(_DrawingProvider.SvgContext);
|
|
13
|
+
if (svgRef === undefined) {
|
|
14
|
+
throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
15
|
+
}
|
|
16
|
+
return svgRef;
|
|
17
|
+
}
|
package/index.js
CHANGED