@mui/x-charts 9.0.0-beta.0 → 9.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +155 -1
  2. package/ChartsLayerContainer/ChartsLayerContainer.js +0 -3
  3. package/ChartsLayerContainer/ChartsLayerContainer.mjs +0 -3
  4. package/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
  5. package/ChartsTooltip/ChartsAxisTooltipContent.mjs +1 -1
  6. package/ChartsTooltip/ChartsItemTooltipContent.js +3 -0
  7. package/ChartsTooltip/ChartsItemTooltipContent.mjs +3 -0
  8. package/ChartsTooltip/ChartsTooltipTable.d.mts +1 -1
  9. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  10. package/ChartsTooltip/useAxesTooltip.d.mts +17 -7
  11. package/ChartsTooltip/useAxesTooltip.d.ts +17 -7
  12. package/ChartsTooltip/useAxesTooltip.js +36 -4
  13. package/ChartsTooltip/useAxesTooltip.mjs +36 -4
  14. package/ChartsTooltip/useItemTooltip.d.mts +1 -1
  15. package/ChartsTooltip/useItemTooltip.d.ts +1 -1
  16. package/ChartsXAxis/useAxisTicksProps.d.mts +11 -11
  17. package/ChartsXAxis/useAxisTicksProps.d.ts +11 -11
  18. package/ChartsYAxis/useAxisTicksProps.d.mts +11 -11
  19. package/ChartsYAxis/useAxisTicksProps.d.ts +11 -11
  20. package/LineChart/LineHighlightPlot.js +3 -2
  21. package/LineChart/LineHighlightPlot.mjs +3 -2
  22. package/LineChart/useLinePlotData.js +1 -1
  23. package/LineChart/useLinePlotData.mjs +1 -1
  24. package/LineChart/useMarkPlotData.js +2 -2
  25. package/LineChart/useMarkPlotData.mjs +2 -2
  26. package/index.js +1 -1
  27. package/index.mjs +1 -1
  28. package/internals/configInit.mjs +2 -2
  29. package/internals/plugins/corePlugins/useChartSeries/processSeries.d.mts +2 -0
  30. package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +2 -0
  31. package/internals/plugins/corePlugins/useChartSeries/processSeries.js +2 -1
  32. package/internals/plugins/corePlugins/useChartSeries/processSeries.mjs +2 -1
  33. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +2 -0
  34. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.mjs +2 -0
  35. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getSeriesWithDefaultValues.types.d.mts +1 -1
  36. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getSeriesWithDefaultValues.types.d.ts +1 -1
  37. package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.mts +12 -2
  38. package/internals/plugins/corePlugins/useChartSeriesConfig/types/tooltipGetter.types.d.ts +12 -2
  39. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.mts +3 -2
  40. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -2
  41. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +8 -4
  42. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.mjs +10 -6
  43. package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.mts +10 -1
  44. package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +10 -1
  45. package/locales/elGR.d.mts +4 -0
  46. package/locales/elGR.d.ts +4 -0
  47. package/locales/elGR.js +5 -1
  48. package/locales/elGR.mjs +5 -1
  49. package/locales/enUS.d.mts +4 -0
  50. package/locales/enUS.d.ts +4 -0
  51. package/locales/enUS.js +5 -1
  52. package/locales/enUS.mjs +5 -1
  53. package/locales/frFR.d.mts +4 -0
  54. package/locales/frFR.d.ts +4 -0
  55. package/locales/frFR.js +5 -1
  56. package/locales/frFR.mjs +5 -1
  57. package/locales/nbNO.d.mts +4 -0
  58. package/locales/nbNO.d.ts +4 -0
  59. package/locales/nbNO.js +5 -1
  60. package/locales/nbNO.mjs +5 -1
  61. package/locales/ptBR.d.mts +4 -0
  62. package/locales/ptBR.d.ts +4 -0
  63. package/locales/ptBR.js +5 -1
  64. package/locales/ptBR.mjs +5 -1
  65. package/locales/ptPT.d.mts +4 -0
  66. package/locales/ptPT.d.ts +4 -0
  67. package/locales/ptPT.js +5 -1
  68. package/locales/ptPT.mjs +5 -1
  69. package/locales/svSE.d.mts +4 -0
  70. package/locales/svSE.d.ts +4 -0
  71. package/locales/svSE.js +5 -1
  72. package/locales/svSE.mjs +5 -1
  73. package/locales/utils/chartsLocaleTextApi.d.mts +8 -0
  74. package/locales/utils/chartsLocaleTextApi.d.ts +8 -0
  75. package/locales/utils/getChartsLocalization.d.mts +4 -0
  76. package/locales/utils/getChartsLocalization.d.ts +4 -0
  77. package/package.json +7 -7
  78. package/tests/web-components.mjs +1 -1
