@mui/x-charts 8.4.0 → 8.5.1

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.
Files changed (194) hide show
  1. package/BarChart/BarChart.d.ts +9 -2
  2. package/BarChart/BarChart.js +7 -1
  3. package/BarChart/BarLabel/BarLabel.d.ts +1 -1
  4. package/BarChart/seriesConfig/seriesProcessor.js +1 -1
  5. package/BarChart/useBarChartProps.js +1 -1
  6. package/CHANGELOG.md +215 -0
  7. package/ChartContainer/ChartContainer.d.ts +21 -2
  8. package/ChartContainer/ChartContainer.js +16 -0
  9. package/ChartContainer/useChartContainerProps.js +7 -3
  10. package/ChartDataProvider/ChartDataProvider.d.ts +11 -1
  11. package/ChartDataProvider/ChartDataProvider.js +19 -2
  12. package/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
  13. package/ChartDataProvider/useChartDataProviderProps.js +7 -3
  14. package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
  15. package/ChartsGrid/styledComponents.d.ts +2 -2
  16. package/ChartsReferenceLine/common.d.ts +1 -1
  17. package/ChartsTooltip/ChartsTooltip.js +1 -1
  18. package/ChartsTooltip/ChartsTooltipContainer.js +21 -16
  19. package/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
  20. package/ChartsTooltip/utils.d.ts +6 -0
  21. package/ChartsTooltip/utils.js +19 -1
  22. package/LineChart/LineChart.d.ts +9 -2
  23. package/LineChart/LineChart.js +7 -1
  24. package/LineChart/useLineChartProps.js +1 -1
  25. package/PieChart/PieChart.d.ts +10 -3
  26. package/PieChart/PieChart.js +12 -11
  27. package/RadarChart/RadarChart.d.ts +21 -3
  28. package/RadarChart/RadarChart.js +16 -2
  29. package/RadarChart/RadarChart.plugins.d.ts +5 -0
  30. package/RadarChart/RadarChart.plugins.js +10 -0
  31. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
  32. package/RadarChart/RadarDataProvider/RadarDataProvider.js +6 -116
  33. package/RadarChart/index.d.ts +2 -0
  34. package/RadarChart/index.js +15 -1
  35. package/RadarChart/useRadarChartProps.d.ts +2 -1
  36. package/RadarChart/useRadarChartProps.js +3 -1
  37. package/ScatterChart/ScatterChart.d.ts +9 -2
  38. package/ScatterChart/ScatterChart.js +7 -1
  39. package/ScatterChart/useScatterChartProps.js +4 -2
  40. package/SparkLineChart/SparkLineChart.d.ts +1 -1
  41. package/Toolbar/Toolbar.d.ts +11 -4
  42. package/Toolbar/Toolbar.js +38 -7
  43. package/Toolbar/Toolbar.types.d.ts +15 -0
  44. package/Toolbar/Toolbar.types.js +5 -0
  45. package/Toolbar/ToolbarButton.d.ts +8 -2
  46. package/Toolbar/ToolbarButton.js +39 -7
  47. package/Toolbar/chartToolbarClasses.d.ts +6 -0
  48. package/Toolbar/chartToolbarClasses.js +9 -0
  49. package/Toolbar/index.d.ts +3 -1
  50. package/Toolbar/index.js +22 -0
  51. package/context/ChartsSlotsContext.d.ts +20 -0
  52. package/context/ChartsSlotsContext.js +44 -0
  53. package/context/index.d.ts +2 -1
  54. package/context/index.js +11 -0
  55. package/context/useChartApiContext.d.ts +10 -0
  56. package/context/useChartApiContext.js +27 -0
  57. package/esm/BarChart/BarChart.d.ts +9 -2
  58. package/esm/BarChart/BarChart.js +7 -1
  59. package/esm/BarChart/BarLabel/BarLabel.d.ts +1 -1
  60. package/esm/BarChart/seriesConfig/seriesProcessor.js +1 -1
  61. package/esm/BarChart/useBarChartProps.js +1 -1
  62. package/esm/ChartContainer/ChartContainer.d.ts +21 -2
  63. package/esm/ChartContainer/ChartContainer.js +16 -0
  64. package/esm/ChartContainer/useChartContainerProps.js +7 -3
  65. package/esm/ChartDataProvider/ChartDataProvider.d.ts +11 -1
  66. package/esm/ChartDataProvider/ChartDataProvider.js +19 -2
  67. package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
  68. package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -3
  69. package/esm/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +1 -1
  70. package/esm/ChartsGrid/styledComponents.d.ts +2 -2
  71. package/esm/ChartsReferenceLine/common.d.ts +1 -1
  72. package/esm/ChartsTooltip/ChartsTooltip.js +1 -1
  73. package/esm/ChartsTooltip/ChartsTooltipContainer.js +22 -17
  74. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +4 -4
  75. package/esm/ChartsTooltip/utils.d.ts +6 -0
  76. package/esm/ChartsTooltip/utils.js +16 -1
  77. package/esm/LineChart/LineChart.d.ts +9 -2
  78. package/esm/LineChart/LineChart.js +7 -1
  79. package/esm/LineChart/useLineChartProps.js +1 -1
  80. package/esm/PieChart/PieChart.d.ts +10 -3
  81. package/esm/PieChart/PieChart.js +12 -11
  82. package/esm/RadarChart/RadarChart.d.ts +21 -3
  83. package/esm/RadarChart/RadarChart.js +16 -2
  84. package/esm/RadarChart/RadarChart.plugins.d.ts +5 -0
  85. package/esm/RadarChart/RadarChart.plugins.js +4 -0
  86. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
  87. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.js +5 -115
  88. package/esm/RadarChart/index.d.ts +2 -0
  89. package/esm/RadarChart/index.js +2 -0
  90. package/esm/RadarChart/useRadarChartProps.d.ts +2 -1
  91. package/esm/RadarChart/useRadarChartProps.js +3 -1
  92. package/esm/ScatterChart/ScatterChart.d.ts +9 -2
  93. package/esm/ScatterChart/ScatterChart.js +7 -1
  94. package/esm/ScatterChart/useScatterChartProps.js +4 -2
  95. package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
  96. package/esm/Toolbar/Toolbar.d.ts +11 -4
  97. package/esm/Toolbar/Toolbar.js +36 -6
  98. package/esm/Toolbar/Toolbar.types.d.ts +15 -0
  99. package/esm/Toolbar/Toolbar.types.js +1 -0
  100. package/esm/Toolbar/ToolbarButton.d.ts +8 -2
  101. package/esm/Toolbar/ToolbarButton.js +39 -6
  102. package/esm/Toolbar/chartToolbarClasses.d.ts +6 -0
  103. package/esm/Toolbar/chartToolbarClasses.js +2 -0
  104. package/esm/Toolbar/index.d.ts +3 -1
  105. package/esm/Toolbar/index.js +3 -1
  106. package/esm/context/ChartsSlotsContext.d.ts +20 -0
  107. package/esm/context/ChartsSlotsContext.js +35 -0
  108. package/esm/context/index.d.ts +2 -1
  109. package/esm/context/index.js +1 -0
  110. package/esm/context/useChartApiContext.d.ts +10 -0
  111. package/esm/context/useChartApiContext.js +21 -0
  112. package/esm/hooks/index.d.ts +1 -0
  113. package/esm/hooks/index.js +1 -0
  114. package/esm/index.js +1 -1
  115. package/esm/internals/components/AxisSharedComponents.d.ts +1 -1
  116. package/esm/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  117. package/esm/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
  118. package/esm/internals/constants.d.ts +10 -1
  119. package/esm/internals/constants.js +10 -1
  120. package/esm/internals/dateHelpers.d.ts +15 -0
  121. package/esm/internals/dateHelpers.js +20 -0
  122. package/esm/internals/domUtils.d.ts +1 -2
  123. package/esm/internals/domUtils.js +8 -19
  124. package/esm/internals/index.d.ts +6 -1
  125. package/esm/internals/index.js +6 -1
  126. package/esm/internals/invertScale.d.ts +2 -0
  127. package/esm/internals/invertScale.js +8 -0
  128. package/esm/internals/material/index.d.ts +2 -0
  129. package/esm/internals/material/index.js +2 -0
  130. package/esm/internals/plugins/allPlugins.d.ts +1 -0
  131. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +2 -8
  132. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
  133. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -3
  134. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
  135. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3000 -0
  136. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -1
  137. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +9 -0
  138. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
  139. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
  140. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -8
  141. package/esm/locales/index.d.ts +3 -1
  142. package/esm/locales/index.js +2 -0
  143. package/esm/locales/ptBR.d.ts +16 -0
  144. package/esm/locales/ptBR.js +9 -0
  145. package/esm/locales/ptPT.d.ts +16 -0
  146. package/esm/locales/ptPT.js +9 -0
  147. package/esm/models/axis.d.ts +2 -1
  148. package/esm/models/index.d.ts +2 -2
  149. package/esm/models/index.js +1 -0
  150. package/esm/models/seriesType/bar.d.ts +2 -2
  151. package/esm/models/slots/chartsBaseSlotProps.d.ts +7 -0
  152. package/esm/models/slots/chartsBaseSlots.d.ts +2 -1
  153. package/hooks/index.d.ts +1 -0
  154. package/hooks/index.js +12 -0
  155. package/index.js +1 -1
  156. package/internals/components/AxisSharedComponents.d.ts +1 -1
  157. package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +5 -0
  158. package/internals/components/ChartsWrapper/ChartsWrapper.js +22 -3
  159. package/internals/constants.d.ts +10 -1
  160. package/internals/constants.js +11 -2
  161. package/internals/dateHelpers.d.ts +15 -0
  162. package/internals/dateHelpers.js +28 -0
  163. package/internals/domUtils.d.ts +1 -2
  164. package/internals/domUtils.js +8 -20
  165. package/internals/index.d.ts +6 -1
  166. package/internals/index.js +68 -8
  167. package/internals/invertScale.d.ts +2 -0
  168. package/internals/invertScale.js +14 -0
  169. package/internals/material/index.d.ts +2 -0
  170. package/internals/material/index.js +2 -0
  171. package/internals/plugins/allPlugins.d.ts +1 -0
  172. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -11
  173. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
  174. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -3
  175. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
  176. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3000 -0
  177. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +10 -2
  178. package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +9 -0
  179. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
  180. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
  181. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +5 -11
  182. package/locales/index.d.ts +3 -1
  183. package/locales/index.js +22 -0
  184. package/locales/ptBR.d.ts +16 -0
  185. package/locales/ptBR.js +15 -0
  186. package/locales/ptPT.d.ts +16 -0
  187. package/locales/ptPT.js +15 -0
  188. package/models/axis.d.ts +2 -1
  189. package/models/index.d.ts +2 -2
  190. package/models/index.js +11 -0
  191. package/models/seriesType/bar.d.ts +2 -2
  192. package/models/slots/chartsBaseSlotProps.d.ts +7 -0
  193. package/models/slots/chartsBaseSlots.d.ts +2 -1
  194. package/package.json +5 -5
