@mui/x-charts 7.6.1 → 7.7.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.d.ts +1 -1
- package/BarChart/BarChart.js +2 -2
- package/BarChart/BarPlot.js +2 -2
- package/BarChart/formatter.js +2 -2
- package/BarChart/getColor.d.ts +1 -1
- package/BarChart/getColor.js +4 -4
- package/BarChart/plugin.d.ts +2 -0
- package/BarChart/plugin.js +17 -0
- package/CHANGELOG.md +147 -0
- package/ChartContainer/ChartContainer.d.ts +15 -3
- package/ChartContainer/ChartContainer.js +70 -22
- package/ChartContainer/defaultPlugins.d.ts +2 -0
- package/ChartContainer/defaultPlugins.js +11 -0
- package/ChartContainer/usePluginsMerge.d.ts +10 -0
- package/ChartContainer/usePluginsMerge.js +39 -0
- package/ChartsLegend/ChartsLegend.js +2 -2
- package/ChartsLegend/utils.js +4 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
- package/ChartsOverlay/index.d.ts +1 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
- package/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
- package/ChartsText/ChartsText.js +1 -3
- package/ChartsTooltip/ChartsAxisTooltipContent.js +9 -15
- package/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +1 -7
- package/ChartsTooltip/utils.js +2 -10
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/ChartsXAxis/ChartsXAxis.js +17 -19
- package/ChartsYAxis/ChartsYAxis.js +17 -19
- package/LineChart/AreaPlot.js +2 -2
- package/LineChart/LineChart.d.ts +2 -2
- package/LineChart/LineChart.js +3 -3
- package/LineChart/LineHighlightPlot.js +2 -2
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/MarkPlot.js +2 -2
- package/LineChart/formatter.js +2 -2
- package/LineChart/getColor.d.ts +1 -1
- package/LineChart/getColor.js +2 -2
- package/LineChart/plugin.d.ts +2 -0
- package/LineChart/plugin.js +17 -0
- package/PieChart/PieChart.d.ts +2 -2
- package/PieChart/PieChart.js +3 -3
- package/PieChart/PiePlot.js +2 -2
- package/PieChart/plugin.d.ts +2 -0
- package/PieChart/plugin.js +14 -0
- package/ResponsiveChartContainer/ResizableContainer.d.ts +10 -0
- package/ResponsiveChartContainer/ResizableContainer.js +32 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -24
- package/ScatterChart/ScatterChart.d.ts +2 -2
- package/ScatterChart/ScatterChart.js +3 -3
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/formatter.js +2 -3
- package/ScatterChart/getColor.d.ts +1 -1
- package/ScatterChart/getColor.js +2 -2
- package/ScatterChart/plugin.d.ts +2 -0
- package/ScatterChart/plugin.js +17 -0
- package/SparkLineChart/SparkLineChart.d.ts +9 -4
- package/SparkLineChart/SparkLineChart.js +58 -2
- package/context/CartesianContextProvider.d.ts +21 -10
- package/context/CartesianContextProvider.js +7 -20
- package/context/ColorProvider.d.ts +12 -0
- package/context/ColorProvider.js +25 -0
- package/context/DrawingProvider.d.ts +3 -1
- package/context/DrawingProvider.js +9 -2
- package/context/HighlightedProvider/HighlightedContext.d.ts +2 -1
- package/context/HighlightedProvider/HighlightedContext.js +8 -5
- package/context/HighlightedProvider/HighlightedProvider.js +15 -12
- package/context/HighlightedProvider/useHighlighted.js +6 -3
- package/context/HighlightedProvider/useItemHighlighted.js +2 -8
- package/context/SeriesContextProvider.d.ts +16 -5
- package/context/SeriesContextProvider.js +14 -17
- package/context/context.types.d.ts +4 -0
- package/context/context.types.js +5 -0
- package/esm/BarChart/BarChart.js +2 -2
- package/esm/BarChart/BarPlot.js +2 -2
- package/esm/BarChart/formatter.js +1 -1
- package/esm/BarChart/getColor.js +4 -4
- package/esm/BarChart/plugin.js +10 -0
- package/esm/ChartContainer/ChartContainer.js +71 -23
- package/esm/ChartContainer/defaultPlugins.js +5 -0
- package/esm/ChartContainer/usePluginsMerge.js +31 -0
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsLegend/utils.js +4 -1
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
- package/esm/ChartsText/ChartsText.js +1 -3
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +2 -8
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/esm/ChartsXAxis/ChartsXAxis.js +17 -19
- package/esm/ChartsYAxis/ChartsYAxis.js +17 -19
- package/esm/LineChart/AreaPlot.js +2 -2
- package/esm/LineChart/LineChart.js +3 -3
- package/esm/LineChart/LineHighlightPlot.js +2 -2
- package/esm/LineChart/LinePlot.js +2 -2
- package/esm/LineChart/MarkPlot.js +2 -2
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/getColor.js +2 -2
- package/esm/LineChart/plugin.js +10 -0
- package/esm/PieChart/PieChart.js +3 -3
- package/esm/PieChart/PiePlot.js +2 -2
- package/esm/PieChart/plugin.js +7 -0
- package/esm/ResponsiveChartContainer/ResizableContainer.js +26 -0
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +31 -23
- package/esm/ScatterChart/ScatterChart.js +3 -3
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/formatter.js +1 -1
- package/esm/ScatterChart/getColor.js +2 -2
- package/esm/ScatterChart/plugin.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +58 -2
- package/esm/context/CartesianContextProvider.js +7 -20
- package/esm/context/ColorProvider.js +16 -0
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/context/HighlightedProvider/HighlightedContext.js +8 -5
- package/esm/context/HighlightedProvider/HighlightedProvider.js +15 -12
- package/esm/context/HighlightedProvider/useHighlighted.js +6 -3
- package/esm/context/HighlightedProvider/useItemHighlighted.js +2 -6
- package/esm/context/SeriesContextProvider.js +14 -17
- package/esm/context/context.types.js +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useColor.js +9 -0
- package/esm/hooks/useColorScale.js +27 -0
- package/esm/hooks/useInteractionItemProps.js +2 -2
- package/esm/hooks/useReducedMotion.js +7 -0
- package/esm/hooks/useSeries.js +6 -3
- package/esm/hooks/useSvgRef.js +6 -3
- package/esm/internals/configInit.js +20 -0
- package/esm/internals/defaultizeValueFormatter.js +2 -3
- package/esm/internals/index.js +27 -0
- package/esm/internals/isCartesian.js +7 -0
- package/esm/internals/warning.js +13 -0
- package/esm/models/index.js +1 -0
- package/esm/models/plugin.js +1 -0
- package/esm/models/seriesType/index.js +6 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +12 -0
- package/hooks/useColor.d.ts +4 -0
- package/hooks/useColor.js +17 -0
- package/hooks/useColorScale.d.ts +4 -0
- package/hooks/useColorScale.js +37 -0
- package/hooks/useInteractionItemProps.js +1 -1
- package/hooks/useReducedMotion.js +7 -0
- package/hooks/useSeries.d.ts +6 -11
- package/hooks/useSeries.js +6 -3
- package/hooks/useSvgRef.js +6 -3
- package/hooks/useTicks.d.ts +4 -2
- package/index.js +1 -1
- package/internals/configInit.d.ts +9 -0
- package/internals/configInit.js +26 -0
- package/internals/defaultizeColor.d.ts +8 -8
- package/internals/defaultizeValueFormatter.d.ts +1 -2
- package/internals/defaultizeValueFormatter.js +2 -3
- package/internals/index.d.ts +17 -0
- package/internals/index.js +203 -0
- package/internals/isCartesian.d.ts +7 -0
- package/internals/isCartesian.js +14 -0
- package/internals/package.json +6 -0
- package/internals/warning.d.ts +1 -0
- package/internals/warning.js +19 -0
- package/models/axis.d.ts +4 -5
- package/models/index.d.ts +1 -0
- package/models/index.js +11 -0
- package/models/plugin.d.ts +16 -0
- package/models/plugin.js +5 -0
- package/models/seriesType/config.d.ts +30 -5
- package/models/seriesType/index.d.ts +8 -11
- package/models/seriesType/index.js +6 -0
- package/modern/BarChart/BarChart.js +2 -2
- package/modern/BarChart/BarPlot.js +2 -2
- package/modern/BarChart/formatter.js +1 -1
- package/modern/BarChart/getColor.js +4 -4
- package/modern/BarChart/plugin.js +10 -0
- package/modern/ChartContainer/ChartContainer.js +71 -23
- package/modern/ChartContainer/defaultPlugins.js +5 -0
- package/modern/ChartContainer/usePluginsMerge.js +31 -0
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsLegend/utils.js +4 -1
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +3 -5
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +3 -5
- package/modern/ChartsText/ChartsText.js +1 -3
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -14
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +8 -18
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +5 -4
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +2 -8
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +17 -19
- package/modern/ChartsYAxis/ChartsYAxis.js +17 -19
- package/modern/LineChart/AreaPlot.js +2 -2
- package/modern/LineChart/LineChart.js +3 -3
- package/modern/LineChart/LineHighlightPlot.js +2 -2
- package/modern/LineChart/LinePlot.js +2 -2
- package/modern/LineChart/MarkPlot.js +2 -2
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/getColor.js +2 -2
- package/modern/LineChart/plugin.js +10 -0
- package/modern/PieChart/PieChart.js +3 -3
- package/modern/PieChart/PiePlot.js +2 -2
- package/modern/PieChart/plugin.js +7 -0
- package/modern/ResponsiveChartContainer/ResizableContainer.js +26 -0
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +31 -23
- package/modern/ScatterChart/ScatterChart.js +3 -3
- package/modern/ScatterChart/ScatterPlot.js +2 -2
- package/modern/ScatterChart/formatter.js +1 -1
- package/modern/ScatterChart/getColor.js +2 -2
- package/modern/ScatterChart/plugin.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +58 -2
- package/modern/context/CartesianContextProvider.js +7 -20
- package/modern/context/ColorProvider.js +16 -0
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/context/HighlightedProvider/HighlightedContext.js +8 -5
- package/modern/context/HighlightedProvider/HighlightedProvider.js +15 -12
- package/modern/context/HighlightedProvider/useHighlighted.js +6 -3
- package/modern/context/HighlightedProvider/useItemHighlighted.js +2 -6
- package/modern/context/SeriesContextProvider.js +14 -17
- package/modern/context/context.types.js +1 -0
- package/modern/hooks/index.js +1 -0
- package/modern/hooks/useColor.js +9 -0
- package/modern/hooks/useColorScale.js +27 -0
- package/modern/hooks/useInteractionItemProps.js +2 -2
- package/modern/hooks/useReducedMotion.js +7 -0
- package/modern/hooks/useSeries.js +6 -3
- package/modern/hooks/useSvgRef.js +6 -3
- package/modern/index.js +1 -1
- package/modern/internals/configInit.js +20 -0
- package/modern/internals/defaultizeValueFormatter.js +2 -3
- package/modern/internals/index.js +27 -0
- package/modern/internals/isCartesian.js +7 -0
- package/modern/internals/warning.js +13 -0
- package/modern/models/index.js +1 -0
- package/modern/models/plugin.js +1 -0
- package/modern/models/seriesType/index.js +6 -0
- package/package.json +2 -2
- package/themeAugmentation/components.d.ts +12 -12
- package/esm/internals/colorGetter.js +0 -22
- package/internals/colorGetter.d.ts +0 -7
- package/internals/colorGetter.js +0 -29
- package/modern/internals/colorGetter.js +0 -22
package/PieChart/PieChart.js
CHANGED
|
@@ -16,7 +16,7 @@ var _ChartsLegend = require("../ChartsLegend");
|
|
|
16
16
|
var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
|
|
17
17
|
var _PiePlot = require("./PiePlot");
|
|
18
18
|
var _useIsRTL = require("../internals/useIsRTL");
|
|
19
|
-
var _ChartsOverlay = require("../ChartsOverlay
|
|
19
|
+
var _ChartsOverlay = require("../ChartsOverlay");
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
21
|
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); }
|
|
22
22
|
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 && {}.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; }
|
|
@@ -316,7 +316,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
316
316
|
labelStyle: _propTypes.default.object,
|
|
317
317
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
318
318
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
319
|
-
position: _propTypes.default.oneOf(['bottom', '
|
|
319
|
+
position: _propTypes.default.oneOf(['bottom', 'top']),
|
|
320
320
|
reverse: _propTypes.default.bool,
|
|
321
321
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
322
322
|
slotProps: _propTypes.default.object,
|
|
@@ -369,7 +369,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
369
369
|
labelStyle: _propTypes.default.object,
|
|
370
370
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
371
371
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
372
|
-
position: _propTypes.default.oneOf(['
|
|
372
|
+
position: _propTypes.default.oneOf(['left', 'right']),
|
|
373
373
|
reverse: _propTypes.default.bool,
|
|
374
374
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
375
375
|
slotProps: _propTypes.default.object,
|
package/PieChart/PiePlot.js
CHANGED
|
@@ -7,12 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.PiePlot = PiePlot;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
11
10
|
var _DrawingProvider = require("../context/DrawingProvider");
|
|
12
11
|
var _PieArcPlot = require("./PieArcPlot");
|
|
13
12
|
var _PieArcLabelPlot = require("./PieArcLabelPlot");
|
|
14
13
|
var _utils = require("../internals/utils");
|
|
15
14
|
var _getPieCoordinates = require("./getPieCoordinates");
|
|
15
|
+
var _useSeries = require("../hooks/useSeries");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
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); }
|
|
18
18
|
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 && {}.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; }
|
|
@@ -33,7 +33,7 @@ function PiePlot(props) {
|
|
|
33
33
|
slotProps,
|
|
34
34
|
onItemClick
|
|
35
35
|
} = props;
|
|
36
|
-
const seriesData =
|
|
36
|
+
const seriesData = (0, _useSeries.usePieSeries)();
|
|
37
37
|
const {
|
|
38
38
|
left,
|
|
39
39
|
top,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.plugin = void 0;
|
|
8
|
+
var _formatter = _interopRequireDefault(require("./formatter"));
|
|
9
|
+
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
10
|
+
const plugin = exports.plugin = {
|
|
11
|
+
seriesType: 'pie',
|
|
12
|
+
colorProcessor: _getColor.default,
|
|
13
|
+
seriesFormatter: _formatter.default
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ResponsiveChartContainerProps } from './ResponsiveChartContainer';
|
|
3
|
+
/**
|
|
4
|
+
* Wrapping div that take the shape of its parent.
|
|
5
|
+
*
|
|
6
|
+
* @ignore - do not document.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ResizableContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
9
|
+
ownerState: Pick<ResponsiveChartContainerProps, 'width' | 'height'>;
|
|
10
|
+
}, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("react").ClassAttributes<HTMLDivElement> | keyof import("react").HTMLAttributes<HTMLDivElement>>, {}>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ResizableContainer = void 0;
|
|
7
|
+
var _styles = require("@mui/material/styles");
|
|
8
|
+
/**
|
|
9
|
+
* Wrapping div that take the shape of its parent.
|
|
10
|
+
*
|
|
11
|
+
* @ignore - do not document.
|
|
12
|
+
*/
|
|
13
|
+
const ResizableContainer = exports.ResizableContainer = (0, _styles.styled)('div', {
|
|
14
|
+
name: 'MuiResponsiveChart',
|
|
15
|
+
slot: 'Container'
|
|
16
|
+
})(({
|
|
17
|
+
ownerState
|
|
18
|
+
}) => ({
|
|
19
|
+
width: ownerState.width ?? '100%',
|
|
20
|
+
height: ownerState.height ?? '100%',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
position: 'relative',
|
|
23
|
+
flexGrow: 1,
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
overflow: 'hidden',
|
|
28
|
+
'&>svg': {
|
|
29
|
+
width: '100%',
|
|
30
|
+
height: '100%'
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
@@ -9,33 +9,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _styles = require("@mui/material/styles");
|
|
13
12
|
var _ChartContainer = require("../ChartContainer");
|
|
14
13
|
var _useChartContainerDimensions = require("./useChartContainerDimensions");
|
|
14
|
+
var _ResizableContainer = require("./ResizableContainer");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
const _excluded = ["width", "height"];
|
|
17
17
|
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); }
|
|
18
18
|
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 && {}.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; }
|
|
19
|
-
const ResizableContainer = (0, _styles.styled)('div', {
|
|
20
|
-
name: 'MuiResponsiveChart',
|
|
21
|
-
slot: 'Container'
|
|
22
|
-
})(({
|
|
23
|
-
ownerState
|
|
24
|
-
}) => ({
|
|
25
|
-
width: ownerState.width ?? '100%',
|
|
26
|
-
height: ownerState.height ?? '100%',
|
|
27
|
-
display: 'flex',
|
|
28
|
-
position: 'relative',
|
|
29
|
-
flexGrow: 1,
|
|
30
|
-
flexDirection: 'column',
|
|
31
|
-
alignItems: 'center',
|
|
32
|
-
justifyContent: 'center',
|
|
33
|
-
overflow: 'hidden',
|
|
34
|
-
'&>svg': {
|
|
35
|
-
width: '100%',
|
|
36
|
-
height: '100%'
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
19
|
const ResponsiveChartContainer = exports.ResponsiveChartContainer = /*#__PURE__*/React.forwardRef(function ResponsiveChartContainer(props, ref) {
|
|
40
20
|
const {
|
|
41
21
|
width: inWidth,
|
|
@@ -43,7 +23,7 @@ const ResponsiveChartContainer = exports.ResponsiveChartContainer = /*#__PURE__*
|
|
|
43
23
|
} = props,
|
|
44
24
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
45
25
|
const [containerRef, width, height] = (0, _useChartContainerDimensions.useChartContainerDimensions)(inWidth, inHeight);
|
|
46
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ResizableContainer, {
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResizableContainer.ResizableContainer, {
|
|
47
27
|
ref: containerRef,
|
|
48
28
|
ownerState: {
|
|
49
29
|
width: inWidth,
|
|
@@ -108,6 +88,11 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
108
88
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
109
89
|
*/
|
|
110
90
|
onHighlightChange: _propTypes.default.func,
|
|
91
|
+
/**
|
|
92
|
+
* An array of plugins defining how to preprocess data.
|
|
93
|
+
* If not provided, the container supports line, bar, scatter and pie charts.
|
|
94
|
+
*/
|
|
95
|
+
plugins: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
111
96
|
/**
|
|
112
97
|
* The array of series to display.
|
|
113
98
|
* Each type of series has its own specificity.
|
|
@@ -161,7 +146,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
161
146
|
labelStyle: _propTypes.default.object,
|
|
162
147
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
163
148
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
164
|
-
position: _propTypes.default.oneOf(['bottom', '
|
|
149
|
+
position: _propTypes.default.oneOf(['bottom', 'top']),
|
|
165
150
|
reverse: _propTypes.default.bool,
|
|
166
151
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
167
152
|
slotProps: _propTypes.default.object,
|
|
@@ -214,7 +199,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
214
199
|
labelStyle: _propTypes.default.object,
|
|
215
200
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
216
201
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
217
|
-
position: _propTypes.default.oneOf(['
|
|
202
|
+
position: _propTypes.default.oneOf(['left', 'right']),
|
|
218
203
|
reverse: _propTypes.default.bool,
|
|
219
204
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
220
205
|
slotProps: _propTypes.default.object,
|
|
@@ -231,5 +216,28 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
231
216
|
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
232
217
|
tickSize: _propTypes.default.number,
|
|
233
218
|
valueFormatter: _propTypes.default.func
|
|
219
|
+
})),
|
|
220
|
+
/**
|
|
221
|
+
* The configuration of the z-axes.
|
|
222
|
+
*/
|
|
223
|
+
zAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
224
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
225
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
226
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
227
|
+
unknownColor: _propTypes.default.string,
|
|
228
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
229
|
+
}), _propTypes.default.shape({
|
|
230
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
231
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
232
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
233
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
234
|
+
}), _propTypes.default.shape({
|
|
235
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
236
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
237
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
238
|
+
})]),
|
|
239
|
+
data: _propTypes.default.array,
|
|
240
|
+
dataKey: _propTypes.default.string,
|
|
241
|
+
id: _propTypes.default.string
|
|
234
242
|
}))
|
|
235
243
|
} : void 0;
|
|
@@ -6,7 +6,7 @@ import { ScatterSeriesType } from '../models/seriesType/scatter';
|
|
|
6
6
|
import { MakeOptional } from '../models/helpers';
|
|
7
7
|
import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '../ChartsTooltip';
|
|
8
8
|
import { ChartsLegendProps, ChartsLegendSlotProps, ChartsLegendSlots } from '../ChartsLegend';
|
|
9
|
-
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '../ChartsOverlay
|
|
9
|
+
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from '../ChartsOverlay';
|
|
10
10
|
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
11
11
|
import { ChartsAxisSlots, ChartsAxisSlotProps } from '../models/axis';
|
|
12
12
|
import { ChartsVoronoiHandlerProps } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
|
|
@@ -16,7 +16,7 @@ export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, Ch
|
|
|
16
16
|
}
|
|
17
17
|
export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps, ChartsOverlaySlotProps {
|
|
18
18
|
}
|
|
19
|
-
export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ZAxisContextProviderProps, 'children' | 'dataset'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Omit<ChartsVoronoiHandlerProps, 'onItemClick'> {
|
|
19
|
+
export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'plugins'>, Omit<ZAxisContextProviderProps, 'children' | 'dataset'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Omit<ChartsVoronoiHandlerProps, 'onItemClick'> {
|
|
20
20
|
/**
|
|
21
21
|
* The series to display in the scatter chart.
|
|
22
22
|
* An array of [[ScatterSeriesType]] objects.
|
|
@@ -13,7 +13,7 @@ var _ResponsiveChartContainer = require("../ResponsiveChartContainer");
|
|
|
13
13
|
var _ChartsAxis = require("../ChartsAxis");
|
|
14
14
|
var _ChartsTooltip = require("../ChartsTooltip");
|
|
15
15
|
var _ChartsLegend = require("../ChartsLegend");
|
|
16
|
-
var _ChartsOverlay = require("../ChartsOverlay
|
|
16
|
+
var _ChartsOverlay = require("../ChartsOverlay");
|
|
17
17
|
var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
|
|
18
18
|
var _ChartsVoronoiHandler = require("../ChartsVoronoiHandler/ChartsVoronoiHandler");
|
|
19
19
|
var _ChartsGrid = require("../ChartsGrid");
|
|
@@ -311,7 +311,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
311
311
|
labelStyle: _propTypes.default.object,
|
|
312
312
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
313
313
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
314
|
-
position: _propTypes.default.oneOf(['bottom', '
|
|
314
|
+
position: _propTypes.default.oneOf(['bottom', 'top']),
|
|
315
315
|
reverse: _propTypes.default.bool,
|
|
316
316
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
317
317
|
slotProps: _propTypes.default.object,
|
|
@@ -364,7 +364,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
364
364
|
labelStyle: _propTypes.default.object,
|
|
365
365
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
366
366
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
367
|
-
position: _propTypes.default.oneOf(['
|
|
367
|
+
position: _propTypes.default.oneOf(['left', 'right']),
|
|
368
368
|
reverse: _propTypes.default.bool,
|
|
369
369
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
370
370
|
slotProps: _propTypes.default.object,
|
|
@@ -9,10 +9,10 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _Scatter = require("./Scatter");
|
|
12
|
-
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
13
12
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
14
13
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
15
14
|
var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
|
|
15
|
+
var _useSeries = require("../hooks/useSeries");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
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); }
|
|
18
18
|
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 && {}.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; }
|
|
@@ -32,7 +32,7 @@ function ScatterPlot(props) {
|
|
|
32
32
|
slotProps,
|
|
33
33
|
onItemClick
|
|
34
34
|
} = props;
|
|
35
|
-
const seriesData =
|
|
35
|
+
const seriesData = (0, _useSeries.useScatterSeries)();
|
|
36
36
|
const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
37
37
|
const {
|
|
38
38
|
zAxis,
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var _defaultizeValueFormatter =
|
|
7
|
+
var _defaultizeValueFormatter = require("../internals/defaultizeValueFormatter");
|
|
9
8
|
const formatter = ({
|
|
10
9
|
series,
|
|
11
10
|
seriesOrder
|
|
12
11
|
}) => {
|
|
13
12
|
return {
|
|
14
|
-
series: (0, _defaultizeValueFormatter.
|
|
13
|
+
series: (0, _defaultizeValueFormatter.defaultizeValueFormatter)(series, v => `(${v.x}, ${v.y})`),
|
|
15
14
|
seriesOrder
|
|
16
15
|
};
|
|
17
16
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AxisDefaultized } from '../models/axis';
|
|
2
2
|
import { ZAxisDefaultized } from '../models/z-axis';
|
|
3
3
|
import { DefaultizedScatterSeriesType } from '../models/seriesType/scatter';
|
|
4
|
-
export default function getColor(series: DefaultizedScatterSeriesType, xAxis
|
|
4
|
+
export default function getColor(series: DefaultizedScatterSeriesType, xAxis?: AxisDefaultized, yAxis?: AxisDefaultized, zAxis?: ZAxisDefaultized): (dataIndex: number) => string;
|
package/ScatterChart/getColor.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = getColor;
|
|
7
7
|
function getColor(series, xAxis, yAxis, zAxis) {
|
|
8
8
|
const zColorScale = zAxis?.colorScale;
|
|
9
|
-
const yColorScale = yAxis
|
|
10
|
-
const xColorScale = xAxis
|
|
9
|
+
const yColorScale = yAxis?.colorScale;
|
|
10
|
+
const xColorScale = xAxis?.colorScale;
|
|
11
11
|
if (zColorScale) {
|
|
12
12
|
return dataIndex => {
|
|
13
13
|
if (zAxis?.data?.[dataIndex] !== undefined) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.plugin = void 0;
|
|
8
|
+
var _extremums = require("./extremums");
|
|
9
|
+
var _formatter = _interopRequireDefault(require("./formatter"));
|
|
10
|
+
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
11
|
+
const plugin = exports.plugin = {
|
|
12
|
+
seriesType: 'scatter',
|
|
13
|
+
seriesFormatter: _formatter.default,
|
|
14
|
+
colorProcessor: _getColor.default,
|
|
15
|
+
xExtremumGetter: _extremums.getExtremumX,
|
|
16
|
+
yExtremumGetter: _extremums.getExtremumY
|
|
17
|
+
};
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { ResponsiveChartContainerProps } from '../ResponsiveChartContainer';
|
|
3
3
|
import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '../ChartsTooltip';
|
|
4
4
|
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
5
|
-
import { AxisConfig } from '../models/axis';
|
|
5
|
+
import { AxisConfig, ChartsXAxisProps, ChartsYAxisProps, ScaleName } from '../models/axis';
|
|
6
6
|
import { MakeOptional } from '../models/helpers';
|
|
7
7
|
import { LineSeriesType } from '../models/seriesType/line';
|
|
8
8
|
import { CardinalDirections } from '../models/layout';
|
|
@@ -15,12 +15,17 @@ export interface SparkLineChartSlots extends AreaPlotSlots, LinePlotSlots, MarkP
|
|
|
15
15
|
}
|
|
16
16
|
export interface SparkLineChartSlotProps extends AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, BarPlotSlotProps, ChartsTooltipSlotProps {
|
|
17
17
|
}
|
|
18
|
-
export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'margin'> {
|
|
18
|
+
export interface SparkLineChartProps extends Omit<ResponsiveChartContainerProps, 'series' | 'xAxis' | 'yAxis' | 'zAxis' | 'margin' | 'plugins'> {
|
|
19
19
|
/**
|
|
20
20
|
* The xAxis configuration.
|
|
21
|
-
* Notice it is a single
|
|
21
|
+
* Notice it is a single [[AxisConfig]] object, not an array of configuration.
|
|
22
22
|
*/
|
|
23
|
-
xAxis?: MakeOptional<AxisConfig, 'id'>;
|
|
23
|
+
xAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsXAxisProps>, 'id'>;
|
|
24
|
+
/**
|
|
25
|
+
* The yAxis configuration.
|
|
26
|
+
* Notice it is a single [[AxisConfig]] object, not an array of configuration.
|
|
27
|
+
*/
|
|
28
|
+
yAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsYAxisProps>, 'id'>;
|
|
24
29
|
tooltip?: ChartsTooltipProps;
|
|
25
30
|
axisHighlight?: ChartsAxisHighlightProps;
|
|
26
31
|
/**
|
|
@@ -36,6 +36,7 @@ const SPARKLINE_DEFAULT_MARGIN = {
|
|
|
36
36
|
const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props, ref) {
|
|
37
37
|
const {
|
|
38
38
|
xAxis,
|
|
39
|
+
yAxis,
|
|
39
40
|
width,
|
|
40
41
|
height,
|
|
41
42
|
margin = SPARKLINE_DEFAULT_MARGIN,
|
|
@@ -82,6 +83,9 @@ const SparkLineChart = exports.SparkLineChart = /*#__PURE__*/React.forwardRef(fu
|
|
|
82
83
|
}, (_, index) => index),
|
|
83
84
|
hideTooltip: xAxis === undefined
|
|
84
85
|
}, xAxis)],
|
|
86
|
+
yAxis: [(0, _extends2.default)({
|
|
87
|
+
id: _constants.DEFAULT_X_AXIS_KEY
|
|
88
|
+
}, yAxis)],
|
|
85
89
|
colors: colors,
|
|
86
90
|
sx: sx,
|
|
87
91
|
disableAxisListener: (!showTooltip || tooltip?.trigger !== 'axis') && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
@@ -242,7 +246,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
242
246
|
width: _propTypes.default.number,
|
|
243
247
|
/**
|
|
244
248
|
* The xAxis configuration.
|
|
245
|
-
* Notice it is a single
|
|
249
|
+
* Notice it is a single [[AxisConfig]] object, not an array of configuration.
|
|
246
250
|
*/
|
|
247
251
|
xAxis: _propTypes.default.shape({
|
|
248
252
|
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
@@ -274,7 +278,59 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
274
278
|
labelStyle: _propTypes.default.object,
|
|
275
279
|
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
276
280
|
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
277
|
-
position: _propTypes.default.oneOf(['bottom', '
|
|
281
|
+
position: _propTypes.default.oneOf(['bottom', 'top']),
|
|
282
|
+
reverse: _propTypes.default.bool,
|
|
283
|
+
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
284
|
+
slotProps: _propTypes.default.object,
|
|
285
|
+
slots: _propTypes.default.object,
|
|
286
|
+
stroke: _propTypes.default.string,
|
|
287
|
+
tickFontSize: _propTypes.default.number,
|
|
288
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
289
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
290
|
+
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
291
|
+
tickLabelStyle: _propTypes.default.object,
|
|
292
|
+
tickMaxStep: _propTypes.default.number,
|
|
293
|
+
tickMinStep: _propTypes.default.number,
|
|
294
|
+
tickNumber: _propTypes.default.number,
|
|
295
|
+
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
296
|
+
tickSize: _propTypes.default.number,
|
|
297
|
+
valueFormatter: _propTypes.default.func
|
|
298
|
+
}),
|
|
299
|
+
/**
|
|
300
|
+
* The yAxis configuration.
|
|
301
|
+
* Notice it is a single [[AxisConfig]] object, not an array of configuration.
|
|
302
|
+
*/
|
|
303
|
+
yAxis: _propTypes.default.shape({
|
|
304
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
305
|
+
classes: _propTypes.default.object,
|
|
306
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
307
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
308
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
309
|
+
unknownColor: _propTypes.default.string,
|
|
310
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
311
|
+
}), _propTypes.default.shape({
|
|
312
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
313
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
314
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
315
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
316
|
+
}), _propTypes.default.shape({
|
|
317
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
318
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
319
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
320
|
+
})]),
|
|
321
|
+
data: _propTypes.default.array,
|
|
322
|
+
dataKey: _propTypes.default.string,
|
|
323
|
+
disableLine: _propTypes.default.bool,
|
|
324
|
+
disableTicks: _propTypes.default.bool,
|
|
325
|
+
fill: _propTypes.default.string,
|
|
326
|
+
hideTooltip: _propTypes.default.bool,
|
|
327
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
328
|
+
label: _propTypes.default.string,
|
|
329
|
+
labelFontSize: _propTypes.default.number,
|
|
330
|
+
labelStyle: _propTypes.default.object,
|
|
331
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
332
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
333
|
+
position: _propTypes.default.oneOf(['left', 'right']),
|
|
278
334
|
reverse: _propTypes.default.bool,
|
|
279
335
|
scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
280
336
|
slotProps: _propTypes.default.object,
|
|
@@ -1,42 +1,53 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { AxisConfig, AxisDefaultized } from '../models/axis';
|
|
3
|
-
import { DatasetType } from '../models/seriesType/config';
|
|
2
|
+
import { AxisConfig, AxisDefaultized, ChartsXAxisProps, ChartsYAxisProps, ScaleName } from '../models/axis';
|
|
3
|
+
import { CartesianChartSeriesType, ChartSeriesType, DatasetType, ExtremumGetter } from '../models/seriesType/config';
|
|
4
4
|
import { MakeOptional } from '../models/helpers';
|
|
5
|
+
export type ExtremumGettersConfig<T extends ChartSeriesType = CartesianChartSeriesType> = {
|
|
6
|
+
[K in T]?: ExtremumGetter<K>;
|
|
7
|
+
};
|
|
5
8
|
export type CartesianContextProviderProps = {
|
|
6
9
|
/**
|
|
7
10
|
* The configuration of the x-axes.
|
|
8
11
|
* If not provided, a default axis config is used.
|
|
9
12
|
* An array of [[AxisConfig]] objects.
|
|
10
13
|
*/
|
|
11
|
-
xAxis?: MakeOptional<AxisConfig, 'id'>[];
|
|
14
|
+
xAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsXAxisProps>, 'id'>[];
|
|
12
15
|
/**
|
|
13
16
|
* The configuration of the y-axes.
|
|
14
17
|
* If not provided, a default axis config is used.
|
|
15
18
|
* An array of [[AxisConfig]] objects.
|
|
16
19
|
*/
|
|
17
|
-
yAxis?: MakeOptional<AxisConfig, 'id'>[];
|
|
20
|
+
yAxis?: MakeOptional<AxisConfig<ScaleName, any, ChartsYAxisProps>, 'id'>[];
|
|
18
21
|
/**
|
|
19
22
|
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
20
23
|
*/
|
|
21
24
|
dataset?: DatasetType;
|
|
25
|
+
/**
|
|
26
|
+
* An object with x-axis extremum getters per series type.
|
|
27
|
+
*/
|
|
28
|
+
xExtremumGetters: ExtremumGettersConfig;
|
|
29
|
+
/**
|
|
30
|
+
* An object with y-axis extremum getters per series type.
|
|
31
|
+
*/
|
|
32
|
+
yExtremumGetters: ExtremumGettersConfig;
|
|
22
33
|
children: React.ReactNode;
|
|
23
34
|
};
|
|
24
|
-
type DefaultizedAxisConfig = {
|
|
25
|
-
[axisKey: string]: AxisDefaultized
|
|
35
|
+
type DefaultizedAxisConfig<AxisProps> = {
|
|
36
|
+
[axisKey: string]: AxisDefaultized<ScaleName, any, AxisProps>;
|
|
26
37
|
};
|
|
27
38
|
export declare const CartesianContext: React.Context<{
|
|
28
39
|
/**
|
|
29
40
|
* Mapping from x-axis key to scaling configuration.
|
|
30
41
|
*/
|
|
31
42
|
xAxis: {
|
|
32
|
-
DEFAULT_X_AXIS_KEY: AxisDefaultized
|
|
33
|
-
} & DefaultizedAxisConfig
|
|
43
|
+
DEFAULT_X_AXIS_KEY: AxisDefaultized<ScaleName, any, ChartsXAxisProps>;
|
|
44
|
+
} & DefaultizedAxisConfig<ChartsXAxisProps>;
|
|
34
45
|
/**
|
|
35
46
|
* Mapping from y-axis key to scaling configuration.
|
|
36
47
|
*/
|
|
37
48
|
yAxis: {
|
|
38
|
-
DEFAULT_X_AXIS_KEY: AxisDefaultized
|
|
39
|
-
} & DefaultizedAxisConfig
|
|
49
|
+
DEFAULT_X_AXIS_KEY: AxisDefaultized<ScaleName, any, ChartsYAxisProps>;
|
|
50
|
+
} & DefaultizedAxisConfig<ChartsYAxisProps>;
|
|
40
51
|
/**
|
|
41
52
|
* The x-axes IDs sorted by order they got provided.
|
|
42
53
|
*/
|
|
@@ -9,33 +9,18 @@ exports.CartesianContextProvider = CartesianContextProvider;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _d3Scale = require("d3-scale");
|
|
12
|
-
var _extremums = require("../BarChart/extremums");
|
|
13
|
-
var _extremums2 = require("../ScatterChart/extremums");
|
|
14
|
-
var _extremums3 = require("../LineChart/extremums");
|
|
15
12
|
var _axis = require("../models/axis");
|
|
16
13
|
var _getScale = require("../internals/getScale");
|
|
17
|
-
var _SeriesContextProvider = require("./SeriesContextProvider");
|
|
18
14
|
var _constants = require("../constants");
|
|
19
15
|
var _useTicks = require("../hooks/useTicks");
|
|
20
16
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
21
17
|
var _colorScale = require("../internals/colorScale");
|
|
18
|
+
var _useSeries = require("../hooks/useSeries");
|
|
22
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
20
|
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); }
|
|
24
21
|
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 && {}.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; }
|
|
25
22
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
26
23
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
27
|
-
|
|
28
|
-
// TODO: those might be better placed in a distinct file
|
|
29
|
-
const xExtremumGetters = {
|
|
30
|
-
bar: _extremums.getExtremumX,
|
|
31
|
-
scatter: _extremums2.getExtremumX,
|
|
32
|
-
line: _extremums3.getExtremumX
|
|
33
|
-
};
|
|
34
|
-
const yExtremumGetters = {
|
|
35
|
-
bar: _extremums.getExtremumY,
|
|
36
|
-
scatter: _extremums2.getExtremumY,
|
|
37
|
-
line: _extremums3.getExtremumY
|
|
38
|
-
};
|
|
39
24
|
const CartesianContext = exports.CartesianContext = /*#__PURE__*/React.createContext({
|
|
40
25
|
xAxis: {},
|
|
41
26
|
yAxis: {},
|
|
@@ -50,9 +35,11 @@ function CartesianContextProvider(props) {
|
|
|
50
35
|
xAxis: inXAxis,
|
|
51
36
|
yAxis: inYAxis,
|
|
52
37
|
dataset,
|
|
38
|
+
xExtremumGetters,
|
|
39
|
+
yExtremumGetters,
|
|
53
40
|
children
|
|
54
41
|
} = props;
|
|
55
|
-
const formattedSeries =
|
|
42
|
+
const formattedSeries = (0, _useSeries.useSeries)();
|
|
56
43
|
const drawingArea = (0, _useDrawingArea.useDrawingArea)();
|
|
57
44
|
const xAxis = React.useMemo(() => inXAxis?.map(axisConfig => {
|
|
58
45
|
const dataKey = axisConfig.dataKey;
|
|
@@ -82,11 +69,11 @@ function CartesianContextProvider(props) {
|
|
|
82
69
|
const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis) => {
|
|
83
70
|
const getter = getters[chartType];
|
|
84
71
|
const series = formattedSeries[chartType]?.series ?? {};
|
|
85
|
-
const [minChartTypeData, maxChartTypeData] = getter({
|
|
72
|
+
const [minChartTypeData, maxChartTypeData] = getter?.({
|
|
86
73
|
series,
|
|
87
74
|
axis,
|
|
88
75
|
isDefaultAxis
|
|
89
|
-
});
|
|
76
|
+
}) ?? [null, null];
|
|
90
77
|
const [minData, maxData] = acc;
|
|
91
78
|
if (minData === null || maxData === null) {
|
|
92
79
|
return [minChartTypeData, maxChartTypeData];
|
|
@@ -223,7 +210,7 @@ function CartesianContextProvider(props) {
|
|
|
223
210
|
id
|
|
224
211
|
}) => id)
|
|
225
212
|
};
|
|
226
|
-
}, [drawingArea.height, drawingArea.left, drawingArea.top, drawingArea.width, formattedSeries, xAxis, yAxis]);
|
|
213
|
+
}, [drawingArea.height, drawingArea.left, drawingArea.top, drawingArea.width, formattedSeries, xAxis, xExtremumGetters, yAxis, yExtremumGetters]);
|
|
227
214
|
|
|
228
215
|
// @ts-ignore
|
|
229
216
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CartesianContext.Provider, {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ColorProcessorsConfig } from '../models';
|
|
3
|
+
import { ChartSeriesType } from '../internals';
|
|
4
|
+
export interface ColorProviderProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* A mapping defining for each series type how to get item colors.
|
|
8
|
+
*/
|
|
9
|
+
colorProcessors: ColorProcessorsConfig<ChartSeriesType>;
|
|
10
|
+
}
|
|
11
|
+
export declare const ColorContext: React.Context<ColorProcessorsConfig<keyof import("../internals").ChartsSeriesConfig>>;
|
|
12
|
+
export declare function ColorProvider(props: ColorProviderProps): React.JSX.Element;
|