@@ -3479,18 +3479,18 @@ export declare function useAxisTicksProps(inProps: ChartsYAxisProps): {
3479
3479
  onFocusCapture?: import("react").FocusEventHandler<SVGTextElement> | undefined;
3480
3480
  onBlur?: import("react").FocusEventHandler<SVGTextElement> | undefined;
3481
3481
  onBlurCapture?: import("react").FocusEventHandler<SVGTextElement> | undefined;
3482
- onChange?: import("react").FormEventHandler<SVGTextElement> | undefined;
3483
- onChangeCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3482
+ onChange?: import("react").ChangeEventHandler<SVGTextElement, Element> | undefined;
3483
+ onChangeCapture?: import("react").ChangeEventHandler<SVGTextElement, Element> | undefined;
3484
3484
  onBeforeInput?: import("react").InputEventHandler<SVGTextElement> | undefined;
3485
- onBeforeInputCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3486
- onInput?: import("react").FormEventHandler<SVGTextElement> | undefined;
3487
- onInputCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3488
- onReset?: import("react").FormEventHandler<SVGTextElement> | undefined;
3489
- onResetCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3490
- onSubmit?: import("react").FormEventHandler<SVGTextElement> | undefined;
3491
- onSubmitCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3492
- onInvalid?: import("react").FormEventHandler<SVGTextElement> | undefined;
3493
- onInvalidCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3485
+ onBeforeInputCapture?: import("react").InputEventHandler<SVGTextElement> | undefined;
3486
+ onInput?: import("react").InputEventHandler<SVGTextElement> | undefined;
3487
+ onInputCapture?: import("react").InputEventHandler<SVGTextElement> | undefined;
3488
+ onReset?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3489
+ onResetCapture?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3490
+ onSubmit?: import("react").SubmitEventHandler<SVGTextElement> | undefined;
3491
+ onSubmitCapture?: import("react").SubmitEventHandler<SVGTextElement> | undefined;
3492
+ onInvalid?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3493
+ onInvalidCapture?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3494
3494
  onLoad?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3495
3495
  onLoadCapture?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3496
3496
  onError?: import("react").ReactEventHandler<SVGTextElement> | undefined;
@@ -3479,18 +3479,18 @@ export declare function useAxisTicksProps(inProps: ChartsYAxisProps): {
3479
3479
  onFocusCapture?: import("react").FocusEventHandler<SVGTextElement> | undefined;
3480
3480
  onBlur?: import("react").FocusEventHandler<SVGTextElement> | undefined;
3481
3481
  onBlurCapture?: import("react").FocusEventHandler<SVGTextElement> | undefined;
3482
- onChange?: import("react").FormEventHandler<SVGTextElement> | undefined;
3483
- onChangeCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3482
+ onChange?: import("react").ChangeEventHandler<SVGTextElement, Element> | undefined;
3483
+ onChangeCapture?: import("react").ChangeEventHandler<SVGTextElement, Element> | undefined;
3484
3484
  onBeforeInput?: import("react").InputEventHandler<SVGTextElement> | undefined;
3485
- onBeforeInputCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3486
- onInput?: import("react").FormEventHandler<SVGTextElement> | undefined;
3487
- onInputCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3488
- onReset?: import("react").FormEventHandler<SVGTextElement> | undefined;
3489
- onResetCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3490
- onSubmit?: import("react").FormEventHandler<SVGTextElement> | undefined;
3491
- onSubmitCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3492
- onInvalid?: import("react").FormEventHandler<SVGTextElement> | undefined;
3493
- onInvalidCapture?: import("react").FormEventHandler<SVGTextElement> | undefined;
3485
+ onBeforeInputCapture?: import("react").InputEventHandler<SVGTextElement> | undefined;
3486
+ onInput?: import("react").InputEventHandler<SVGTextElement> | undefined;
3487
+ onInputCapture?: import("react").InputEventHandler<SVGTextElement> | undefined;
3488
+ onReset?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3489
+ onResetCapture?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3490
+ onSubmit?: import("react").SubmitEventHandler<SVGTextElement> | undefined;
3491
+ onSubmitCapture?: import("react").SubmitEventHandler<SVGTextElement> | undefined;
3492
+ onInvalid?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3493
+ onInvalidCapture?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3494
3494
  onLoad?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3495
3495
  onLoadCapture?: import("react").ReactEventHandler<SVGTextElement> | undefined;
3496
3496
  onError?: import("react").ReactEventHandler<SVGTextElement> | undefined;
@@ -80,9 +80,10 @@ function LineHighlightPlot(props) {
80
80
  visibleStackedData,
81
81
  data,
82
82
  disableHighlight,
83
- shape = 'circle'
83
+ shape = 'circle',
84
+ hidden
84
85
  } = series[seriesId];
85
- if (disableHighlight || data[highlightedIndex] == null) {
86
+ if (hidden || disableHighlight || data[highlightedIndex] == null) {
86
87
  return null;
87
88
  }
88
89
  if (highlightedAxisId !== xAxisId) {
@@ -73,9 +73,10 @@ function LineHighlightPlot(props) {
73
73
  visibleStackedData,
74
74
  data,
75
75
  disableHighlight,
76
- shape = 'circle'
76
+ shape = 'circle',
77
+ hidden
77
78
  } = series[seriesId];
78
- if (disableHighlight || data[highlightedIndex] == null) {
79
+ if (hidden || disableHighlight || data[highlightedIndex] == null) {
79
80
  return null;
80
81
  }
81
82
  if (highlightedAxisId !== xAxisId) {
@@ -96,7 +96,7 @@ function useLinePlotData(xAxes, yAxes) {
96
96
  const hidden = series[seriesId].hidden;
97
97
  const linePath = (0, _d3Shape.line)().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y(d => {
98
98
  if (hidden) {
99
- return yScale(yScale.domain()[0]);
99
+ return yScale(d.y[0]);
100
100
  }
101
101
  return yScale(d.y[1]);
102
102
  });
@@ -89,7 +89,7 @@ export function useLinePlotData(xAxes, yAxes) {
89
89
  const hidden = series[seriesId].hidden;
90
90
  const linePath = d3Line().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y(d => {
91
91
  if (hidden) {
92
- return yScale(yScale.domain()[0]);
92
+ return yScale(d.y[0]);
93
93
  }
94
94
  return yScale(d.y[1]);
95
95
  });
@@ -67,9 +67,9 @@ function useMarkPlotData(xAxes, yAxes) {
67
67
  continue;
68
68
  }
69
69
 
70
- // The line fade animation move all the values to the min.
70
+ // The line fade animation move all the values to the series baseline.
71
71
  // So we need to do the same with mark in order for it to look nice.
72
- const y = yScale(hidden ? yScale.domain()[0] : value);
72
+ const y = yScale(hidden ? visibleStackedData[index][0] : value);
73
73
  const xPos = xScale(x);
74
74
  if (!instance.isPointInside(xPos, y)) {
75
75
  continue;
@@ -59,9 +59,9 @@ export function useMarkPlotData(xAxes, yAxes) {
59
59
  continue;
60
60
  }
61
61
 
62
- // The line fade animation move all the values to the min.
62
+ // The line fade animation move all the values to the series baseline.
63
63
  // So we need to do the same with mark in order for it to look nice.
64
- const y = yScale(hidden ? yScale.domain()[0] : value);
64
+ const y = yScale(hidden ? visibleStackedData[index][0] : value);
65
65
  const xPos = xScale(x);
66
66
  if (!instance.isPointInside(xPos, y)) {
67
67
  continue;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v9.0.0-beta.0
2
+ * @mui/x-charts v9.0.0-rc.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v9.0.0-beta.0
2
+ * @mui/x-charts v9.0.0-rc.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -2,7 +2,7 @@ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
2
2
  let cartesianInstance;
3
3
  let polarInstance;
4
4
  class CartesianSeriesTypes {
5
- types = (() => new Set())();
5
+ types = new Set();
6
6
  constructor() {
7
7
  if (cartesianInstance) {
8
8
  throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: Only one CartesianSeriesTypes instance can be created. ' + 'This is a singleton class used internally for series type registration. ' + 'Use the existing instance instead of creating a new one.' : _formatErrorMessage(24));
@@ -17,7 +17,7 @@ class CartesianSeriesTypes {
17
17
  }
18
18
  }
19
19
  class PolarSeriesTypes {
20
- types = (() => new Set())();
20
+ types = new Set();
21
21
  constructor() {
22
22
  if (polarInstance) {
23
23
  throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: Only one PolarSeriesTypes instance can be created. ' + 'This is a singleton class used internally for series type registration. ' + 'Use the existing instance instead of creating a new one.' : _formatErrorMessage(25));
@@ -14,10 +14,12 @@ import type { IsItemVisibleFunction } from "../../featurePlugins/useChartVisibil
14
14
  export declare const defaultizeSeries: <SeriesType extends ChartSeriesType>({
15
15
  series,
16
16
  colors,
17
+ theme,
17
18
  seriesConfig
18
19
  }: {
19
20
  series: Readonly<AllSeriesType<SeriesType>[]>;
20
21
  colors: readonly string[];
22
+ theme: "light" | "dark";
21
23
  seriesConfig: ChartSeriesConfig<SeriesType>;
22
24
  }) => {
23
25
  defaultizedSeries: DefaultizedSeriesGroups<SeriesType>;
@@ -14,10 +14,12 @@ import type { IsItemVisibleFunction } from "../../featurePlugins/useChartVisibil
14
14
  export declare const defaultizeSeries: <SeriesType extends ChartSeriesType>({
15
15
  series,
16
16
  colors,
17
+ theme,
17
18
  seriesConfig
18
19
  }: {
19
20
  series: Readonly<AllSeriesType<SeriesType>[]>;
20
21
  colors: readonly string[];
22
+ theme: "light" | "dark";
21
23
  seriesConfig: ChartSeriesConfig<SeriesType>;
22
24
  }) => {
23
25
  defaultizedSeries: DefaultizedSeriesGroups<SeriesType>;
@@ -16,13 +16,14 @@ var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/form
16
16
  const defaultizeSeries = ({
17
17
  series,
18
18
  colors,
19
+ theme,
19
20
  seriesConfig
20
21
  }) => {
21
22
  // Group series by type
22
23
  const seriesGroups = {};
23
24
  const idToType = new Map();
24
25
  series.forEach((seriesData, seriesIndex) => {
25
- const seriesWithDefaultValues = seriesConfig[seriesData.type].getSeriesWithDefaultValues(seriesData, seriesIndex, colors);
26
+ const seriesWithDefaultValues = seriesConfig[seriesData.type].getSeriesWithDefaultValues(seriesData, seriesIndex, colors, theme);
26
27
  const id = seriesWithDefaultValues.id;
27
28
  if (seriesGroups[seriesData.type] === undefined) {
28
29
  seriesGroups[seriesData.type] = {
@@ -9,13 +9,14 @@ import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
9
9
  export const defaultizeSeries = ({
10
10
  series,
11
11
  colors,
12
+ theme,
12
13
  seriesConfig
13
14
  }) => {
14
15
  // Group series by type
15
16
  const seriesGroups = {};
16
17
  const idToType = new Map();
17
18
  series.forEach((seriesData, seriesIndex) => {
18
- const seriesWithDefaultValues = seriesConfig[seriesData.type].getSeriesWithDefaultValues(seriesData, seriesIndex, colors);
19
+ const seriesWithDefaultValues = seriesConfig[seriesData.type].getSeriesWithDefaultValues(seriesData, seriesIndex, colors, theme);
19
20
  const id = seriesWithDefaultValues.id;
20
21
  if (seriesGroups[seriesData.type] === undefined) {
21
22
  seriesGroups[seriesData.type] = {
@@ -47,6 +47,7 @@ const useChartSeries = ({
47
47
  } = (0, _processSeries.defaultizeSeries)({
48
48
  series,
49
49
  colors: typeof colors === 'function' ? colors(theme) : colors,
50
+ theme,
50
51
  seriesConfig: store.state.seriesConfig.config
51
52
  });
52
53
  store.set('series', (0, _extends2.default)({}, store.state.series, {
@@ -90,6 +91,7 @@ useChartSeries.getInitialState = ({
90
91
  } = (0, _processSeries.defaultizeSeries)({
91
92
  series,
92
93
  colors: typeof colors === 'function' ? colors(theme) : colors,
94
+ theme,
93
95
  seriesConfig
94
96
  });
95
97
  return {
@@ -40,6 +40,7 @@ export const useChartSeries = ({
40
40
  } = defaultizeSeries({
41
41
  series,
42
42
  colors: typeof colors === 'function' ? colors(theme) : colors,
43
+ theme,
43
44
  seriesConfig: store.state.seriesConfig.config
44
45
  });
45
46
  store.set('series', _extends({}, store.state.series, {
@@ -82,6 +83,7 @@ useChartSeries.getInitialState = ({
82
83
  } = defaultizeSeries({
83
84
  series,
84
85
  colors: typeof colors === 'function' ? colors(theme) : colors,
86
+ theme,
85
87
  seriesConfig
86
88
  });
87
89
  return {
@@ -1,3 +1,3 @@
1
1
  import type { ChartSeries, ChartSeriesType } from "../../../../../models/seriesType/config.mjs";
2
2
  import type { AllSeriesType } from "../../../../../models/seriesType/index.mjs";
3
- export type GetSeriesWithDefaultValues<SeriesType extends ChartSeriesType> = (series: AllSeriesType<SeriesType>, seriesIndex: number, colors: readonly string[]) => ChartSeries<SeriesType>;
3
+ export type GetSeriesWithDefaultValues<SeriesType extends ChartSeriesType> = (series: AllSeriesType<SeriesType>, seriesIndex: number, colors: readonly string[], theme: 'light' | 'dark') => ChartSeries<SeriesType>;
@@ -1,3 +1,3 @@
1
1
  import type { ChartSeries, ChartSeriesType } from "../../../../../models/seriesType/config.js";
2
2
  import type { AllSeriesType } from "../../../../../models/seriesType/index.js";
3
- export type GetSeriesWithDefaultValues<SeriesType extends ChartSeriesType> = (series: AllSeriesType<SeriesType>, seriesIndex: number, colors: readonly string[]) => ChartSeries<SeriesType>;
3
+ export type GetSeriesWithDefaultValues<SeriesType extends ChartSeriesType> = (series: AllSeriesType<SeriesType>, seriesIndex: number, colors: readonly string[], theme: 'light' | 'dark') => ChartSeries<SeriesType>;
@@ -12,11 +12,21 @@ export interface ItemTooltipValue<SeriesType extends ChartSeriesType> {
12
12
  /**
13
13
  * The value.
14
14
  */
15
- value: SeriesType extends 'heatmap' ? number | null : ChartsSeriesConfig[SeriesType]['valueType'];
15
+ value: SeriesType extends 'heatmap' ? number | null : SeriesType extends 'ohlc' ? {
16
+ open: number;
17
+ high: number;
18
+ low: number;
19
+ close: number;
20
+ } | null : ChartsSeriesConfig[SeriesType]['valueType'];
16
21
  /**
17
22
  * The value formatted with context set to "tooltip".
18
23
  */
19
- formattedValue: string | null;
24
+ formattedValue: SeriesType extends 'ohlc' ? {
25
+ open: string | null;
26
+ high: string | null;
27
+ low: string | null;
28
+ close: string | null;
29
+ } : string | null;
20
30
  /**
21
31
  * The series mark type.
22
32
  */
@@ -12,11 +12,21 @@ export interface ItemTooltipValue<SeriesType extends ChartSeriesType> {
12
12
  /**
13
13
  * The value.
14
14
  */
15
- value: SeriesType extends 'heatmap' ? number | null : ChartsSeriesConfig[SeriesType]['valueType'];
15
+ value: SeriesType extends 'heatmap' ? number | null : SeriesType extends 'ohlc' ? {
16
+ open: number;
17
+ high: number;
18
+ low: number;
19
+ close: number;
20
+ } | null : ChartsSeriesConfig[SeriesType]['valueType'];
16
21
  /**
17
22
  * The value formatted with context set to "tooltip".
18
23
  */
19
- formattedValue: string | null;
24
+ formattedValue: SeriesType extends 'ohlc' ? {
25
+ open: string | null;
26
+ high: string | null;
27
+ low: string | null;
28
+ close: string | null;
29
+ } : string | null;
20
30
  /**
21
31
  * The series mark type.
22
32
  */
@@ -2,7 +2,7 @@ import type { ChartPluginSignature } from "../../models/index.mjs";
2
2
  import type { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.mjs";
3
3
  import type { ComputedAxis, ScaleName, AxisId, ChartsAxisData, YAxis, XAxis, DefaultedXAxis, DefaultedYAxis, AxisItemIdentifier } from "../../../../models/axis.mjs";
4
4
  import type { UseChartSeriesSignature } from "../../corePlugins/useChartSeries/index.mjs";
5
- import type { ZoomData, ZoomOptions, ZoomSliderShowTooltip } from "./zoom.types.mjs";
5
+ import type { ZoomData, ZoomOptions, ZoomSliderPreviewOptions, ZoomSliderShowTooltip } from "./zoom.types.mjs";
6
6
  import type { UseChartInteractionSignature } from "../useChartInteraction/index.mjs";
7
7
  import type { ChartsAxisProps } from "../../../../ChartsAxis/index.mjs";
8
8
  import type { UseChartBrushSignature } from "../useChartBrush/index.mjs";
@@ -79,8 +79,9 @@ export type UseChartCartesianAxisDefaultizedParameters<S extends ScaleName = Sca
79
79
  defaultizedXAxis: DefaultedXAxis<S>[];
80
80
  defaultizedYAxis: DefaultedYAxis<S>[];
81
81
  };
82
- export interface DefaultedZoomSliderOptions extends Omit<NonNullable<Required<ZoomOptions['slider']>>, 'showTooltip'> {
82
+ export interface DefaultedZoomSliderOptions extends Omit<NonNullable<Required<ZoomOptions['slider']>>, 'showTooltip' | 'preview'> {
83
83
  showTooltip: ZoomSliderShowTooltip;
84
+ preview: boolean | ZoomSliderPreviewOptions;
84
85
  }
85
86
  export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slider'>> {
86
87
  axisId: AxisId;
@@ -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, AxisItemIdentifier } from "../../../../models/axis.js";
4
4
  import type { UseChartSeriesSignature } from "../../corePlugins/useChartSeries/index.js";
5
- import type { ZoomData, ZoomOptions, ZoomSliderShowTooltip } from "./zoom.types.js";
5
+ import type { ZoomData, ZoomOptions, ZoomSliderPreviewOptions, 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
  import type { UseChartBrushSignature } from "../useChartBrush/index.js";
@@ -79,8 +79,9 @@ export type UseChartCartesianAxisDefaultizedParameters<S extends ScaleName = Sca
79
79
  defaultizedXAxis: DefaultedXAxis<S>[];
80
80
  defaultizedYAxis: DefaultedYAxis<S>[];
81
81
  };
82
- export interface DefaultedZoomSliderOptions extends Omit<NonNullable<Required<ZoomOptions['slider']>>, 'showTooltip'> {
82
+ export interface DefaultedZoomSliderOptions extends Omit<NonNullable<Required<ZoomOptions['slider']>>, 'showTooltip' | 'preview'> {
83
83
  showTooltip: ZoomSliderShowTooltip;
84
+ preview: boolean | ZoomSliderPreviewOptions;
84
85
  }
85
86
  export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slider'>> {
86
87
  axisId: AxisId;
@@ -32,14 +32,16 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
32
32
  bottom: mainChartDrawingArea.height
33
33
  };
34
34
  }
35
- const selectorChartPreviewXScales = exports.selectorChartPreviewXScales = (0, _store.createSelectorMemoized)(_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartNormalizedXScales, function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, normalizedXScales, axisId) {
35
+ const selectorChartPreviewXScales = exports.selectorChartPreviewXScales = (0, _store.createSelectorMemoized)(_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartXAxisWithDomains, function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, {
36
+ domains: unfilteredDomains
37
+ }, axisId) {
36
38
  const hasAxis = xAxes?.some(axis => axis.id === axisId);
37
39
  const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
38
40
  const options = zoomOptions[axisId];
39
41
  const scales = {};
40
42
  xAxes?.forEach(eachAxis => {
41
43
  const axis = eachAxis;
42
- const scale = normalizedXScales[axis.id].copy();
44
+ const scale = (0, _getAxisScale.getNormalizedAxisScale)(axis, unfilteredDomains[axis.id].domain);
43
45
  const range = (0, _getAxisScale.getRange)(drawingArea, 'x', axis);
44
46
  const zoomedRange = (0, _zoom.zoomScaleRange)(range, [options.minStart, options.maxEnd]);
45
47
  scale.range(zoomedRange);
@@ -76,14 +78,16 @@ const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXA
76
78
  }
77
79
  return computedAxes.axis;
78
80
  });
79
- const selectorChartPreviewYScales = exports.selectorChartPreviewYScales = (0, _store.createSelectorMemoized)(_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartNormalizedYScales, function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, normalizedYScales, axisId) {
81
+ const selectorChartPreviewYScales = exports.selectorChartPreviewYScales = (0, _store.createSelectorMemoized)(_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartYAxisWithDomains, function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, {
82
+ domains: unfilteredDomains
83
+ }, axisId) {
80
84
  const hasAxis = yAxes?.some(axis => axis.id === axisId);
81
85
  const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
82
86
  const options = zoomOptions[axisId];
83
87
  const scales = {};
84
88
  yAxes?.forEach(eachAxis => {
85
89
  const axis = eachAxis;
86
- const scale = normalizedYScales[axis.id].copy();
90
+ const scale = (0, _getAxisScale.getNormalizedAxisScale)(axis, unfilteredDomains[axis.id].domain);
87
91
  let range = (0, _getAxisScale.getRange)(drawingArea, 'y', axis);
88
92
  if ((0, _scaleGuards.isOrdinalScale)(scale)) {
89
93
  range = range.reverse();
@@ -2,10 +2,10 @@ import { createSelectorMemoized } from '@mui/x-internals/store';
2
2
  import { selectorChartRawXAxis, selectorChartRawYAxis } from "./useChartCartesianAxisLayout.selectors.mjs";
3
3
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.mjs";
4
4
  import { computeAxisValue } from "./computeAxisValue.mjs";
5
- import { selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartXAxisWithDomains, selectorChartYAxisWithDomains, selectorChartZoomOptionsLookup } from "./useChartCartesianAxisRendering.selectors.mjs";
5
+ import { selectorChartXAxisWithDomains, selectorChartYAxisWithDomains, selectorChartZoomOptionsLookup } from "./useChartCartesianAxisRendering.selectors.mjs";
6
6
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.mjs";
7
7
  import { ZOOM_SLIDER_PREVIEW_SIZE } from "../../../constants.mjs";
8
- import { getRange } from "./getAxisScale.mjs";
8
+ import { getNormalizedAxisScale, getRange } from "./getAxisScale.mjs";
9
9
  import { zoomScaleRange } from "./zoom.mjs";
10
10
  import { isOrdinalScale } from "../../../scaleGuards.mjs";
11
11
  import { selectorChartSeriesConfig } from "../../corePlugins/useChartSeriesConfig/index.mjs";
@@ -26,14 +26,16 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
26
26
  bottom: mainChartDrawingArea.height
27
27
  };
28
28
  }
29
- export const selectorChartPreviewXScales = createSelectorMemoized(selectorChartRawXAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedXScales, function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, normalizedXScales, axisId) {
29
+ export const selectorChartPreviewXScales = createSelectorMemoized(selectorChartRawXAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartXAxisWithDomains, function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, {
30
+ domains: unfilteredDomains
31
+ }, axisId) {
30
32
  const hasAxis = xAxes?.some(axis => axis.id === axisId);
31
33
  const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
32
34
  const options = zoomOptions[axisId];
33
35
  const scales = {};
34
36
  xAxes?.forEach(eachAxis => {
35
37
  const axis = eachAxis;
36
- const scale = normalizedXScales[axis.id].copy();
38
+ const scale = getNormalizedAxisScale(axis, unfilteredDomains[axis.id].domain);
37
39
  const range = getRange(drawingArea, 'x', axis);
38
40
  const zoomedRange = zoomScaleRange(range, [options.minStart, options.maxEnd]);
39
41
  scale.range(zoomedRange);
@@ -70,14 +72,16 @@ export const selectorChartPreviewComputedXAxis = createSelectorMemoized(selector
70
72
  }
71
73
  return computedAxes.axis;
72
74
  });
73
- export const selectorChartPreviewYScales = createSelectorMemoized(selectorChartRawYAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedYScales, function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, normalizedYScales, axisId) {
75
+ export const selectorChartPreviewYScales = createSelectorMemoized(selectorChartRawYAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartYAxisWithDomains, function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, {
76
+ domains: unfilteredDomains
77
+ }, axisId) {
74
78
  const hasAxis = yAxes?.some(axis => axis.id === axisId);
75
79
  const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
76
80
  const options = zoomOptions[axisId];
77
81
  const scales = {};
78
82
  yAxes?.forEach(eachAxis => {
79
83
  const axis = eachAxis;
80
- const scale = normalizedYScales[axis.id].copy();
84
+ const scale = getNormalizedAxisScale(axis, unfilteredDomains[axis.id].domain);
81
85
  let range = getRange(drawingArea, 'y', axis);
82
86
  if (isOrdinalScale(scale)) {
83
87
  range = range.reverse();
@@ -1,4 +1,5 @@
1
1
  import { type AxisId } from "../../../../models/axis.mjs";
2
+ import { type SeriesId } from "../../../../models/seriesType/common.mjs";
2
3
  import type { ExtremumFilter } from "./useChartCartesianAxis.types.mjs";
3
4
  export type ZoomData = {
4
5
  /**
@@ -96,8 +97,16 @@ export interface ZoomSliderOptions {
96
97
  showTooltip?: ZoomSliderShowTooltip;
97
98
  /**
98
99
  * If `true`, a preview of the chart will be shown in the slider.
100
+ * Can also be an object to configure which series are shown in the preview.
99
101
  */
100
- preview?: boolean;
102
+ preview?: boolean | ZoomSliderPreviewOptions;
103
+ }
104
+ export interface ZoomSliderPreviewOptions {
105
+ /**
106
+ * The series IDs to display in the preview.
107
+ * If not provided, all series attached to this axis will be shown.
108
+ */
109
+ seriesIds?: SeriesId[];
101
110
  }
102
111
  export type ZoomAxisFilters = Record<AxisId, ExtremumFilter>;
103
112
  export type ZoomMap = Map<AxisId, ZoomData>;
@@ -1,4 +1,5 @@
1
1
  import { type AxisId } from "../../../../models/axis.js";
2
+ import { type SeriesId } from "../../../../models/seriesType/common.js";
2
3
  import type { ExtremumFilter } from "./useChartCartesianAxis.types.js";
3
4
  export type ZoomData = {
4
5
  /**
@@ -96,8 +97,16 @@ export interface ZoomSliderOptions {
96
97
  showTooltip?: ZoomSliderShowTooltip;
97
98
  /**
98
99
  * If `true`, a preview of the chart will be shown in the slider.
100
+ * Can also be an object to configure which series are shown in the preview.
99
101
  */
100
- preview?: boolean;
102
+ preview?: boolean | ZoomSliderPreviewOptions;
103
+ }
104
+ export interface ZoomSliderPreviewOptions {
105
+ /**
106
+ * The series IDs to display in the preview.
107
+ * If not provided, all series attached to this axis will be shown.
108
+ */
109
+ seriesIds?: SeriesId[];
101
110
  }
102
111
  export type ZoomAxisFilters = Record<AxisId, ExtremumFilter>;
103
112
  export type ZoomMap = Map<AxisId, ZoomData>;
@@ -184,6 +184,10 @@ export declare const elGR: {
184
184
  high: number | null;
185
185
  low: number | null;
186
186
  close: number | null;
187
+ formattedOpen: string | null;
188
+ formattedHigh: string | null;
189
+ formattedLow: string | null;
190
+ formattedClose: string | null;
187
191
  date: Date | null;
188
192
  formattedDate: string;
189
193
  seriesLabel?: string;
package/locales/elGR.d.ts CHANGED
@@ -184,6 +184,10 @@ export declare const elGR: {
184
184
  high: number | null;
185
185
  low: number | null;
186
186
  close: number | null;
187
+ formattedOpen: string | null;
188
+ formattedHigh: string | null;
189
+ formattedLow: string | null;
190
+ formattedClose: string | null;
187
191
  date: Date | null;
188
192
  formattedDate: string;
189
193
  seriesLabel?: string;
package/locales/elGR.js CHANGED
@@ -204,11 +204,15 @@ const elGRLocaleText = exports.elGRLocaleText = {
204
204
  // high,
205
205
  // low,
206
206
  // close,
207
+ // formattedOpen,
208
+ // formattedHigh,
209
+ // formattedLow,
210
+ // formattedClose,
207
211
  // formattedDate,
208
212
  // seriesLabel
209
213
  // }) {
210
214
  // const hasValues = open !== null && high !== null && low !== null && close !== null;
211
- // return [formattedDate, seriesLabel, hasValues ? `Open: ${open}, High: ${high}, Low: ${low}, Close: ${close}` : this.a11yNoValue].filter(Boolean).join(this.a11yConnector);
215
+ // return [formattedDate, seriesLabel, hasValues ? `Open: ${formattedOpen ?? open}, High: ${formattedHigh ?? high}, Low: ${formattedLow ?? low}, Close: ${formattedClose ?? close}` : this.a11yNoValue].filter(Boolean).join(this.a11yConnector);
212
216
  // },
213
217
  };
214
218
  const elGR = exports.elGR = (0, _getChartsLocalization.getChartsLocalization)(elGRLocaleText);
package/locales/elGR.mjs CHANGED
@@ -198,11 +198,15 @@ export const elGRLocaleText = {
198
198
  // high,
199
199
  // low,
200
200
  // close,
201
+ // formattedOpen,
202
+ // formattedHigh,
203
+ // formattedLow,
204
+ // formattedClose,
201
205
  // formattedDate,
202
206
  // seriesLabel
203
207
  // }) {
204
208
  // const hasValues = open !== null && high !== null && low !== null && close !== null;
205
- // return [formattedDate, seriesLabel, hasValues ? `Open: ${open}, High: ${high}, Low: ${low}, Close: ${close}` : this.a11yNoValue].filter(Boolean).join(this.a11yConnector);
209
+ // return [formattedDate, seriesLabel, hasValues ? `Open: ${formattedOpen ?? open}, High: ${formattedHigh ?? high}, Low: ${formattedLow ?? low}, Close: ${formattedClose ?? close}` : this.a11yNoValue].filter(Boolean).join(this.a11yConnector);
206
210
  // },
207
211
  };
208
212
  export const elGR = getChartsLocalization(elGRLocaleText);
@@ -185,6 +185,10 @@ export declare const enUS: {
185
185
  high: number | null;
186
186
  low: number | null;
187
187
  close: number | null;
188
+ formattedOpen: string | null;
189
+ formattedHigh: string | null;
190
+ formattedLow: string | null;
191
+ formattedClose: string | null;
188
192
  date: Date | null;
189
193
  formattedDate: string;
190
194
  seriesLabel?: string;
package/locales/enUS.d.ts CHANGED
@@ -185,6 +185,10 @@ export declare const enUS: {
185
185
  high: number | null;
186
186
  low: number | null;
187
187
  close: number | null;
188
+ formattedOpen: string | null;
189
+ formattedHigh: string | null;
190
+ formattedLow: string | null;
191
+ formattedClose: string | null;
188
192
  date: Date | null;
189
193
  formattedDate: string;
190
194
  seriesLabel?: string;
package/locales/enUS.js CHANGED
@@ -204,11 +204,15 @@ const enUSLocaleText = exports.enUSLocaleText = {
204
204
  high,
205
205
  low,
206
206
  close,
207
+ formattedOpen,
208
+ formattedHigh,
209
+ formattedLow,
210
+ formattedClose,
207
211
  formattedDate,
208
212
  seriesLabel
209
213
  }) {
210
214
  const hasValues = open !== null && high !== null && low !== null && close !== null;
211
- return [formattedDate, seriesLabel, hasValues ? `Open: ${open}, High: ${high}, Low: ${low}, Close: ${close}` : this.a11yNoValue].filter(Boolean).join(this.a11yConnector);
215
+ return [formattedDate, seriesLabel, hasValues ? `Open: ${formattedOpen ?? open}, High: ${formattedHigh ?? high}, Low: ${formattedLow ?? low}, Close: ${formattedClose ?? close}` : this.a11yNoValue].filter(Boolean).join(this.a11yConnector);
212
216
  }
213
217
  };
214
218
  const DEFAULT_LOCALE = exports.DEFAULT_LOCALE = enUSLocaleText;