@@ -1,13 +1,40 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["render", "onKeyDown", "onFocus", "disabled", "aria-disabled"],
6
+ _excluded2 = ["tabIndex"];
2
7
  import PropTypes from 'prop-types';
3
8
  import * as React from 'react';
4
- import { defaultSlotsMaterial } from "../internals/material/index.js";
9
+ import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
10
+ import useForkRef from '@mui/utils/useForkRef';
11
+ import { useRegisterToolbarButton } from '@mui/x-internals/ToolbarContext';
12
+ import { useChartsSlots } from "../context/ChartsSlotsContext.js";
5
13
  import { jsx as _jsx } from "react/jsx-runtime";
6
14
  const ToolbarButton = /*#__PURE__*/React.forwardRef(function ToolbarButton(props, ref) {
7
- const IconButton = defaultSlotsMaterial.baseIconButton;
8
- return /*#__PURE__*/_jsx(IconButton, _extends({
9
- ref: ref
10
- }, props));
15
+ const {
16
+ render
17
+ } = props,
18
+ other = _objectWithoutPropertiesLoose(props, _excluded);
19
+ const {
20
+ slots,
21
+ slotProps
22
+ } = useChartsSlots();
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
34
+ }));
35
+ return /*#__PURE__*/_jsx(React.Fragment, {
36
+ children: element
37
+ });
11
38
  });
