@mui/x-charts 8.5.0 → 8.5.2
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 +2 -3
- package/BarChart/BarLabel/BarLabel.d.ts +1 -1
- package/BarChart/seriesConfig/seriesProcessor.js +1 -1
- package/CHANGELOG.md +204 -0
- package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
- package/ChartsGrid/ChartsHorizontalGrid.js +1 -1
- package/ChartsGrid/ChartsVerticalGrid.js +1 -1
- package/ChartsGrid/styledComponents.d.ts +2 -2
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsTooltip/ChartsTooltip.js +1 -1
- package/ChartsTooltip/ChartsTooltipContainer.js +21 -16
- package/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
- package/ChartsTooltip/utils.d.ts +6 -0
- package/ChartsTooltip/utils.js +19 -1
- package/LineChart/LineChart.js +2 -3
- package/PieChart/PieChart.js +4 -11
- package/RadarChart/RadarChart.js +2 -3
- package/RadarChart/index.d.ts +1 -1
- package/ScatterChart/ScatterChart.js +2 -3
- package/Toolbar/Toolbar.d.ts +9 -8
- package/Toolbar/Toolbar.js +24 -8
- package/Toolbar/Toolbar.types.d.ts +1 -1
- package/Toolbar/ToolbarButton.js +18 -4
- package/esm/BarChart/BarChart.js +2 -3
- package/esm/BarChart/BarLabel/BarLabel.d.ts +1 -1
- package/esm/BarChart/seriesConfig/seriesProcessor.js +1 -1
- package/esm/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
- package/esm/ChartsGrid/ChartsHorizontalGrid.js +1 -1
- package/esm/ChartsGrid/ChartsVerticalGrid.js +1 -1
- package/esm/ChartsGrid/styledComponents.d.ts +2 -2
- package/esm/ChartsReferenceLine/common.d.ts +1 -1
- package/esm/ChartsTooltip/ChartsTooltip.js +1 -1
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +22 -17
- package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
- package/esm/ChartsTooltip/utils.d.ts +6 -0
- package/esm/ChartsTooltip/utils.js +16 -1
- package/esm/LineChart/LineChart.js +2 -3
- package/esm/PieChart/PieChart.js +4 -11
- package/esm/RadarChart/RadarChart.js +2 -3
- package/esm/RadarChart/index.d.ts +1 -1
- package/esm/ScatterChart/ScatterChart.js +2 -3
- package/esm/Toolbar/Toolbar.d.ts +9 -8
- package/esm/Toolbar/Toolbar.js +23 -7
- package/esm/Toolbar/Toolbar.types.d.ts +1 -1
- package/esm/Toolbar/ToolbarButton.js +19 -4
- package/esm/index.js +1 -1
- package/esm/internals/components/AxisSharedComponents.d.ts +1 -1
- package/esm/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
- package/esm/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
- package/esm/internals/constants.d.ts +8 -1
- package/esm/internals/constants.js +9 -1
- package/esm/internals/defaultValueFormatters.d.ts +6 -0
- package/esm/internals/defaultValueFormatters.js +15 -0
- package/esm/internals/index.d.ts +7 -0
- package/esm/internals/index.js +7 -0
- package/esm/internals/invertScale.d.ts +2 -0
- package/esm/internals/invertScale.js +8 -0
- package/esm/internals/material/index.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +2917 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +1 -0
- package/esm/internals/plugins/models/seriesConfig/colorProcessor.types.d.ts +5 -0
- package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +3 -2
- package/esm/internals/store/useSelector.js +3 -1
- package/esm/locales/index.d.ts +3 -1
- package/esm/locales/index.js +2 -0
- package/esm/locales/ptBR.d.ts +16 -0
- package/esm/locales/ptBR.js +9 -0
- package/esm/locales/ptPT.d.ts +16 -0
- package/esm/locales/ptPT.js +9 -0
- package/esm/models/axis.d.ts +3 -1
- package/esm/models/index.d.ts +1 -1
- package/esm/models/seriesType/bar.d.ts +2 -2
- package/esm/models/slots/chartsBaseSlotProps.d.ts +6 -0
- package/esm/models/slots/chartsBaseSlots.d.ts +2 -1
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +1 -1
- package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
- package/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
- package/internals/constants.d.ts +8 -1
- package/internals/constants.js +10 -2
- package/internals/defaultValueFormatters.d.ts +6 -0
- package/internals/defaultValueFormatters.js +21 -0
- package/internals/index.d.ts +7 -0
- package/internals/index.js +76 -0
- package/internals/invertScale.d.ts +2 -0
- package/internals/invertScale.js +14 -0
- package/internals/material/index.js +2 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +2917 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +2 -1
- package/internals/plugins/models/seriesConfig/colorProcessor.types.d.ts +5 -0
- package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +3 -2
- package/internals/store/useSelector.js +4 -1
- package/locales/index.d.ts +3 -1
- package/locales/index.js +22 -0
- package/locales/ptBR.d.ts +16 -0
- package/locales/ptBR.js +15 -0
- package/locales/ptPT.d.ts +16 -0
- package/locales/ptPT.js +15 -0
- package/models/axis.d.ts +3 -1
- package/models/index.d.ts +1 -1
- package/models/seriesType/bar.d.ts +2 -2
- package/models/slots/chartsBaseSlotProps.d.ts +6 -0
- package/models/slots/chartsBaseSlots.d.ts +2 -1
- package/package.json +5 -5
- package/Toolbar/internals/ChartsToolbar.d.ts +0 -6
- package/Toolbar/internals/ChartsToolbar.js +0 -14
- package/esm/Toolbar/internals/ChartsToolbar.d.ts +0 -6
- package/esm/Toolbar/internals/ChartsToolbar.js +0 -8
|
@@ -2,7 +2,7 @@ export { RadarChart as Unstable_RadarChart } from "./RadarChart.js";
|
|
|
2
2
|
export { RadarChart } from "./RadarChart.js";
|
|
3
3
|
export { RadarDataProvider as Unstable_RadarDataProvider } from "./RadarDataProvider/index.js";
|
|
4
4
|
export { RadarDataProvider } from "./RadarDataProvider/index.js";
|
|
5
|
-
export type { RadarChartProps } from "./RadarChart.js";
|
|
5
|
+
export type { RadarChartProps, RadarChartSlots, RadarChartSlotProps } from "./RadarChart.js";
|
|
6
6
|
export type { RadarDataProviderProps } from "./RadarDataProvider/index.js";
|
|
7
7
|
export * from "./RadarGrid/index.js";
|
|
8
8
|
export * from "./RadarAxisHighlight/index.js";
|
|
@@ -16,7 +16,6 @@ import { useChartContainerProps } from "../ChartContainer/useChartContainerProps
|
|
|
16
16
|
import { ChartDataProvider } from "../ChartDataProvider/index.js";
|
|
17
17
|
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
18
18
|
import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
|
|
19
|
-
import { ChartsToolbar } from "../Toolbar/internals/ChartsToolbar.js";
|
|
20
19
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
20
|
/**
|
|
22
21
|
* Demos:
|
|
@@ -49,10 +48,10 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(inProps
|
|
|
49
48
|
chartsSurfaceProps
|
|
50
49
|
} = useChartContainerProps(chartContainerProps, ref);
|
|
51
50
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
52
|
-
const Toolbar = props.slots?.toolbar
|
|
51
|
+
const Toolbar = props.slots?.toolbar;
|
|
53
52
|
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
54
53
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
55
|
-
children: [props.showToolbar ? /*#__PURE__*/_jsx(Toolbar, {}) : null, !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
54
|
+
children: [props.showToolbar && Toolbar ? /*#__PURE__*/_jsx(Toolbar, _extends({}, props.slotProps?.toolbar)) : null, !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
56
55
|
children: [/*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
|
|
57
56
|
"data-drawing-container": true,
|
|
58
57
|
children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
|
package/esm/Toolbar/Toolbar.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
import { RenderProp } from '@mui/x-internals/useComponentRenderer';
|
|
3
|
+
declare const ToolbarRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
4
|
+
export interface ToolbarProps extends React.ComponentProps<'div'> {
|
|
3
5
|
className?: string;
|
|
6
|
+
/**
|
|
7
|
+
* A function to customize rendering of the component.
|
|
8
|
+
*/
|
|
9
|
+
render?: RenderProp<React.ComponentProps<typeof ToolbarRoot>>;
|
|
4
10
|
}
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
...other
|
|
8
|
-
}: ChartsToolbarProps): React.JSX.Element;
|
|
9
|
-
export declare namespace Toolbar {
|
|
10
|
-
var propTypes: any;
|
|
11
|
-
}
|
|
11
|
+
export declare const Toolbar: React.ForwardRefExoticComponent<Omit<ToolbarProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export {};
|
package/esm/Toolbar/Toolbar.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className"];
|
|
3
|
+
const _excluded = ["className", "render"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
|
+
import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
|
|
9
|
+
import { ToolbarContextProvider } from '@mui/x-internals/ToolbarContext';
|
|
8
10
|
import { chartsToolbarClasses } from "./chartToolbarClasses.js";
|
|
9
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
12
|
const ToolbarRoot = styled('div', {
|
|
@@ -19,24 +21,38 @@ const ToolbarRoot = styled('div', {
|
|
|
19
21
|
justifyContent: 'end',
|
|
20
22
|
gap: theme.spacing(0.25),
|
|
21
23
|
padding: theme.spacing(0.5),
|
|
24
|
+
marginBottom: theme.spacing(1.5),
|
|
22
25
|
minHeight: 44,
|
|
23
26
|
boxSizing: 'border-box',
|
|
24
27
|
border: `1px solid ${(theme.vars || theme).palette.divider}`,
|
|
25
28
|
borderRadius: 4
|
|
26
29
|
}));
|
|
27
|
-
export function Toolbar(_ref) {
|
|
30
|
+
export const Toolbar = /*#__PURE__*/React.forwardRef(function Toolbar(_ref, ref) {
|
|
28
31
|
let {
|
|
29
|
-
className
|
|
32
|
+
className,
|
|
33
|
+
render
|
|
30
34
|
} = _ref,
|
|
31
35
|
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
32
|
-
|
|
36
|
+
const element = useComponentRenderer(ToolbarRoot, render, _extends({
|
|
37
|
+
role: 'toolbar',
|
|
38
|
+
'aria-orientation': 'horizontal',
|
|
33
39
|
className: clsx(chartsToolbarClasses.root, className)
|
|
34
|
-
}, other
|
|
35
|
-
|
|
40
|
+
}, other, {
|
|
41
|
+
ref
|
|
42
|
+
}));
|
|
43
|
+
return /*#__PURE__*/_jsx(ToolbarContextProvider, {
|
|
44
|
+
children: element
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
if (process.env.NODE_ENV !== "production") Toolbar.displayName = "Toolbar";
|
|
36
48
|
process.env.NODE_ENV !== "production" ? Toolbar.propTypes = {
|
|
37
49
|
// ----------------------------- Warning --------------------------------
|
|
38
50
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
39
51
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
40
52
|
// ----------------------------------------------------------------------
|
|
41
|
-
className: PropTypes.string
|
|
53
|
+
className: PropTypes.string,
|
|
54
|
+
/**
|
|
55
|
+
* A function to customize rendering of the component.
|
|
56
|
+
*/
|
|
57
|
+
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
|
|
42
58
|
} : void 0;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["render"]
|
|
5
|
+
const _excluded = ["render", "onKeyDown", "onFocus", "disabled", "aria-disabled"],
|
|
6
|
+
_excluded2 = ["tabIndex"];
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
5
8
|
import * as React from 'react';
|
|
6
9
|
import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
|
|
10
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
11
|
+
import { useRegisterToolbarButton } from '@mui/x-internals/ToolbarContext';
|
|
7
12
|
import { useChartsSlots } from "../context/ChartsSlotsContext.js";
|
|
8
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
14
|
const ToolbarButton = /*#__PURE__*/React.forwardRef(function ToolbarButton(props, ref) {
|
|
@@ -15,8 +20,17 @@ const ToolbarButton = /*#__PURE__*/React.forwardRef(function ToolbarButton(props
|
|
|
15
20
|
slots,
|
|
16
21
|
slotProps
|
|
17
22
|
} = useChartsSlots();
|
|
18
|
-
const
|
|
19
|
-
|
|
23
|
+
const buttonRef = React.useRef(null);
|
|
24
|
+
const handleRef = useForkRef(buttonRef, ref);
|
|
25
|
+
const _useRegisterToolbarBu = useRegisterToolbarButton(props, buttonRef),
|
|
26
|
+
{
|
|
27
|
+
tabIndex
|
|
28
|
+
} = _useRegisterToolbarBu,
|
|
29
|
+
toolbarButtonProps = _objectWithoutPropertiesLoose(_useRegisterToolbarBu, _excluded2);
|
|
30
|
+
const element = useComponentRenderer(slots.baseIconButton, render, _extends({}, slotProps?.baseIconButton, {
|
|
31
|
+
tabIndex
|
|
32
|
+
}, other, toolbarButtonProps, {
|
|
33
|
+
ref: handleRef
|
|
20
34
|
}));
|
|
21
35
|
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
22
36
|
children: element
|
|
@@ -34,6 +48,7 @@ process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
|
|
|
34
48
|
* A function to customize the rendering of the component.
|
|
35
49
|
*/
|
|
36
50
|
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
37
|
-
style: PropTypes.object
|
|
51
|
+
style: PropTypes.object,
|
|
52
|
+
tabIndex: PropTypes.number
|
|
38
53
|
} : void 0;
|
|
39
54
|
export { ToolbarButton };
|
package/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
|
|
1
|
+
export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
|
|
@@ -5,6 +5,11 @@ import { Position } from "../../../models/index.js";
|
|
|
5
5
|
export interface ChartsWrapperProps {
|
|
6
6
|
legendPosition?: Position;
|
|
7
7
|
legendDirection?: Direction;
|
|
8
|
+
/**
|
|
9
|
+
* If `true`, the chart wrapper set `height: 100%`.
|
|
10
|
+
* @default `false` if the `height` prop is set. And `true` otherwise.
|
|
11
|
+
*/
|
|
12
|
+
extendVertically?: boolean;
|
|
8
13
|
children: React.ReactNode;
|
|
9
14
|
sx?: SxProps<Theme>;
|
|
10
15
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
|
+
import { shouldForwardProp } from '@mui/system/createStyled';
|
|
3
4
|
import { useChartRootRef } from "../../../hooks/useChartRootRef.js";
|
|
5
|
+
import { useStore } from "../../store/useStore.js";
|
|
6
|
+
import { useSelector } from "../../store/useSelector.js";
|
|
7
|
+
import { selectorChartPropsSize } from "../../plugins/corePlugins/useChartDimensions/index.js";
|
|
4
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
9
|
const getDirection = (direction, position) => {
|
|
6
10
|
if (direction === 'vertical') {
|
|
@@ -35,7 +39,8 @@ const getAlign = (direction, position) => {
|
|
|
35
39
|
};
|
|
36
40
|
const Root = styled('div', {
|
|
37
41
|
name: 'MuiChartsWrapper',
|
|
38
|
-
slot: 'Root'
|
|
42
|
+
slot: 'Root',
|
|
43
|
+
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'extendVertically'
|
|
39
44
|
})(({
|
|
40
45
|
ownerState
|
|
41
46
|
}) => ({
|
|
@@ -43,7 +48,15 @@ const Root = styled('div', {
|
|
|
43
48
|
flexDirection: getDirection(ownerState.legendDirection, ownerState.legendPosition),
|
|
44
49
|
flex: 1,
|
|
45
50
|
justifyContent: 'center',
|
|
46
|
-
alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition)
|
|
51
|
+
alignItems: getAlign(ownerState.legendDirection, ownerState.legendPosition),
|
|
52
|
+
variants: [{
|
|
53
|
+
props: {
|
|
54
|
+
extendVertically: true
|
|
55
|
+
},
|
|
56
|
+
style: {
|
|
57
|
+
height: '100%'
|
|
58
|
+
}
|
|
59
|
+
}]
|
|
47
60
|
}));
|
|
48
61
|
|
|
49
62
|
/**
|
|
@@ -55,13 +68,19 @@ const Root = styled('div', {
|
|
|
55
68
|
function ChartsWrapper(props) {
|
|
56
69
|
const {
|
|
57
70
|
children,
|
|
58
|
-
sx
|
|
71
|
+
sx,
|
|
72
|
+
extendVertically
|
|
59
73
|
} = props;
|
|
60
74
|
const chartRootRef = useChartRootRef();
|
|
75
|
+
const store = useStore();
|
|
76
|
+
const {
|
|
77
|
+
height: propsHeight
|
|
78
|
+
} = useSelector(store, selectorChartPropsSize);
|
|
61
79
|
return /*#__PURE__*/_jsx(Root, {
|
|
62
80
|
ref: chartRootRef,
|
|
63
81
|
ownerState: props,
|
|
64
82
|
sx: sx,
|
|
83
|
+
extendVertically: extendVertically ?? propsHeight === undefined,
|
|
65
84
|
children: children
|
|
66
85
|
});
|
|
67
86
|
}
|
|
@@ -3,4 +3,11 @@ import type { ZoomSliderShowTooltip } from "./plugins/featurePlugins/useChartCar
|
|
|
3
3
|
export declare const ZOOM_SLIDER_MARGIN = 4;
|
|
4
4
|
/** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
|
|
5
5
|
export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
|
|
6
|
-
export declare const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP: ZoomSliderShowTooltip;
|
|
6
|
+
export declare const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP: ZoomSliderShowTooltip;
|
|
7
|
+
/** Default margin for pie charts. */
|
|
8
|
+
export declare const DEFAULT_PIE_CHART_MARGIN: {
|
|
9
|
+
top: number;
|
|
10
|
+
bottom: number;
|
|
11
|
+
left: number;
|
|
12
|
+
right: number;
|
|
13
|
+
};
|
|
@@ -3,4 +3,12 @@ export const ZOOM_SLIDER_MARGIN = 4;
|
|
|
3
3
|
|
|
4
4
|
/** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
|
|
5
5
|
export const DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
|
|
6
|
-
export const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = 'hover';
|
|
6
|
+
export const DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP = 'hover';
|
|
7
|
+
|
|
8
|
+
/** Default margin for pie charts. */
|
|
9
|
+
export const DEFAULT_PIE_CHART_MARGIN = {
|
|
10
|
+
top: 5,
|
|
11
|
+
bottom: 5,
|
|
12
|
+
left: 5,
|
|
13
|
+
right: 5
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AxisValueFormatterContext, ContinuousScaleName, D3ContinuousScale } from "../models/axis.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a default formatter function for continuous scales (e.g., linear, sqrt, log).
|
|
4
|
+
* @returns A formatter function for continuous values.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createScalarFormatter(tickNumber: number, zoomScale: D3ContinuousScale): <S extends ContinuousScaleName = ContinuousScaleName>(value: any, context: AxisValueFormatterContext<S>) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a default formatter function for continuous scales (e.g., linear, sqrt, log).
|
|
3
|
+
* @returns A formatter function for continuous values.
|
|
4
|
+
*/
|
|
5
|
+
export function createScalarFormatter(tickNumber, zoomScale) {
|
|
6
|
+
return function defaultScalarValueFormatter(value, context) {
|
|
7
|
+
if (context.location === 'tick') {
|
|
8
|
+
return context.scale.tickFormat(tickNumber)(value);
|
|
9
|
+
}
|
|
10
|
+
if (context.location === 'zoom-slider-tooltip') {
|
|
11
|
+
return zoomScale.tickFormat(2)(value);
|
|
12
|
+
}
|
|
13
|
+
return `${value}`;
|
|
14
|
+
};
|
|
15
|
+
}
|
package/esm/internals/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
|
21
21
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
22
22
|
export * from "./plugins/featurePlugins/useChartVoronoi/index.js";
|
|
23
23
|
export * from "./plugins/utils/selectors.js";
|
|
24
|
+
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
25
|
+
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
24
26
|
export * from "./store/useCharts.js";
|
|
25
27
|
export * from "./store/useStore.js";
|
|
26
28
|
export * from "./store/useSelector.js";
|
|
@@ -28,6 +30,7 @@ export * from "../BarChart/BarChart.plugins.js";
|
|
|
28
30
|
export * from "../LineChart/LineChart.plugins.js";
|
|
29
31
|
export * from "../ScatterChart/ScatterChart.plugins.js";
|
|
30
32
|
export * from "../RadarChart/RadarChart.plugins.js";
|
|
33
|
+
export * from "../PieChart/PieChart.plugins.js";
|
|
31
34
|
export * from "./defaultizeValueFormatter.js";
|
|
32
35
|
export * from "./configInit.js";
|
|
33
36
|
export * from "./getLabel.js";
|
|
@@ -39,7 +42,11 @@ export * from "./getCurve.js";
|
|
|
39
42
|
export * from "./consumeSlots.js";
|
|
40
43
|
export * from "./consumeThemeProps.js";
|
|
41
44
|
export * from "./defaultizeMargin.js";
|
|
45
|
+
export * from "./colorScale.js";
|
|
46
|
+
export * from "./ticks.js";
|
|
42
47
|
export * from "./dateHelpers.js";
|
|
48
|
+
export * from "./invertScale.js";
|
|
49
|
+
export * from "./isBandScale.js";
|
|
43
50
|
export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
|
|
44
51
|
export * from "../context/ChartProvider/index.js";
|
|
45
52
|
export * from "../context/ChartsSlotsContext.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -26,6 +26,8 @@ export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
|
26
26
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
27
27
|
export * from "./plugins/featurePlugins/useChartVoronoi/index.js";
|
|
28
28
|
export * from "./plugins/utils/selectors.js";
|
|
29
|
+
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
30
|
+
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
29
31
|
export * from "./store/useCharts.js";
|
|
30
32
|
export * from "./store/useStore.js";
|
|
31
33
|
export * from "./store/useSelector.js";
|
|
@@ -36,6 +38,7 @@ export * from "../BarChart/BarChart.plugins.js";
|
|
|
36
38
|
export * from "../LineChart/LineChart.plugins.js";
|
|
37
39
|
export * from "../ScatterChart/ScatterChart.plugins.js";
|
|
38
40
|
export * from "../RadarChart/RadarChart.plugins.js";
|
|
41
|
+
export * from "../PieChart/PieChart.plugins.js";
|
|
39
42
|
|
|
40
43
|
// utils
|
|
41
44
|
export * from "./defaultizeValueFormatter.js";
|
|
@@ -49,7 +52,11 @@ export * from "./getCurve.js";
|
|
|
49
52
|
export * from "./consumeSlots.js";
|
|
50
53
|
export * from "./consumeThemeProps.js";
|
|
51
54
|
export * from "./defaultizeMargin.js";
|
|
55
|
+
export * from "./colorScale.js";
|
|
56
|
+
export * from "./ticks.js";
|
|
52
57
|
export * from "./dateHelpers.js";
|
|
58
|
+
export * from "./invertScale.js";
|
|
59
|
+
export * from "./isBandScale.js";
|
|
53
60
|
|
|
54
61
|
// contexts
|
|
55
62
|
export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isBandScale } from "./isBandScale.js";
|
|
2
|
+
export function invertScale(scale, data, value) {
|
|
3
|
+
if (isBandScale(scale)) {
|
|
4
|
+
const dataIndex = scale.bandwidth() === 0 ? Math.floor((value - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((value - Math.min(...scale.range())) / scale.step());
|
|
5
|
+
return data[dataIndex];
|
|
6
|
+
}
|
|
7
|
+
return scale.invert(value);
|
|
8
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
|
|
3
|
+
import { createScalarFormatter } from "../../../defaultValueFormatters.js";
|
|
3
4
|
import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
|
|
4
5
|
import { getColorScale, getOrdinalColorScale } from "../../../colorScale.js";
|
|
5
6
|
import { getTickNumber, scaleTickNumberByRange } from "../../../ticks.js";
|
|
@@ -123,7 +124,8 @@ export function computeAxisValue({
|
|
|
123
124
|
scaleType: scaleType,
|
|
124
125
|
scale: finalScale.domain(domain),
|
|
125
126
|
tickNumber,
|
|
126
|
-
colorScale: axis.colorMap && getColorScale(axis.colorMap)
|
|
127
|
+
colorScale: axis.colorMap && getColorScale(axis.colorMap),
|
|
128
|
+
valueFormatter: axis.valueFormatter ?? createScalarFormatter(tickNumber, getScale(scaleType, range.map(v => scale.invert(v)), range))
|
|
127
129
|
});
|
|
128
130
|
});
|
|
129
131
|
return {
|