@mui/x-charts 8.0.0-alpha.3 → 8.0.0-alpha.5
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/CHANGELOG.md +377 -0
- package/ChartsAxis/ChartsAxis.js +0 -4
- package/ChartsLabel/ChartsLabel.d.ts +19 -0
- package/ChartsLabel/ChartsLabel.js +58 -0
- package/ChartsLabel/ChartsLabelGradient.d.ts +40 -0
- package/ChartsLabel/ChartsLabelGradient.js +133 -0
- package/ChartsLabel/ChartsLabelMark.d.ts +27 -0
- package/ChartsLabel/ChartsLabelMark.js +108 -0
- package/ChartsLabel/labelClasses.d.ts +9 -0
- package/ChartsLabel/labelClasses.js +13 -0
- package/ChartsLabel/labelGradientClasses.d.ts +15 -0
- package/ChartsLabel/labelGradientClasses.js +17 -0
- package/ChartsLabel/labelMarkClasses.d.ts +17 -0
- package/ChartsLabel/labelMarkClasses.js +17 -0
- package/ChartsLegend/useAxis.js +3 -3
- package/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
- package/ChartsTooltip/ChartsTooltipTable.js +15 -13
- package/ChartsTooltip/chartsTooltipClasses.d.ts +3 -1
- package/ChartsTooltip/chartsTooltipClasses.js +3 -2
- package/ChartsTooltip/useAxisTooltip.js +2 -3
- package/ChartsTooltip/useItemTooltip.js +2 -3
- package/PieChart/PiePlot.js +2 -2
- package/README.md +1 -1
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/extremums.js +1 -3
- package/ScatterChart/formatter.js +3 -3
- package/hooks/useChartId.d.ts +1 -1
- package/hooks/useColorScale.js +2 -3
- package/hooks/useZAxis.d.ts +6 -0
- package/hooks/useZAxis.js +8 -0
- package/index.js +1 -1
- package/internals/consumeThemeProps.d.ts +54 -0
- package/internals/consumeThemeProps.js +79 -0
- package/internals/defaultizeColor.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +6 -6
- package/internals/plugins/corePlugins/useChartId/useChartId.types.d.ts +3 -3
- package/internals/store/useCharts.js +8 -2
- package/models/seriesType/scatter.d.ts +1 -1
- package/modern/ChartsAxis/ChartsAxis.js +0 -4
- package/modern/ChartsLabel/ChartsLabel.js +58 -0
- package/modern/ChartsLabel/ChartsLabelGradient.js +133 -0
- package/modern/ChartsLabel/ChartsLabelMark.js +108 -0
- package/modern/ChartsLabel/labelClasses.js +13 -0
- package/modern/ChartsLabel/labelGradientClasses.js +17 -0
- package/modern/ChartsLabel/labelMarkClasses.js +17 -0
- package/modern/ChartsLegend/useAxis.js +3 -3
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
- package/modern/ChartsTooltip/ChartsTooltipTable.js +15 -13
- package/modern/ChartsTooltip/chartsTooltipClasses.js +3 -2
- package/modern/ChartsTooltip/useAxisTooltip.js +2 -3
- package/modern/ChartsTooltip/useItemTooltip.js +2 -3
- package/modern/PieChart/PiePlot.js +2 -2
- package/modern/ScatterChart/ScatterPlot.js +2 -2
- package/modern/ScatterChart/extremums.js +1 -3
- package/modern/ScatterChart/formatter.js +3 -3
- package/modern/hooks/useColorScale.js +2 -3
- package/modern/hooks/useZAxis.js +8 -0
- package/modern/index.js +1 -1
- package/modern/internals/consumeThemeProps.js +79 -0
- package/modern/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/modern/internals/store/useCharts.js +8 -2
- package/node/ChartsAxis/ChartsAxis.js +0 -4
- package/node/ChartsLabel/ChartsLabel.js +64 -0
- package/node/ChartsLabel/ChartsLabelGradient.js +139 -0
- package/node/ChartsLabel/ChartsLabelMark.js +114 -0
- package/node/ChartsLabel/labelClasses.js +22 -0
- package/node/ChartsLabel/labelGradientClasses.js +26 -0
- package/node/ChartsLabel/labelMarkClasses.js +26 -0
- package/node/ChartsLegend/useAxis.js +2 -4
- package/node/ChartsTooltip/ChartsAxisTooltipContent.js +5 -3
- package/node/ChartsTooltip/ChartsTooltipTable.js +15 -13
- package/node/ChartsTooltip/chartsTooltipClasses.js +3 -2
- package/node/ChartsTooltip/useAxisTooltip.js +2 -4
- package/node/ChartsTooltip/useItemTooltip.js +2 -4
- package/node/PieChart/PiePlot.js +2 -2
- package/node/ScatterChart/ScatterPlot.js +2 -2
- package/node/ScatterChart/extremums.js +1 -3
- package/node/ScatterChart/formatter.js +3 -3
- package/node/hooks/useColorScale.js +2 -4
- package/node/hooks/useZAxis.js +15 -0
- package/node/index.js +1 -1
- package/node/internals/consumeThemeProps.js +87 -0
- package/node/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/node/internals/store/useCharts.js +9 -2
- package/package.json +5 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { useTheme, useThemeProps } from '@mui/material/styles';
|
|
3
|
+
import resolveProps from '@mui/utils/resolveProps';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import * as ReactIs from 'react-is';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A higher order component that consumes and merges the theme `defaultProps` and handles the `classes` and renders the component.
|
|
9
|
+
*
|
|
10
|
+
* This HOC will wrap a single component.
|
|
11
|
+
* If you need to render multiple components, you can manually consume the theme and render them in your component instead of using this HOC.
|
|
12
|
+
*
|
|
13
|
+
* In the example below, `MyComponent` will render the `DefaultComponent` with the `direction` prop set to `'row'` and the className set to `'my-custom-root'`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* createTheme({
|
|
18
|
+
* components: {
|
|
19
|
+
* MuiMyComponent: {
|
|
20
|
+
* defaultProps: {
|
|
21
|
+
* direction: 'row',
|
|
22
|
+
* },
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* type MyComponentProps = {
|
|
28
|
+
* direction: 'row' | 'column';
|
|
29
|
+
* classes?: Record<'root', string>;
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* const MyComponent = consumeThemeProps(
|
|
33
|
+
* 'MuiMyComponent',
|
|
34
|
+
* function DefaultComponent(props: MyComponentProps) {
|
|
35
|
+
* return (
|
|
36
|
+
* <div className={props.classes.root}>
|
|
37
|
+
* {props.direction}
|
|
38
|
+
* </div>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* render(<MyComponent classes={{ root: 'my-custom-root' }} />);
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param {string} name The mui component name.
|
|
47
|
+
* @param {object} options Options for the HOC.
|
|
48
|
+
* @param {Record<string, any>} options.defaultProps A set of defaults for the component, will be deep merged with the props.
|
|
49
|
+
* @param {Function} options.classesResolver A function that returns the classes for the component. It receives the props, after theme props and defaults have been applied. And the theme object as the second argument.
|
|
50
|
+
* @param InComponent The component to render if the slot is not provided.
|
|
51
|
+
*/
|
|
52
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
53
|
+
export const consumeThemeProps = (name, options, InComponent) => {
|
|
54
|
+
function InternalComponent(props, ref) {
|
|
55
|
+
const themedProps = useThemeProps({
|
|
56
|
+
props,
|
|
57
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
58
|
+
name
|
|
59
|
+
});
|
|
60
|
+
const defaultProps = typeof options.defaultProps === 'function' ? options.defaultProps(themedProps) : options.defaultProps ?? {};
|
|
61
|
+
const outProps = resolveProps(defaultProps, themedProps);
|
|
62
|
+
const theme = useTheme();
|
|
63
|
+
const classes = options.classesResolver?.(outProps, theme);
|
|
64
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
65
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
66
|
+
InComponent.displayName = name;
|
|
67
|
+
}
|
|
68
|
+
const OutComponent = ReactIs.isForwardRef(InComponent) ? InComponent :
|
|
69
|
+
/*#__PURE__*/
|
|
70
|
+
// InComponent needs to be a function that accepts `(props, ref)`
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
React.forwardRef(InComponent);
|
|
73
|
+
return /*#__PURE__*/_jsx(OutComponent, _extends({}, outProps, {
|
|
74
|
+
classes: classes,
|
|
75
|
+
ref: ref
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return /*#__PURE__*/React.forwardRef(InternalComponent);
|
|
79
|
+
};
|
|
@@ -73,7 +73,7 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
73
73
|
};
|
|
74
74
|
id?: import(".").SeriesId;
|
|
75
75
|
color: string;
|
|
76
|
-
valueFormatter?: import(".").SeriesValueFormatter<import("..").ScatterValueType> | undefined;
|
|
76
|
+
valueFormatter?: import(".").SeriesValueFormatter<import("..").ScatterValueType | null> | undefined;
|
|
77
77
|
highlightScope?: Partial<import("..").HighlightScope>;
|
|
78
78
|
xAxisId?: string;
|
|
79
79
|
yAxisId?: string;
|
|
@@ -7,24 +7,24 @@ import { UseChartIdSignature } from './useChartId.types';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const selectorChartId: ((state: import("./useChartId.types").UseChartIdState & Partial<{}> & {
|
|
9
9
|
cacheKey: import("../../models").ChartStateCacheKey;
|
|
10
|
-
}) => string) & {
|
|
10
|
+
}) => string | undefined) & {
|
|
11
11
|
clearCache: () => void;
|
|
12
12
|
resultsCount: () => number;
|
|
13
13
|
resetResultsCount: () => void;
|
|
14
14
|
} & {
|
|
15
15
|
resultFunc: (resultFuncArgs_0: {
|
|
16
|
-
chartId: string;
|
|
16
|
+
chartId: string | undefined;
|
|
17
17
|
providedChartId: string | undefined;
|
|
18
|
-
}) => string;
|
|
18
|
+
}) => string | undefined;
|
|
19
19
|
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
20
|
-
chartId: string;
|
|
20
|
+
chartId: string | undefined;
|
|
21
21
|
providedChartId: string | undefined;
|
|
22
|
-
}) => string) & {
|
|
22
|
+
}) => string | undefined) & {
|
|
23
23
|
clearCache: () => void;
|
|
24
24
|
resultsCount: () => number;
|
|
25
25
|
resetResultsCount: () => void;
|
|
26
26
|
};
|
|
27
|
-
lastResult: () => string;
|
|
27
|
+
lastResult: () => string | undefined;
|
|
28
28
|
dependencies: [ChartRootSelector<UseChartIdSignature>];
|
|
29
29
|
recomputations: () => number;
|
|
30
30
|
resetRecomputations: () => void;
|
|
@@ -4,12 +4,12 @@ export interface UseChartIdParameters {
|
|
|
4
4
|
* This prop is used to help implement the accessibility logic.
|
|
5
5
|
* If you don't provide this prop. It falls back to a randomly generated id.
|
|
6
6
|
*/
|
|
7
|
-
id
|
|
7
|
+
id: string | undefined;
|
|
8
8
|
}
|
|
9
|
-
export type UseChartIdDefaultizedParameters = UseChartIdParameters
|
|
9
|
+
export type UseChartIdDefaultizedParameters = Required<UseChartIdParameters>;
|
|
10
10
|
export interface UseChartIdState {
|
|
11
11
|
id: {
|
|
12
|
-
chartId: string;
|
|
12
|
+
chartId: string | undefined;
|
|
13
13
|
providedChartId: string | undefined;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import useId from '@mui/utils/useId';
|
|
2
3
|
import { ChartStore } from "../plugins/utils/ChartStore.js";
|
|
3
4
|
import { CHART_CORE_PLUGINS } from "../plugins/corePlugins/index.js";
|
|
4
5
|
export function useChartApiInitialization(inputApiRef) {
|
|
@@ -15,7 +16,10 @@ export function useChartApiInitialization(inputApiRef) {
|
|
|
15
16
|
let globalId = 0;
|
|
16
17
|
export function useCharts(inPlugins, props) {
|
|
17
18
|
const plugins = React.useMemo(() => [...CHART_CORE_PLUGINS, ...inPlugins], [inPlugins]);
|
|
18
|
-
const
|
|
19
|
+
const defaultChartId = useId();
|
|
20
|
+
const pluginParams = {
|
|
21
|
+
id: defaultChartId
|
|
22
|
+
}; // To generate when plugins use params.
|
|
19
23
|
const instanceRef = React.useRef({});
|
|
20
24
|
const instance = instanceRef.current;
|
|
21
25
|
const publicAPI = useChartApiInitialization(props.apiRef);
|
|
@@ -39,7 +43,9 @@ export function useCharts(inPlugins, props) {
|
|
|
39
43
|
};
|
|
40
44
|
plugins.forEach(plugin => {
|
|
41
45
|
if (plugin.getInitialState) {
|
|
42
|
-
Object.assign(initialState, plugin.getInitialState({
|
|
46
|
+
Object.assign(initialState, plugin.getInitialState({
|
|
47
|
+
id: defaultChartId
|
|
48
|
+
}));
|
|
43
49
|
}
|
|
44
50
|
});
|
|
45
51
|
storeRef.current = new ChartStore(initialState);
|
|
@@ -9,7 +9,7 @@ export type ScatterValueType = {
|
|
|
9
9
|
*/
|
|
10
10
|
id: string | number;
|
|
11
11
|
};
|
|
12
|
-
export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, CartesianSeriesType {
|
|
12
|
+
export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType | null>, CartesianSeriesType {
|
|
13
13
|
type: 'scatter';
|
|
14
14
|
data?: ScatterValueType[];
|
|
15
15
|
markerSize?: number;
|
|
@@ -50,10 +50,6 @@ function ChartsAxis(props) {
|
|
|
50
50
|
yAxis,
|
|
51
51
|
yAxisIds
|
|
52
52
|
} = useCartesianContext();
|
|
53
|
-
|
|
54
|
-
// TODO: use for plotting line without ticks or any thing
|
|
55
|
-
// const drawingArea = React.useContext(DrawingContext);
|
|
56
|
-
|
|
57
53
|
const leftId = getAxisId(leftAxis === undefined ? yAxisIds[0] : leftAxis, yAxisIds[0]);
|
|
58
54
|
const bottomId = getAxisId(bottomAxis === undefined ? xAxisIds[0] : bottomAxis, xAxisIds[0]);
|
|
59
55
|
const topId = getAxisId(topAxis, xAxisIds[0]);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
const _excluded = ["children", "className", "classes"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { useUtilityClasses } from "./labelClasses.js";
|
|
11
|
+
import { consumeThemeProps } from "../internals/consumeThemeProps.js";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const Root = styled('span', {
|
|
14
|
+
name: 'MuiChartsLabel',
|
|
15
|
+
slot: 'Root',
|
|
16
|
+
overridesResolver: (props, styles) => styles.root
|
|
17
|
+
})(({
|
|
18
|
+
theme
|
|
19
|
+
}) => _extends({}, theme.typography.caption, {
|
|
20
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
21
|
+
lineHeight: undefined,
|
|
22
|
+
display: 'flex'
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @ignore - internal component.
|
|
27
|
+
*
|
|
28
|
+
* Generates the label mark for the tooltip and legend.
|
|
29
|
+
*/
|
|
30
|
+
const ChartsLabel = consumeThemeProps('MuiChartsLabel', {
|
|
31
|
+
classesResolver: useUtilityClasses
|
|
32
|
+
}, function ChartsLabel(props, ref) {
|
|
33
|
+
const {
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
classes
|
|
37
|
+
} = props,
|
|
38
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
39
|
+
return /*#__PURE__*/_jsx(Root, _extends({
|
|
40
|
+
className: clsx(classes?.root, className),
|
|
41
|
+
ownerState: props,
|
|
42
|
+
ref: ref
|
|
43
|
+
}, other, {
|
|
44
|
+
children: children
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
process.env.NODE_ENV !== "production" ? ChartsLabel.propTypes = {
|
|
48
|
+
// ----------------------------- Warning --------------------------------
|
|
49
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
50
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
51
|
+
// ----------------------------------------------------------------------
|
|
52
|
+
children: PropTypes.node,
|
|
53
|
+
/**
|
|
54
|
+
* Override or extend the styles applied to the component.
|
|
55
|
+
*/
|
|
56
|
+
classes: PropTypes.object
|
|
57
|
+
} : void 0;
|
|
58
|
+
export { ChartsLabel };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["gradientId", "direction", "classes", "className"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { useUtilityClasses, labelGradientClasses } from "./labelGradientClasses.js";
|
|
11
|
+
import { consumeThemeProps } from "../internals/consumeThemeProps.js";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const getRotation = (direction, reverse, rotate) => {
|
|
14
|
+
if (!rotate && reverse) {
|
|
15
|
+
return direction === 'column' ? 90 : 180;
|
|
16
|
+
}
|
|
17
|
+
if (rotate && !reverse) {
|
|
18
|
+
return direction === 'column' ? 0 : 90;
|
|
19
|
+
}
|
|
20
|
+
if (rotate && reverse) {
|
|
21
|
+
return direction === 'column' ? 180 : -90;
|
|
22
|
+
}
|
|
23
|
+
return direction === 'column' ? -90 : 0;
|
|
24
|
+
};
|
|
25
|
+
const Root = styled('div', {
|
|
26
|
+
name: 'MuiChartsLabelGradient',
|
|
27
|
+
slot: 'Root',
|
|
28
|
+
overridesResolver: (props, styles) => styles.root
|
|
29
|
+
})(({
|
|
30
|
+
ownerState
|
|
31
|
+
}) => {
|
|
32
|
+
const rotation = getRotation(ownerState.direction, ownerState.reverse, ownerState.rotate);
|
|
33
|
+
return {
|
|
34
|
+
display: 'flex',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
justifyContent: 'center',
|
|
37
|
+
[`.${labelGradientClasses.mask}`]: {
|
|
38
|
+
borderRadius: 2,
|
|
39
|
+
overflow: 'hidden'
|
|
40
|
+
},
|
|
41
|
+
[`&.${labelGradientClasses.row}`]: {
|
|
42
|
+
width: '100%',
|
|
43
|
+
[`.${labelGradientClasses.mask}`]: {
|
|
44
|
+
height: 12,
|
|
45
|
+
width: '100%'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
[`&.${labelGradientClasses.column}`]: {
|
|
49
|
+
height: '100%',
|
|
50
|
+
[`.${labelGradientClasses.mask}`]: {
|
|
51
|
+
width: 12,
|
|
52
|
+
height: '100%',
|
|
53
|
+
'> svg': {
|
|
54
|
+
height: '100%'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
svg: {
|
|
59
|
+
transform: `rotate(${rotation}deg)`,
|
|
60
|
+
display: 'block'
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @ignore - internal component.
|
|
67
|
+
*
|
|
68
|
+
* Generates the label Gradient for the tooltip and legend.
|
|
69
|
+
*/
|
|
70
|
+
const ChartsLabelGradient = consumeThemeProps('MuiChartsLabelGradient', {
|
|
71
|
+
defaultProps: {
|
|
72
|
+
direction: 'row'
|
|
73
|
+
},
|
|
74
|
+
classesResolver: useUtilityClasses
|
|
75
|
+
}, function ChartsLabelGradient(props, ref) {
|
|
76
|
+
const {
|
|
77
|
+
gradientId,
|
|
78
|
+
classes,
|
|
79
|
+
className
|
|
80
|
+
} = props,
|
|
81
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
82
|
+
return /*#__PURE__*/_jsx(Root, _extends({
|
|
83
|
+
className: clsx(classes?.root, className),
|
|
84
|
+
ownerState: props,
|
|
85
|
+
"aria-hidden": "true",
|
|
86
|
+
ref: ref
|
|
87
|
+
}, other, {
|
|
88
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
89
|
+
className: classes?.mask,
|
|
90
|
+
children: /*#__PURE__*/_jsx("svg", {
|
|
91
|
+
viewBox: "0 0 24 24",
|
|
92
|
+
children: /*#__PURE__*/_jsx("rect", {
|
|
93
|
+
width: "24",
|
|
94
|
+
height: "24",
|
|
95
|
+
fill: `url(#${gradientId})`
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
process.env.NODE_ENV !== "production" ? ChartsLabelGradient.propTypes = {
|
|
102
|
+
// ----------------------------- Warning --------------------------------
|
|
103
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
104
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
105
|
+
// ----------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* Override or extend the styles applied to the component.
|
|
108
|
+
*/
|
|
109
|
+
classes: PropTypes.object,
|
|
110
|
+
/**
|
|
111
|
+
* The direction of the gradient.
|
|
112
|
+
*
|
|
113
|
+
* @default 'row'
|
|
114
|
+
*/
|
|
115
|
+
direction: PropTypes.oneOf(['column', 'row']),
|
|
116
|
+
/**
|
|
117
|
+
* A unique identifier for the gradient.
|
|
118
|
+
*
|
|
119
|
+
* The `gradientId` will be used as `fill="url(#gradientId)"`.
|
|
120
|
+
*/
|
|
121
|
+
gradientId: PropTypes.string.isRequired,
|
|
122
|
+
/**
|
|
123
|
+
* If `true`, the gradient will be reversed.
|
|
124
|
+
*/
|
|
125
|
+
reverse: PropTypes.bool,
|
|
126
|
+
/**
|
|
127
|
+
* If provided, the gradient will be rotated by 90deg.
|
|
128
|
+
*
|
|
129
|
+
* Useful for linear gradients that are not in the correct orientation.
|
|
130
|
+
*/
|
|
131
|
+
rotate: PropTypes.bool
|
|
132
|
+
} : void 0;
|
|
133
|
+
export { ChartsLabelGradient };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["type", "color", "className", "classes"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { labelMarkClasses, useUtilityClasses } from "./labelMarkClasses.js";
|
|
11
|
+
import { consumeThemeProps } from "../internals/consumeThemeProps.js";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const Root = styled('div', {
|
|
14
|
+
name: 'MuiChartsLabelMark',
|
|
15
|
+
slot: 'Root',
|
|
16
|
+
overridesResolver: (props, styles) => styles.root
|
|
17
|
+
})(() => {
|
|
18
|
+
return {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
flexShrink: 0,
|
|
23
|
+
[`&.${labelMarkClasses.line}`]: {
|
|
24
|
+
width: 16,
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
[`.${labelMarkClasses.mask}`]: {
|
|
28
|
+
height: 4,
|
|
29
|
+
width: '100%',
|
|
30
|
+
borderRadius: 1,
|
|
31
|
+
overflow: 'hidden'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[`&.${labelMarkClasses.square}`]: {
|
|
35
|
+
height: 13,
|
|
36
|
+
width: 13,
|
|
37
|
+
borderRadius: 2,
|
|
38
|
+
overflow: 'hidden'
|
|
39
|
+
},
|
|
40
|
+
[`&.${labelMarkClasses.circle}`]: {
|
|
41
|
+
height: 15,
|
|
42
|
+
width: 15,
|
|
43
|
+
borderRadius: '50%',
|
|
44
|
+
overflow: 'hidden'
|
|
45
|
+
},
|
|
46
|
+
svg: {
|
|
47
|
+
display: 'block',
|
|
48
|
+
height: '100%',
|
|
49
|
+
width: '100%'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @ignore - internal component.
|
|
56
|
+
*
|
|
57
|
+
* Generates the label mark for the tooltip and legend.
|
|
58
|
+
*/
|
|
59
|
+
const ChartsLabelMark = consumeThemeProps('MuiChartsLabelMark', {
|
|
60
|
+
classesResolver: useUtilityClasses
|
|
61
|
+
}, function ChartsLabelMark(props, ref) {
|
|
62
|
+
const {
|
|
63
|
+
type,
|
|
64
|
+
color,
|
|
65
|
+
className,
|
|
66
|
+
classes
|
|
67
|
+
} = props,
|
|
68
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
69
|
+
return /*#__PURE__*/_jsx(Root, _extends({
|
|
70
|
+
className: clsx(classes?.root, className),
|
|
71
|
+
ownerState: props,
|
|
72
|
+
"aria-hidden": "true",
|
|
73
|
+
ref: ref
|
|
74
|
+
}, other, {
|
|
75
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
76
|
+
className: classes?.mask,
|
|
77
|
+
children: /*#__PURE__*/_jsx("svg", {
|
|
78
|
+
viewBox: "0 0 24 24",
|
|
79
|
+
preserveAspectRatio: type === 'line' ? 'none' : undefined,
|
|
80
|
+
children: /*#__PURE__*/_jsx("rect", {
|
|
81
|
+
width: "24",
|
|
82
|
+
height: "24",
|
|
83
|
+
fill: color
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
}));
|
|
88
|
+
});
|
|
89
|
+
process.env.NODE_ENV !== "production" ? ChartsLabelMark.propTypes = {
|
|
90
|
+
// ----------------------------- Warning --------------------------------
|
|
91
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
92
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
93
|
+
// ----------------------------------------------------------------------
|
|
94
|
+
/**
|
|
95
|
+
* Override or extend the styles applied to the component.
|
|
96
|
+
*/
|
|
97
|
+
classes: PropTypes.object,
|
|
98
|
+
/**
|
|
99
|
+
* The color of the mark.
|
|
100
|
+
*/
|
|
101
|
+
color: PropTypes.string,
|
|
102
|
+
/**
|
|
103
|
+
* The type of the mark.
|
|
104
|
+
* @default 'square'
|
|
105
|
+
*/
|
|
106
|
+
type: PropTypes.oneOf(['circle', 'line', 'square'])
|
|
107
|
+
} : void 0;
|
|
108
|
+
export { ChartsLabelMark };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
4
|
+
export function getLabelUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiChartsLabel', slot);
|
|
6
|
+
}
|
|
7
|
+
export const labelClasses = generateUtilityClasses('MuiChartsLabel', ['root']);
|
|
8
|
+
export const useUtilityClasses = props => {
|
|
9
|
+
const slots = {
|
|
10
|
+
root: ['root']
|
|
11
|
+
};
|
|
12
|
+
return composeClasses(slots, getLabelUtilityClass, props.classes);
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
4
|
+
export function getLabelGradientUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiChartsLabelGradient', slot);
|
|
6
|
+
}
|
|
7
|
+
export const labelGradientClasses = generateUtilityClasses('MuiChartsLabelGradient', ['root', 'column', 'row', 'mask']);
|
|
8
|
+
export const useUtilityClasses = props => {
|
|
9
|
+
const {
|
|
10
|
+
direction
|
|
11
|
+
} = props;
|
|
12
|
+
const slots = {
|
|
13
|
+
root: ['root', direction],
|
|
14
|
+
mask: ['mask']
|
|
15
|
+
};
|
|
16
|
+
return composeClasses(slots, getLabelGradientUtilityClass, props.classes);
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
4
|
+
export function getLabelMarkUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiChartsLabelMark', slot);
|
|
6
|
+
}
|
|
7
|
+
export const labelMarkClasses = generateUtilityClasses('MuiChartsLabelMark', ['root', 'line', 'square', 'circle', 'mask']);
|
|
8
|
+
export const useUtilityClasses = props => {
|
|
9
|
+
const {
|
|
10
|
+
type
|
|
11
|
+
} = props;
|
|
12
|
+
const slots = {
|
|
13
|
+
root: ['root', type],
|
|
14
|
+
mask: ['mask']
|
|
15
|
+
};
|
|
16
|
+
return composeClasses(slots, getLabelMarkUtilityClass, props.classes);
|
|
17
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
5
3
|
import { useCartesianContext } from "../context/CartesianProvider/useCartesianContext.js";
|
|
4
|
+
import { useZAxis } from "../hooks/useZAxis.js";
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* Helper to select an axis definition according to its direction and id.
|
|
8
8
|
*/
|
|
@@ -19,7 +19,7 @@ export function useAxis({
|
|
|
19
19
|
const {
|
|
20
20
|
zAxis,
|
|
21
21
|
zAxisIds
|
|
22
|
-
} =
|
|
22
|
+
} = useZAxis();
|
|
23
23
|
switch (axisDirection) {
|
|
24
24
|
case 'x':
|
|
25
25
|
{
|
|
@@ -14,11 +14,11 @@ function ChartsAxisTooltipContent(props) {
|
|
|
14
14
|
classes: propClasses,
|
|
15
15
|
sx
|
|
16
16
|
} = props;
|
|
17
|
-
const
|
|
17
|
+
const tooltipData = useAxisTooltip();
|
|
18
18
|
const xAxis = useXAxis();
|
|
19
19
|
const yAxis = useYAxis();
|
|
20
20
|
const classes = useUtilityClasses(propClasses);
|
|
21
|
-
if (
|
|
21
|
+
if (tooltipData === null) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
const {
|
|
@@ -26,7 +26,7 @@ function ChartsAxisTooltipContent(props) {
|
|
|
26
26
|
axisValue,
|
|
27
27
|
axisFormattedValue,
|
|
28
28
|
seriesItems
|
|
29
|
-
} =
|
|
29
|
+
} = tooltipData;
|
|
30
30
|
const axis = axisDirection === 'x' ? xAxis : yAxis;
|
|
31
31
|
return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
|
|
32
32
|
sx: sx,
|
|
@@ -35,8 +35,10 @@ function ChartsAxisTooltipContent(props) {
|
|
|
35
35
|
className: classes.table,
|
|
36
36
|
children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
|
|
37
37
|
children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
|
|
38
|
+
className: classes.row,
|
|
38
39
|
children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
|
|
39
40
|
colSpan: 3,
|
|
41
|
+
className: clsx(classes.cell, classes.axisValueCell),
|
|
40
42
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
41
43
|
children: axisFormattedValue
|
|
42
44
|
})
|
|
@@ -12,11 +12,10 @@ export const ChartsTooltipPaper = styled('div', {
|
|
|
12
12
|
})(({
|
|
13
13
|
theme
|
|
14
14
|
}) => ({
|
|
15
|
-
boxShadow: theme.shadows[1],
|
|
16
15
|
backgroundColor: (theme.vars || theme).palette.background.paper,
|
|
17
16
|
color: (theme.vars || theme).palette.text.primary,
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
borderRadius: theme.shape.borderRadius,
|
|
18
|
+
border: `solid ${(theme.vars || theme).palette.divider} 1px`
|
|
20
19
|
}));
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -46,10 +45,10 @@ export const ChartsTooltipRow = styled('tr', {
|
|
|
46
45
|
theme
|
|
47
46
|
}) => ({
|
|
48
47
|
'tr:first-of-type& td': {
|
|
49
|
-
paddingTop: theme.spacing(
|
|
48
|
+
paddingTop: theme.spacing(0.5)
|
|
50
49
|
},
|
|
51
50
|
'tr:last-of-type& td': {
|
|
52
|
-
paddingBottom: theme.spacing(
|
|
51
|
+
paddingBottom: theme.spacing(0.5)
|
|
53
52
|
}
|
|
54
53
|
}));
|
|
55
54
|
|
|
@@ -66,17 +65,23 @@ export const ChartsTooltipCell = styled('td', {
|
|
|
66
65
|
verticalAlign: 'middle',
|
|
67
66
|
color: (theme.vars || theme).palette.text.secondary,
|
|
68
67
|
[`&.${chartsTooltipClasses.labelCell}`]: {
|
|
69
|
-
paddingLeft: theme.spacing(1)
|
|
68
|
+
paddingLeft: theme.spacing(1),
|
|
69
|
+
paddingRight: theme.spacing(1.5),
|
|
70
|
+
fontWeight: theme.typography.fontWeightRegular
|
|
71
|
+
},
|
|
72
|
+
[`&.${chartsTooltipClasses.valueCell}, &.${chartsTooltipClasses.axisValueCell}`]: {
|
|
73
|
+
color: (theme.vars || theme).palette.text.primary,
|
|
74
|
+
fontWeight: theme.typography.fontWeightMedium
|
|
70
75
|
},
|
|
71
76
|
[`&.${chartsTooltipClasses.valueCell}`]: {
|
|
72
|
-
paddingLeft: theme.spacing(
|
|
73
|
-
|
|
77
|
+
paddingLeft: theme.spacing(1.5),
|
|
78
|
+
paddingRight: theme.spacing(1.5)
|
|
74
79
|
},
|
|
75
80
|
'td:first-of-type&': {
|
|
76
|
-
paddingLeft: theme.spacing(
|
|
81
|
+
paddingLeft: theme.spacing(1.5)
|
|
77
82
|
},
|
|
78
83
|
'td:last-of-type&': {
|
|
79
|
-
paddingRight: theme.spacing(
|
|
84
|
+
paddingRight: theme.spacing(1.5)
|
|
80
85
|
}
|
|
81
86
|
}));
|
|
82
87
|
|
|
@@ -95,9 +100,6 @@ export const ChartsTooltipMark = styled('div', {
|
|
|
95
100
|
width: theme.spacing(1),
|
|
96
101
|
height: theme.spacing(1),
|
|
97
102
|
borderRadius: '50%',
|
|
98
|
-
boxShadow: theme.shadows[1],
|
|
99
103
|
background: color,
|
|
100
|
-
borderColor: (theme.vars || theme).palette.background.paper,
|
|
101
|
-
border: `solid ${(theme.vars || theme).palette.background.paper} ${theme.spacing(0.25)}`,
|
|
102
104
|
boxSizing: 'content-box'
|
|
103
105
|
}));
|