12
39
  if (process.env.NODE_ENV !== "production") ToolbarButton.displayName = "ToolbarButton";
13
40
  process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
@@ -16,6 +43,12 @@ process.env.NODE_ENV !== "production" ? ToolbarButton.propTypes = {
16
43
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
17
44
  // ----------------------------------------------------------------------
18
45
  className: PropTypes.string,
19
- style: PropTypes.object
46
+ disabled: PropTypes.bool,
47
+ /**
48
+ * A function to customize the rendering of the component.
49
+ */
50
+ render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
51
+ style: PropTypes.object,
52
+ tabIndex: PropTypes.number
20
53
  } : void 0;
21
54
  export { ToolbarButton };
@@ -0,0 +1,6 @@
1
+ export interface ChartsToolbarClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
4
+ }
5
+ export type ChartsToolbarClassKey = keyof ChartsToolbarClasses;
6
+ export declare const chartsToolbarClasses: ChartsToolbarClasses;
@@ -0,0 +1,2 @@
1
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
2
+ export const chartsToolbarClasses = generateUtilityClasses('MuiChartsToolbar', ['root']);
@@ -1,2 +1,4 @@
1
1
  export * from "./Toolbar.js";
2
- export * from "./ToolbarButton.js";
2
+ export * from "./ToolbarButton.js";
3
+ export * from "./Toolbar.types.js";
4
+ export * from "./chartToolbarClasses.js";
@@ -1,2 +1,4 @@
1
1
  export * from "./Toolbar.js";
2
- export * from "./ToolbarButton.js";
2
+ export * from "./ToolbarButton.js";
3
+ export * from "./Toolbar.types.js";
4
+ export * from "./chartToolbarClasses.js";
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
3
+ type SlotProps<T extends Record<keyof T, React.ComponentType<any>>> = { [key in keyof T]: React.ComponentProps<T[key]> };
4
+ export interface ChartsSlotsContextValue<T extends ChartsSlots & Record<keyof T, React.ComponentType<any>> = ChartsSlots> {
5
+ slots: T;
6
+ slotProps: Partial<SlotProps<T>>;
7
+ }
8
+ export declare const ChartsSlotsContext: React.Context<ChartsSlotsContextValue<ChartsSlots> | null>;
9
+ /**
10
+ * Get the slots and slotProps from the nearest `ChartDataProvider` or `ChartDataProviderPro`.
11
+ * @returns {ChartsSlotsContextValue} The slots and slotProps from the context.
12
+ */
13
+ export declare function useChartsSlots<T extends ChartsSlots & Record<keyof T, React.ComponentType<any>> = ChartsSlots>(): ChartsSlotsContextValue<T>;
14
+ interface ChartsSlotsProviderProps {
15
+ slots?: Partial<ChartsSlots>;
16
+ slotProps?: Partial<ChartsSlotProps>;
17
+ defaultSlots: ChartsSlots;
18
+ }
19
+ export declare function ChartsSlotsProvider(props: React.PropsWithChildren<ChartsSlotsProviderProps>): React.JSX.Element;
20
+ export {};
@@ -0,0 +1,35 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export const ChartsSlotsContext = /*#__PURE__*/React.createContext(null);
7
+
8
+ /**
9
+ * Get the slots and slotProps from the nearest `ChartDataProvider` or `ChartDataProviderPro`.
10
+ * @returns {ChartsSlotsContextValue} The slots and slotProps from the context.
11
+ */
12
+ if (process.env.NODE_ENV !== "production") ChartsSlotsContext.displayName = "ChartsSlotsContext";
13
+ export function useChartsSlots() {
14
+ const context = React.useContext(ChartsSlotsContext);
15
+ if (context == null) {
16
+ throw new Error(['MUI X Charts: Could not find the Charts Slots context.', 'It looks like you rendered your component outside of a ChartDataProvider.', 'This can also happen if you are bundling multiple versions of the library.'].join('\n'));
17
+ }
18
+ return context;
19
+ }
20
+ export function ChartsSlotsProvider(props) {
21
+ const {
22
+ slots,
23
+ slotProps = {},
24
+ defaultSlots,
25
+ children
26
+ } = props;
27
+ const value = React.useMemo(() => ({
28
+ slots: _extends({}, defaultSlots, slots),
29
+ slotProps
30
+ }), [defaultSlots, slots, slotProps]);
31
+ return /*#__PURE__*/_jsx(ChartsSlotsContext.Provider, {
32
+ value: value,
33
+ children: children
34
+ });
35
+ }
@@ -1 +1,2 @@
1
- export type { HighlightScope, FadeOptions, HighlightItemData, HighlightOptions } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
1
+ export type { HighlightScope, FadeOptions, HighlightItemData, HighlightOptions } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
2
+ export * from "./useChartApiContext.js";
@@ -1 +1,2 @@
1
+ export * from "./useChartApiContext.js";
1
2
  export {};
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { ChartApi } from "../ChartContainer/index.js";
3
+ /**
4
+ * The `useChartApiContext` hook provides access to the chart API.
5
+ * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
6
+ * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
7
+ * @example
8
+ * const apiRef = useChartApiContext<ChartApi<'bar'>>();
9
+ */
10
+ export declare function useChartApiContext<Api extends ChartApi>(): React.RefObject<Api>;
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { useChartContext } from "./ChartProvider/index.js";
5
+ /**
6
+ * The `useChartApiContext` hook provides access to the chart API.
7
+ * This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
8
+ * If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
9
+ * @example
10
+ * const apiRef = useChartApiContext<ChartApi<'bar'>>();
11
+ */
12
+ export function useChartApiContext() {
13
+ const {
14
+ publicAPI
15
+ } = useChartContext();
16
+ const apiRef = React.useRef(publicAPI);
17
+ React.useEffect(() => {
18
+ apiRef.current = publicAPI;
19
+ }, [publicAPI]);
20
+ return apiRef;
21
+ }
@@ -10,6 +10,7 @@ export * from "./useScatterSeries.js";
10
10
  export * from "./usePieSeries.js";
11
11
  export * from "./useBarSeries.js";
12
12
  export * from "./useLineSeries.js";
13
+ export * from "./useRadarSeries.js";
13
14
  export * from "./useItemHighlighted.js";
14
15
  export * from "./useItemHighlightedGetter.js";
15
16
  export * from "./useLegend.js";
@@ -10,6 +10,7 @@ export * from "./useScatterSeries.js";
10
10
  export * from "./usePieSeries.js";
11
11
  export * from "./useBarSeries.js";
12
12
  export * from "./useLineSeries.js";
13
+ export * from "./useRadarSeries.js";
13
14
  export * from "./useItemHighlighted.js";
14
15
  export * from "./useItemHighlightedGetter.js";
15
16
  export * from "./useLegend.js";
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.4.0
2
+ * @mui/x-charts v8.5.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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
  }
@@ -1,4 +1,13 @@
1
+ import type { ZoomSliderShowTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/zoom.types.js";
1
2
  /** Margin in the opposite direction of the axis, i.e., horizontal if the axis is vertical and vice versa. */
2
3
  export declare const ZOOM_SLIDER_MARGIN = 4;
3
4
  /** Size reserved for the zoom slider. The actual size of the slider might be smaller. */
4
- export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
5
+ export declare const DEFAULT_ZOOM_SLIDER_SIZE: number;
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
+ };
@@ -2,4 +2,13 @@
2
2
  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
- export const DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
5
+ export const DEFAULT_ZOOM_SLIDER_SIZE = 20 + 2 * ZOOM_SLIDER_MARGIN;
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,15 @@
1
+ import { AxisConfig } from "../models/index.js";
2
+ import { ChartsAxisProps } from "../models/axis.js";
3
+ /**
4
+ * Checks if the provided data array contains Date objects.
5
+ * @param data The data array to check.
6
+ * @returns A type predicate indicating if the data is an array of Date objects.
7
+ */
8
+ export declare const isDateData: (data?: readonly any[]) => data is Date[];
9
+ /**
10
+ * Creates a formatter function for date values.
11
+ * @param axis The axis configuration.
12
+ * @param range The range for the time scale.
13
+ * @returns A formatter function for date values.
14
+ */
15
+ export declare function createDateFormatter(axis: AxisConfig<'band' | 'point', any, ChartsAxisProps>, range: number[]): AxisConfig<'band' | 'point', any, ChartsAxisProps>['valueFormatter'];
@@ -0,0 +1,20 @@
1
+ import { scaleTime } from '@mui/x-charts-vendor/d3-scale';
2
+ /**
3
+ * Checks if the provided data array contains Date objects.
4
+ * @param data The data array to check.
5
+ * @returns A type predicate indicating if the data is an array of Date objects.
6
+ */
7
+ export const isDateData = data => data?.[0] instanceof Date;
8
+
9
+ /**
10
+ * Creates a formatter function for date values.
11
+ * @param axis The axis configuration.
12
+ * @param range The range for the time scale.
13
+ * @returns A formatter function for date values.
14
+ */
15
+ export function createDateFormatter(axis, range) {
16
+ const timeScale = scaleTime(axis.data, range);
17
+ return (v, {
18
+ location
19
+ }) => location === 'tick' ? timeScale.tickFormat(axis.tickNumber)(v) : `${v.toLocaleString()}`;
20
+ }
@@ -14,5 +14,4 @@ export declare const getStyleString: (style: React.CSSProperties) => string;
14
14
  export declare const getStringSize: (text: string | number, style?: React.CSSProperties) => {
15
15
  width: number;
16
16
  height: number;
17
- };
18
- export declare function unstable_cleanupDOM(): void;
17
+ };
@@ -5,10 +5,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  function isSsr() {
6
6
  return typeof window === 'undefined';
7
7
  }
8
- const stringCache = {
9
- widthCache: {},
10
- cacheCount: 0
11
- };
8
+ const stringCache = new Map();
12
9
  const MAX_CACHE_NUM = 2000;
13
10
  const SPAN_STYLE = {
14
11
  position: 'absolute',
@@ -75,8 +72,9 @@ export const getStringSize = (text, style = {}) => {
75
72
  const str = `${text}`;
76
73
  const styleString = getStyleString(style);
77
74
  const cacheKey = `${str}-${styleString}`;
78
- if (stringCache.widthCache[cacheKey]) {
79
- return stringCache.widthCache[cacheKey];
75
+ const size = stringCache.get(cacheKey);
76
+ if (size) {
77
+ return size;
80
78
  }
81
79
  try {
82
80
  let measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
@@ -99,12 +97,9 @@ export const getStringSize = (text, style = {}) => {
99
97
  width: rect.width,
100
98
  height: rect.height
101
99
  };
102
- stringCache.widthCache[cacheKey] = result;
103
- if (stringCache.cacheCount + 1 > MAX_CACHE_NUM) {
104
- stringCache.cacheCount = 0;
105
- stringCache.widthCache = {};
106
- } else {
107
- stringCache.cacheCount += 1;
100
+ stringCache.set(cacheKey, result);
101
+ if (stringCache.size + 1 > MAX_CACHE_NUM) {
102
+ stringCache.clear();
108
103
  }
109
104
  if (process.env.NODE_ENV === 'test') {
110
105
  // In test environment, we clean the measurement span immediately
@@ -125,10 +120,4 @@ export const getStringSize = (text, style = {}) => {
125
120
  height: 0
126
121
  };
127
122
  }
128
- };
129
-
130
- // eslint-disable-next-line @typescript-eslint/naming-convention
131
- export function unstable_cleanupDOM() {
132
- // const measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
133
- // measurementSpan?.remove();
134
- }
123
+ };
@@ -7,6 +7,7 @@ export { useDrawingArea } from "../hooks/useDrawingArea.js";
7
7
  export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
8
8
  export { useLineChartProps } from "../LineChart/useLineChartProps.js";
9
9
  export { useBarChartProps } from "../BarChart/useBarChartProps.js";
10
+ export { useRadarChartProps } from "../RadarChart/useRadarChartProps.js";
10
11
  export * from "../ChartContainer/useChartContainerProps.js";
11
12
  export * from "../ChartDataProvider/useChartDataProviderProps.js";
12
13
  export * from "./createSeriesSelectorOfType.js";
@@ -26,20 +27,24 @@ export * from "./store/useSelector.js";
26
27
  export * from "../BarChart/BarChart.plugins.js";
27
28
  export * from "../LineChart/LineChart.plugins.js";
28
29
  export * from "../ScatterChart/ScatterChart.plugins.js";
30
+ export * from "../RadarChart/RadarChart.plugins.js";
31
+ export * from "../PieChart/PieChart.plugins.js";
29
32
  export * from "./defaultizeValueFormatter.js";
30
33
  export * from "./configInit.js";
31
34
  export * from "./getLabel.js";
32
35
  export * from "./getSVGPoint.js";
33
36
  export * from "./isDefined.js";
34
- export { unstable_cleanupDOM } from "./domUtils.js";
35
37
  export * from "./getScale.js";
36
38
  export * from "./stackSeries.js";
37
39
  export * from "./getCurve.js";
38
40
  export * from "./consumeSlots.js";
39
41
  export * from "./consumeThemeProps.js";
40
42
  export * from "./defaultizeMargin.js";
43
+ export * from "./dateHelpers.js";
44
+ export * from "./invertScale.js";
41
45
  export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
42
46
  export * from "../context/ChartProvider/index.js";
47
+ export * from "../context/ChartsSlotsContext.js";
43
48
  export * from "../models/seriesType/config.js";
44
49
  export * from "../models/seriesType/common.js";
45
50
  export * from "../models/z-axis.js";
@@ -10,6 +10,7 @@ export { useDrawingArea } from "../hooks/useDrawingArea.js";
10
10
  export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
11
11
  export { useLineChartProps } from "../LineChart/useLineChartProps.js";
12
12
  export { useBarChartProps } from "../BarChart/useBarChartProps.js";
13
+ export { useRadarChartProps } from "../RadarChart/useRadarChartProps.js";
13
14
  export * from "../ChartContainer/useChartContainerProps.js";
14
15
  export * from "../ChartDataProvider/useChartDataProviderProps.js";
15
16
  export * from "./createSeriesSelectorOfType.js";
@@ -34,6 +35,8 @@ export * from "./store/useSelector.js";
34
35
  export * from "../BarChart/BarChart.plugins.js";
35
36
  export * from "../LineChart/LineChart.plugins.js";
36
37
  export * from "../ScatterChart/ScatterChart.plugins.js";
38
+ export * from "../RadarChart/RadarChart.plugins.js";
39
+ export * from "../PieChart/PieChart.plugins.js";
37
40
 
38
41
  // utils
39
42
  export * from "./defaultizeValueFormatter.js";
@@ -41,17 +44,19 @@ export * from "./configInit.js";
41
44
  export * from "./getLabel.js";
42
45
  export * from "./getSVGPoint.js";
43
46
  export * from "./isDefined.js";
44
- export { unstable_cleanupDOM } from "./domUtils.js";
45
47
  export * from "./getScale.js";
46
48
  export * from "./stackSeries.js";
47
49
  export * from "./getCurve.js";
48
50
  export * from "./consumeSlots.js";
49
51
  export * from "./consumeThemeProps.js";
50
52
  export * from "./defaultizeMargin.js";
53
+ export * from "./dateHelpers.js";
54
+ export * from "./invertScale.js";
51
55
 
52
56
  // contexts
53
57
  export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
54
58
  export * from "../context/ChartProvider/index.js";
59
+ export * from "../context/ChartsSlotsContext.js";
55
60
 
56
61
  // series configuration
57
62
  export * from "../models/seriesType/config.js";
@@ -0,0 +1,2 @@
1
+ import { D3Scale } from "../models/axis.js";
2
+ export declare function invertScale<T>(scale: D3Scale, data: readonly T[], value: number): number | Date | T;
@@ -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,4 +1,6 @@
1
+ import type * as React from 'react';
1
2
  import { ChartsBaseSlots } from "../../models/slots/chartsBaseSlots.js";
2
3
  import { ChartsIconSlots } from "../../models/slots/chartsIconSlots.js";
3
4
  export type ChartsSlots = ChartsBaseSlots & ChartsIconSlots;
5
+ export type ChartsSlotProps = { [key in keyof ChartsSlots]: React.ComponentProps<ChartsSlots[key]> };
4
6
  export declare const defaultSlotsMaterial: ChartsSlots;
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import IconButton from '@mui/material/IconButton';
3
+ import Button from '@mui/material/Button';
3
4
  const baseSlots = {
5
+ baseButton: Button,
4
6
  baseIconButton: IconButton
5
7
  };
6
8
  const iconSlots = {};
@@ -6,4 +6,5 @@ import { UseChartPolarAxisSignature } from "./featurePlugins/useChartPolarAxis/i
6
6
  import { UseChartVoronoiSignature } from "./featurePlugins/useChartVoronoi/index.js";
7
7
  import { UseChartZAxisSignature } from "./featurePlugins/useChartZAxis/index.js";
8
8
  export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartVoronoiSignature];
9
+ export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartVoronoiSignature];
9
10
  export declare const DEFAULT_PLUGINS: readonly [import("./models/index.js").ChartPlugin<UseChartZAxisSignature>, import("./models/index.js").ChartPlugin<UseChartCartesianAxisSignature<any>>, import("./models/index.js").ChartPlugin<UseChartInteractionSignature>, import("./models/index.js").ChartPlugin<UseChartHighlightSignature>, import("./models/index.js").ChartPlugin<UseChartVoronoiSignature>];
@@ -1,9 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { scaleBand, scalePoint, scaleTime } from '@mui/x-charts-vendor/d3-scale';
2
+ import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
3
3
  import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
4
4
  import { getColorScale, getOrdinalColorScale } from "../../../colorScale.js";
5
5
  import { getTickNumber, scaleTickNumberByRange } from "../../../ticks.js";
6
6
  import { getScale } from "../../../getScale.js";
7
+ import { isDateData, createDateFormatter } from "../../../dateHelpers.js";
7
8
  import { zoomScaleRange } from "./zoom.js";
8
9
  import { getAxisExtremum } from "./getAxisExtremum.js";
9
10
  import { getAxisTriggerTooltip } from "./getAxisTriggerTooltip.js";
@@ -13,13 +14,6 @@ axis) {
13
14
  const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
14
15
  return axis.reverse ? [range[1], range[0]] : range;
15
16
  }
16
- const isDateData = data => data?.[0] instanceof Date;
17
- function createDateFormatter(axis, range) {
18
- const timeScale = scaleTime(axis.data, range);
19
- return (v, {
20
- location
21
- }) => location === 'tick' ? timeScale.tickFormat(axis.tickNumber)(v) : `${v.toLocaleString()}`;
22
- }
23
17
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
24
18
  const DEFAULT_BAR_GAP_RATIO = 0.1;
25
19
  export function computeAxisValue({
@@ -1,4 +1,18 @@
1
1
  import { AxisId } from "../../../../models/axis.js";
2
2
  import { DefaultizedZoomOptions } from "./useChartCartesianAxis.types.js";
3
3
  import { ZoomOptions } from "./zoom.types.js";
4
+ export declare const defaultZoomOptions: {
5
+ minStart: number;
6
+ maxEnd: number;
7
+ step: number;
8
+ minSpan: number;
9
+ maxSpan: number;
10
+ panning: true;
11
+ filterMode: "keep";
12
+ slider: {
13
+ enabled: false;
14
+ size: number;
15
+ showTooltip: import("./zoom.types.js").ZoomSliderShowTooltip;
16
+ };
17
+ };
4
18
  export declare const defaultizeZoom: (zoom: boolean | ZoomOptions | undefined, axisId: AxisId, axisDirection: "x" | "y") => DefaultizedZoomOptions | undefined;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { DEFAULT_ZOOM_SLIDER_SIZE } from "../../../constants.js";
3
- const defaultZoomOptions = {
2
+ import { DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP, DEFAULT_ZOOM_SLIDER_SIZE } from "../../../constants.js";
3
+ export const defaultZoomOptions = {
4
4
  minStart: 0,
5
5
  maxEnd: 100,
6
6
  step: 5,
@@ -10,7 +10,8 @@ const defaultZoomOptions = {
10
10
  filterMode: 'keep',
11
11
  slider: {
12
12
  enabled: false,
13
- size: DEFAULT_ZOOM_SLIDER_SIZE
13
+ size: DEFAULT_ZOOM_SLIDER_SIZE,
14
+ showTooltip: DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP
14
15
  }
15
16
  };
16
17
  export const defaultizeZoom = (zoom, axisId, axisDirection) => {
@@ -2,7 +2,7 @@ import type { ChartPluginSignature } from "../../models/index.js";
2
2
  import type { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.js";
3
3
  import type { ComputedAxis, ScaleName, AxisId, ChartsAxisData, YAxis, XAxis, DefaultedXAxis, DefaultedYAxis } from "../../../../models/axis.js";
4
4
  import type { UseChartSeriesSignature } from "../../corePlugins/useChartSeries/index.js";
5
- import type { ZoomData, ZoomOptions } from "./zoom.types.js";
5
+ import type { ZoomData, ZoomOptions, ZoomSliderShowTooltip } from "./zoom.types.js";
6
6
  import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
7
7
  import type { ChartsAxisProps } from "../../../../ChartsAxis/index.js";
8
8
  /**
@@ -47,10 +47,13 @@ export type UseChartCartesianAxisDefaultizedParameters<S extends ScaleName = Sca
47
47
  defaultizedXAxis: DefaultedXAxis<S>[];
48
48
  defaultizedYAxis: DefaultedYAxis<S>[];
49
49
  };
50
+ export interface DefaultedZoomSliderOptions extends Omit<NonNullable<Required<ZoomOptions['slider']>>, 'showTooltip'> {
51
+ showTooltip: ZoomSliderShowTooltip;
52
+ }
50
53
  export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slider'>> {
51
54
  axisId: AxisId;
52
55
  axisDirection: 'x' | 'y';
53
- slider: NonNullable<Required<ZoomOptions['slider']>>;
56
+ slider: DefaultedZoomSliderOptions;
54
57
  }
55
58
  export interface UseChartCartesianAxisState {
56
59
  /**