@mui/x-charts 7.17.0 → 7.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +10 -0
- package/CHANGELOG.md +98 -5
- package/ChartsLegend/ChartsLegend.d.ts +2 -2
- package/ChartsTooltip/index.d.ts +3 -0
- package/ChartsTooltip/index.js +4 -1
- package/ChartsTooltip/useAxisTooltip.d.ts +18 -0
- package/ChartsTooltip/useAxisTooltip.js +84 -0
- package/ChartsTooltip/useItemTooltip.d.ts +10 -0
- package/ChartsTooltip/useItemTooltip.js +64 -0
- package/ChartsTooltip/utils.d.ts +2 -1
- package/LineChart/AnimatedLine.js +12 -22
- package/LineChart/LineChart.js +10 -0
- package/PieChart/PieChart.js +10 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +10 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -0
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +1 -1
- package/ResponsiveChartContainer/useChartContainerDimensions.js +32 -8
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +3 -2
- package/ScatterChart/ScatterChart.js +10 -0
- package/SparkLineChart/SparkLineChart.js +10 -0
- package/context/CartesianProvider/CartesianProvider.js +3 -3
- package/context/CartesianProvider/getAxisExtremum.d.ts +1 -1
- package/context/CartesianProvider/getAxisExtremum.js +5 -4
- package/context/CartesianProvider/index.d.ts +0 -5
- package/context/CartesianProvider/index.js +1 -6
- package/context/PluginProvider/ExtremumGetter.types.d.ts +1 -0
- package/context/PluginProvider/Plugin.types.d.ts +4 -0
- package/context/PluginProvider/PluginContext.js +3 -1
- package/context/PluginProvider/index.d.ts +2 -0
- package/context/PluginProvider/index.js +3 -1
- package/context/PluginProvider/mergePlugins.d.ts +10 -0
- package/context/PluginProvider/mergePlugins.js +11 -1
- package/context/PluginProvider/useRadiusExtremumGetter.d.ts +4 -0
- package/context/PluginProvider/useRadiusExtremumGetter.js +17 -0
- package/context/PluginProvider/useRotationExtremumGetter.d.ts +4 -0
- package/context/PluginProvider/useRotationExtremumGetter.js +17 -0
- package/context/PolarProvider/Polar.types.d.ts +42 -0
- package/context/PolarProvider/Polar.types.js +1 -0
- package/context/PolarProvider/PolarContext.d.ts +4 -0
- package/context/PolarProvider/PolarContext.js +13 -0
- package/context/PolarProvider/PolarProvider.d.ts +4 -0
- package/context/PolarProvider/PolarProvider.js +49 -0
- package/context/PolarProvider/getAxisExtremum.d.ts +4 -0
- package/context/PolarProvider/getAxisExtremum.js +20 -0
- package/context/PolarProvider/index.d.ts +0 -0
- package/context/PolarProvider/index.js +0 -0
- package/context/PolarProvider/usePolarContext.d.ts +2 -0
- package/context/PolarProvider/usePolarContext.js +10 -0
- package/index.js +1 -1
- package/internals/computeAxisValue.d.ts +38 -0
- package/{context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +28 -15
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/models/axis.d.ts +20 -0
- package/models/seriesType/config.d.ts +6 -2
- package/modern/BarChart/BarChart.js +10 -0
- package/modern/ChartsTooltip/index.js +4 -1
- package/modern/ChartsTooltip/useAxisTooltip.js +84 -0
- package/modern/ChartsTooltip/useItemTooltip.js +64 -0
- package/modern/LineChart/AnimatedLine.js +12 -22
- package/modern/LineChart/LineChart.js +10 -0
- package/modern/PieChart/PieChart.js +10 -0
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -0
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +32 -8
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +3 -2
- package/modern/ScatterChart/ScatterChart.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +10 -0
- package/modern/context/CartesianProvider/CartesianProvider.js +3 -3
- package/modern/context/CartesianProvider/getAxisExtremum.js +5 -4
- package/modern/context/CartesianProvider/index.js +1 -6
- package/modern/context/PluginProvider/PluginContext.js +3 -1
- package/modern/context/PluginProvider/index.js +3 -1
- package/modern/context/PluginProvider/mergePlugins.js +11 -1
- package/modern/context/PluginProvider/useRadiusExtremumGetter.js +17 -0
- package/modern/context/PluginProvider/useRotationExtremumGetter.js +17 -0
- package/modern/context/PolarProvider/Polar.types.js +1 -0
- package/modern/context/PolarProvider/PolarContext.js +13 -0
- package/modern/context/PolarProvider/PolarProvider.js +49 -0
- package/modern/context/PolarProvider/getAxisExtremum.js +20 -0
- package/modern/context/PolarProvider/index.js +0 -0
- package/modern/context/PolarProvider/usePolarContext.js +10 -0
- package/modern/index.js +1 -1
- package/modern/{context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +28 -15
- package/modern/internals/index.js +1 -0
- package/node/BarChart/BarChart.js +10 -0
- package/node/ChartsTooltip/index.js +42 -1
- package/node/ChartsTooltip/useAxisTooltip.js +90 -0
- package/node/ChartsTooltip/useItemTooltip.js +71 -0
- package/node/LineChart/AnimatedLine.js +12 -22
- package/node/LineChart/LineChart.js +10 -0
- package/node/PieChart/PieChart.js +10 -0
- package/node/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -0
- package/node/ResponsiveChartContainer/useChartContainerDimensions.js +32 -8
- package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +3 -2
- package/node/ScatterChart/ScatterChart.js +10 -0
- package/node/SparkLineChart/SparkLineChart.js +10 -0
- package/node/context/CartesianProvider/CartesianProvider.js +3 -3
- package/node/context/CartesianProvider/getAxisExtremum.js +5 -4
- package/node/context/CartesianProvider/index.js +1 -13
- package/node/context/PluginProvider/PluginContext.js +3 -1
- package/node/context/PluginProvider/index.js +22 -0
- package/node/context/PluginProvider/mergePlugins.js +11 -1
- package/node/context/PluginProvider/useRadiusExtremumGetter.js +23 -0
- package/node/context/PluginProvider/useRotationExtremumGetter.js +23 -0
- package/node/context/PolarProvider/Polar.types.js +5 -0
- package/node/context/PolarProvider/PolarContext.js +20 -0
- package/node/context/PolarProvider/PolarProvider.js +54 -0
- package/node/context/PolarProvider/getAxisExtremum.js +27 -0
- package/node/context/PolarProvider/index.js +1 -0
- package/node/context/PolarProvider/usePolarContext.js +17 -0
- package/node/index.js +1 -1
- package/node/{context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +29 -16
- package/node/internals/index.js +12 -0
- package/package.json +4 -4
- package/context/CartesianProvider/computeValue.d.ts +0 -30
package/BarChart/BarChart.js
CHANGED
|
@@ -196,6 +196,16 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
196
196
|
* @param {BarItemIdentifier} barItemIdentifier The bar item identifier.
|
|
197
197
|
*/
|
|
198
198
|
onItemClick: PropTypes.func,
|
|
199
|
+
/**
|
|
200
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
201
|
+
* before it renders for the first time.
|
|
202
|
+
*
|
|
203
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
204
|
+
* the first render, like when used inside a grid.
|
|
205
|
+
*
|
|
206
|
+
* @default false
|
|
207
|
+
*/
|
|
208
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
199
209
|
/**
|
|
200
210
|
* Indicate which axis to display the right of the charts.
|
|
201
211
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,99 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.18.0
|
|
7
|
+
|
|
8
|
+
_Sep 20, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 💫 Support [Row spanning](https://mui.com/x/react-data-grid/row-spanning/) on the Data Grid that automatically merges the consecutive cells in a column based on the cell value
|
|
13
|
+
|
|
14
|
+
<img width="600" src="https://github.com/user-attachments/assets/d32ec936-d238-4c92-9e1a-af6788d74cdf" alt="data grid row spanning" />
|
|
15
|
+
|
|
16
|
+
- ⏰ Support `date-fns` v4 (#14673) @LukasTy
|
|
17
|
+
- 🎉 Add option for Pickers to change the order of displayed years (#11780) @thomasmoon
|
|
18
|
+
- 🐞 Bugfixes
|
|
19
|
+
- 📚 Documentation improvements
|
|
20
|
+
|
|
21
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
22
|
+
|
|
23
|
+
### Data Grid
|
|
24
|
+
|
|
25
|
+
#### `@mui/x-data-grid@7.18.0`
|
|
26
|
+
|
|
27
|
+
- [DataGrid] Add default reset value in row edit mode (#14050) @michelengelen
|
|
28
|
+
- [DataGrid] Add `columnGroupHeaderHeight` prop for sizing column group headers (#14637) @KenanYusuf
|
|
29
|
+
- [DataGrid] Fix `document` reference when the grid is rendered in a popup window (#14649) @arminmeh
|
|
30
|
+
- [DataGrid] Remove `minFirstColumn` from `GetHeadersParams` interface (#14450) @k-rajat19
|
|
31
|
+
- [DataGrid] Row spanning (#14124) @MBilalShafi
|
|
32
|
+
|
|
33
|
+
#### `@mui/x-data-grid-pro@7.18.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
34
|
+
|
|
35
|
+
Same changes as in `@mui/x-data-grid@7.18.0`, plus:
|
|
36
|
+
|
|
37
|
+
- [DataGridPro] Fix `onRowsScrollEnd` being triggered instantly when bottom pinned row is present (#14602) @arminmeh
|
|
38
|
+
- [DataGridPro] Fix header filters rendering issue for `isEmpty` and `isNotEmpty` filter operators (#14493) @k-rajat19
|
|
39
|
+
- [DataGridPro] Fix pinned columns in RTL mode (#14586) @KenanYusuf
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-data-grid-premium@7.18.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
42
|
+
|
|
43
|
+
Same changes as in `@mui/x-data-grid-pro@7.18.0`.
|
|
44
|
+
|
|
45
|
+
### Date and Time Pickers
|
|
46
|
+
|
|
47
|
+
#### `@mui/x-date-pickers@7.18.0`
|
|
48
|
+
|
|
49
|
+
- [pickers] Add option to change the order of displayed years (#11780) @thomasmoon
|
|
50
|
+
- [pickers] Support `date-fns` v4 (#14673) @LukasTy
|
|
51
|
+
|
|
52
|
+
#### `@mui/x-date-pickers-pro@7.18.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
53
|
+
|
|
54
|
+
Same changes as in `@mui/x-date-pickers@7.18.0`.
|
|
55
|
+
|
|
56
|
+
### Charts
|
|
57
|
+
|
|
58
|
+
#### `@mui/x-charts@7.18.0`
|
|
59
|
+
|
|
60
|
+
- [charts] Add a `PolarProvider` to manage polar axes (#14642) @alexfauquette
|
|
61
|
+
- [charts] Fix `LineChart` animation being stuck with initial drawing area value (#14553) @JCQuintas
|
|
62
|
+
- [charts] Fix legend slot typing (#14657) @alexfauquette
|
|
63
|
+
- [charts] Pass the axis index to extremum getter (#14641) @alexfauquette
|
|
64
|
+
- [charts] Provide hooks to create custom tooltip (#14377) @alexfauquette
|
|
65
|
+
|
|
66
|
+
#### `@mui/x-charts-pro@7.0.0-beta.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
67
|
+
|
|
68
|
+
Same changes as in `@mui/x-charts@7.18.0`.
|
|
69
|
+
|
|
70
|
+
### Tree View
|
|
71
|
+
|
|
72
|
+
#### `@mui/x-tree-view@7.18.0`
|
|
73
|
+
|
|
74
|
+
- [TreeView] Add `"use client"` directive to every public component and hook (#14579) @flaviendelangle
|
|
75
|
+
|
|
76
|
+
### Docs
|
|
77
|
+
|
|
78
|
+
- [docs] Add `groupingValueGetter` callout in column definition docs (#14599) @michelengelen
|
|
79
|
+
- [docs] Clean v6 => v7 migration guide (#14652) @flaviendelangle
|
|
80
|
+
- [docs] Copy `vale-action.yml` from main repo @oliviertassinari
|
|
81
|
+
- [docs] Edit the Pickers Getting started doc (#14555) @samuelsycamore
|
|
82
|
+
- [docs] Fix TypeScript capitalization @oliviertassinari
|
|
83
|
+
- [docs] Fix Vale error @oliviertassinari
|
|
84
|
+
- [docs] Make the migration guide diff a bit easier to read @oliviertassinari
|
|
85
|
+
- [docs] Report Vale at warning level (#14660) @oliviertassinari
|
|
86
|
+
- [docs] Warn about the `valueGetter` and `valueFormatter` signature change (#14613) @cherniavskii
|
|
87
|
+
- [docs] Polish code formatting (#14603) @oliviertassinari
|
|
88
|
+
- [test] Spy on `observe` method to avoid flaky wait for a callback (#14640) @arminmeh
|
|
89
|
+
|
|
90
|
+
### Core
|
|
91
|
+
|
|
92
|
+
- [core] Fix 301 link to Next.js and git diff @oliviertassinari
|
|
93
|
+
- [core] Fix failing CI on `master` (#14644) @cherniavskii
|
|
94
|
+
- [core] Fix `package.json` repository rule @oliviertassinari
|
|
95
|
+
- [core] MUI X repository moved to a new location @oliviertassinari
|
|
96
|
+
- [docs-infra] Strengthen CSP (#14581) @oliviertassinari
|
|
97
|
+
- [license] Finish renaming of LicensingModel (#14615) @oliviertassinari
|
|
98
|
+
|
|
6
99
|
## 7.17.0
|
|
7
100
|
|
|
8
101
|
_Sep 13, 2024_
|
|
@@ -75,7 +168,7 @@ Same changes as in `@mui/x-charts@7.17.0`.
|
|
|
75
168
|
### Docs
|
|
76
169
|
|
|
77
170
|
- [docs] Add missing callout on "Imperative API" tree view sections (#14503) @flaviendelangle
|
|
78
|
-
- [docs] Fix broken redirection to MUI
|
|
171
|
+
- [docs] Fix broken redirection to MUI X v5 @oliviertassinari
|
|
79
172
|
- [docs] Fix multiple `console.error` messages on `charts` docs (#14554) @JCQuintas
|
|
80
173
|
- [docs] Fixed typo in Row Grouping recipes (#14549) @Miodini
|
|
81
174
|
- [docs] Match title with blog posts @oliviertassinari
|
|
@@ -195,7 +288,7 @@ We'd like to offer a big thanks to the 8 contributors who made this release poss
|
|
|
195
288
|
|
|
196
289
|
- 💫 Support Material UI v6 (`@mui/material@6`) peer dependency (#14142) @cherniavskii
|
|
197
290
|
|
|
198
|
-
You can now use MUI
|
|
291
|
+
You can now use MUI X components with either v5 or v6 of `@mui/material` package 🎉
|
|
199
292
|
|
|
200
293
|
- 🐞 Bugfixes
|
|
201
294
|
|
|
@@ -240,7 +333,7 @@ Same changes as in `@mui/x-charts@7.15.0`, plus:
|
|
|
240
333
|
|
|
241
334
|
- [docs] Fix sentence case `h2` @oliviertassinari
|
|
242
335
|
- [docs] Clarify contribution guide references @oliviertassinari
|
|
243
|
-
- [docs] Fix Stack
|
|
336
|
+
- [docs] Fix Stack Overflow issue canned response @oliviertassinari
|
|
244
337
|
- [docs] Fix outdated link to support page @oliviertassinari
|
|
245
338
|
- [docs] Fix use of Material UI @oliviertassinari
|
|
246
339
|
- [docs] Update deprecated props in docs (#14295) @JCQuintas
|
|
@@ -498,7 +591,7 @@ The [Pro plan](https://mui.com/x/introduction/licensing/#pro-plan) is receiving
|
|
|
498
591
|
|
|
499
592
|
As always, every feature released as part of the MIT plan will remain free and MIT licensed forever.
|
|
500
593
|
|
|
501
|
-
This expansion of the Pro plan comes with some adjustments to our pricing strategy. Learn more about those in the [Upcoming changes to MUI
|
|
594
|
+
This expansion of the Pro plan comes with some adjustments to our pricing strategy. Learn more about those in the [Upcoming changes to MUI X pricing in 2024](https://mui.com/blog/mui-x-sep-2024-price-update/) blog post.
|
|
502
595
|
|
|
503
596
|
### Highlights
|
|
504
597
|
|
|
@@ -563,7 +656,7 @@ Same changes as in `@mui/x-date-pickers@7.12.0`.
|
|
|
563
656
|
#### `@mui/x-charts@7.12.0`
|
|
564
657
|
|
|
565
658
|
- [charts] Fix incorrect `axisId` prop being allowed in xAxis/yAxis config. Use `id` instead. (#13986) @JCQuintas
|
|
566
|
-
- [charts] Use vendor to have
|
|
659
|
+
- [charts] Use vendor to have CommonJS bundle working out of the box (#13608) @alexfauquette
|
|
567
660
|
- [charts] Divide the `SeriesProvider` to use in filtering (#14026) @JCQuintas
|
|
568
661
|
|
|
569
662
|
### Tree View
|
|
@@ -7,10 +7,10 @@ export interface ChartsLegendSlots {
|
|
|
7
7
|
* Custom rendering of the legend.
|
|
8
8
|
* @default DefaultChartsLegend
|
|
9
9
|
*/
|
|
10
|
-
legend?: React.JSXElementConstructor<
|
|
10
|
+
legend?: React.JSXElementConstructor<LegendRendererProps>;
|
|
11
11
|
}
|
|
12
12
|
export interface ChartsLegendSlotProps {
|
|
13
|
-
legend?: Partial<
|
|
13
|
+
legend?: Partial<LegendRendererProps>;
|
|
14
14
|
}
|
|
15
15
|
export interface ChartsLegendProps extends ChartsLegendPropsBase {
|
|
16
16
|
/**
|
package/ChartsTooltip/index.d.ts
CHANGED
|
@@ -5,3 +5,6 @@ export * from './ChartsItemTooltipContent';
|
|
|
5
5
|
export * from './DefaultChartsAxisTooltipContent';
|
|
6
6
|
export * from './DefaultChartsItemTooltipContent';
|
|
7
7
|
export * from './ChartsTooltipTable';
|
|
8
|
+
export * from './useItemTooltip';
|
|
9
|
+
export * from './useAxisTooltip';
|
|
10
|
+
export { useMouseTracker } from './utils';
|
package/ChartsTooltip/index.js
CHANGED
|
@@ -4,4 +4,7 @@ export * from "./ChartsAxisTooltipContent.js";
|
|
|
4
4
|
export * from "./ChartsItemTooltipContent.js";
|
|
5
5
|
export * from "./DefaultChartsAxisTooltipContent.js";
|
|
6
6
|
export * from "./DefaultChartsItemTooltipContent.js";
|
|
7
|
-
export * from "./ChartsTooltipTable.js";
|
|
7
|
+
export * from "./ChartsTooltipTable.js";
|
|
8
|
+
export * from "./useItemTooltip.js";
|
|
9
|
+
export * from "./useAxisTooltip.js";
|
|
10
|
+
export { useMouseTracker } from "./utils.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxisInteractionData } from '../context/InteractionProvider';
|
|
2
|
+
import { SeriesId } from '../models/seriesType/common';
|
|
3
|
+
import { CartesianChartSeriesType, ChartsSeriesConfig } from '../models/seriesType/config';
|
|
4
|
+
export interface UseAxisTooltipReturnValue<SeriesT extends CartesianChartSeriesType = CartesianChartSeriesType, AxisValueT extends string | number | Date = string | number | Date> {
|
|
5
|
+
identifier: AxisInteractionData;
|
|
6
|
+
seriesItems: SeriesItem<SeriesT>[];
|
|
7
|
+
axisValue: AxisValueT;
|
|
8
|
+
axisFormattedValue: string;
|
|
9
|
+
}
|
|
10
|
+
interface SeriesItem<T extends CartesianChartSeriesType> {
|
|
11
|
+
seriesId: SeriesId;
|
|
12
|
+
color: string;
|
|
13
|
+
value: ChartsSeriesConfig[T]['valueType'];
|
|
14
|
+
formattedValue: string;
|
|
15
|
+
formattedLabel: string | null;
|
|
16
|
+
}
|
|
17
|
+
export declare function useAxisTooltip(): null | UseAxisTooltipReturnValue;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
5
|
+
import { useSeries } from "../hooks/useSeries.js";
|
|
6
|
+
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
7
|
+
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
8
|
+
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
9
|
+
import { getLabel } from "../internals/getLabel.js";
|
|
10
|
+
import { isCartesianSeriesType } from "../internals/isCartesian.js";
|
|
11
|
+
import { utcFormatter } from "./utils.js";
|
|
12
|
+
export function useAxisTooltip() {
|
|
13
|
+
const {
|
|
14
|
+
axis
|
|
15
|
+
} = React.useContext(InteractionContext);
|
|
16
|
+
const series = useSeries();
|
|
17
|
+
const {
|
|
18
|
+
xAxis,
|
|
19
|
+
yAxis,
|
|
20
|
+
xAxisIds,
|
|
21
|
+
yAxisIds
|
|
22
|
+
} = useCartesianContext();
|
|
23
|
+
const {
|
|
24
|
+
zAxis,
|
|
25
|
+
zAxisIds
|
|
26
|
+
} = React.useContext(ZAxisContext);
|
|
27
|
+
const colorProcessors = useColorProcessor();
|
|
28
|
+
|
|
29
|
+
// By default use the x-axis
|
|
30
|
+
const isXaxis = axis.x !== null && axis.x.index !== -1;
|
|
31
|
+
const axisData = isXaxis ? axis.x && axis.x : axis.y && axis.y;
|
|
32
|
+
if (axisData === null) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const {
|
|
36
|
+
index: dataIndex,
|
|
37
|
+
value: axisValue
|
|
38
|
+
} = axisData;
|
|
39
|
+
const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
|
|
40
|
+
const usedAxis = isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
|
|
41
|
+
const relevantSeries = Object.keys(series).filter(isCartesianSeriesType).flatMap(seriesType => {
|
|
42
|
+
const seriesOfType = series[seriesType];
|
|
43
|
+
if (!seriesOfType) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return seriesOfType.seriesOrder.map(seriesId => {
|
|
47
|
+
const seriesToAdd = seriesOfType.series[seriesId];
|
|
48
|
+
const providedXAxisId = seriesToAdd.xAxisId ?? seriesToAdd.xAxisKey;
|
|
49
|
+
const providedYAxisId = seriesToAdd.yAxisId ?? seriesToAdd.yAxisKey;
|
|
50
|
+
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
51
|
+
|
|
52
|
+
// Test if the series uses the default axis
|
|
53
|
+
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
54
|
+
const xAxisId = providedXAxisId ?? xAxisIds[0];
|
|
55
|
+
const yAxisId = providedYAxisId ?? yAxisIds[0];
|
|
56
|
+
const zAxisId = seriesToAdd.zAxisId ?? seriesToAdd.zAxisKey ?? zAxisIds[0];
|
|
57
|
+
const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId])(dataIndex) ?? '';
|
|
58
|
+
const value = seriesToAdd.data[dataIndex] ?? null;
|
|
59
|
+
const formattedValue = seriesToAdd.valueFormatter(value, {
|
|
60
|
+
dataIndex
|
|
61
|
+
});
|
|
62
|
+
const formattedLabel = getLabel(seriesToAdd.label, 'tooltip') ?? null;
|
|
63
|
+
return {
|
|
64
|
+
seriesId,
|
|
65
|
+
color,
|
|
66
|
+
value,
|
|
67
|
+
formattedValue,
|
|
68
|
+
formattedLabel
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
});
|
|
73
|
+
}).filter(item => item != null);
|
|
74
|
+
const axisFormatter = usedAxis.valueFormatter ?? (v => usedAxis.scaleType === 'utc' ? utcFormatter(v) : v.toLocaleString());
|
|
75
|
+
const axisFormattedValue = axisFormatter(axisValue, {
|
|
76
|
+
location: 'tooltip'
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
identifier: axis,
|
|
80
|
+
seriesItems: relevantSeries,
|
|
81
|
+
axisValue,
|
|
82
|
+
axisFormattedValue
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ItemInteractionData } from '../context/InteractionProvider';
|
|
2
|
+
import { ChartSeriesType, ChartsSeriesConfig } from '../models/seriesType/config';
|
|
3
|
+
export interface UseItemTooltipReturnValue<T extends ChartSeriesType> {
|
|
4
|
+
identifier: ItemInteractionData<T>;
|
|
5
|
+
color: string;
|
|
6
|
+
label: string | undefined;
|
|
7
|
+
value: ChartsSeriesConfig[T]['valueType'];
|
|
8
|
+
formattedValue: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function useItemTooltip<T extends ChartSeriesType>(): null | UseItemTooltipReturnValue<T>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
6
|
+
import { useSeries } from "../hooks/useSeries.js";
|
|
7
|
+
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
8
|
+
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
9
|
+
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
10
|
+
import { getLabel } from "../internals/getLabel.js";
|
|
11
|
+
export function useItemTooltip() {
|
|
12
|
+
const {
|
|
13
|
+
item
|
|
14
|
+
} = React.useContext(InteractionContext);
|
|
15
|
+
const series = useSeries();
|
|
16
|
+
const {
|
|
17
|
+
xAxis,
|
|
18
|
+
yAxis,
|
|
19
|
+
xAxisIds,
|
|
20
|
+
yAxisIds
|
|
21
|
+
} = useCartesianContext();
|
|
22
|
+
const {
|
|
23
|
+
zAxis,
|
|
24
|
+
zAxisIds
|
|
25
|
+
} = React.useContext(ZAxisContext);
|
|
26
|
+
const colorProcessors = useColorProcessor();
|
|
27
|
+
const xAxisId = series.xAxisId ?? series.xAxisKey ?? xAxisIds[0];
|
|
28
|
+
const yAxisId = series.yAxisId ?? series.yAxisKey ?? yAxisIds[0];
|
|
29
|
+
const zAxisId = series.zAxisId ?? series.zAxisKey ?? zAxisIds[0];
|
|
30
|
+
if (!item || item.dataIndex === undefined) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const itemSeries = series[item.type].series[item.seriesId];
|
|
34
|
+
const getColor = colorProcessors[itemSeries.type]?.(itemSeries, xAxisId && xAxis[xAxisId], yAxisId && yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
35
|
+
if (itemSeries.type === 'pie') {
|
|
36
|
+
const point = itemSeries.data[item.dataIndex];
|
|
37
|
+
const label = getLabel(point.label, 'tooltip');
|
|
38
|
+
const value = _extends({}, point, {
|
|
39
|
+
label
|
|
40
|
+
});
|
|
41
|
+
const formattedValue = itemSeries.valueFormatter?.(value, {
|
|
42
|
+
dataIndex: item.dataIndex
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
identifier: item,
|
|
46
|
+
color: getColor(item.dataIndex),
|
|
47
|
+
label,
|
|
48
|
+
value,
|
|
49
|
+
formattedValue
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const label = getLabel(itemSeries.label, 'tooltip');
|
|
53
|
+
const value = itemSeries.data[item.dataIndex];
|
|
54
|
+
const formattedValue = itemSeries.valueFormatter?.(value, {
|
|
55
|
+
dataIndex: item.dataIndex
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
identifier: item,
|
|
59
|
+
color: getColor(item.dataIndex),
|
|
60
|
+
label,
|
|
61
|
+
value,
|
|
62
|
+
formattedValue
|
|
63
|
+
};
|
|
64
|
+
}
|
package/ChartsTooltip/utils.d.ts
CHANGED
|
@@ -19,7 +19,8 @@ export declare function generateVirtualElement(mousePosition: MousePosition | nu
|
|
|
19
19
|
toJSON: () => string;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type UseMouseTrackerReturnValue = null | MousePosition;
|
|
23
|
+
export declare function useMouseTracker(): UseMouseTrackerReturnValue;
|
|
23
24
|
export type TriggerOptions = 'item' | 'axis' | 'none';
|
|
24
25
|
export declare function getTooltipHasData(trigger: TriggerOptions, displayedData: null | AxisInteractionData | ItemInteractionData<ChartSeriesType>): boolean;
|
|
25
26
|
export declare function utcFormatter(v: string | number | Date): string;
|
|
@@ -44,29 +44,19 @@ function AnimatedLine(props) {
|
|
|
44
44
|
ownerState
|
|
45
45
|
} = props,
|
|
46
46
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
47
|
-
const
|
|
48
|
-
left,
|
|
49
|
-
top,
|
|
50
|
-
bottom,
|
|
51
|
-
width,
|
|
52
|
-
height,
|
|
53
|
-
right
|
|
54
|
-
} = useDrawingArea();
|
|
47
|
+
const drawingArea = useDrawingArea();
|
|
55
48
|
const chartId = useChartId();
|
|
56
49
|
const stringInterpolator = useStringInterpolator(d);
|
|
57
|
-
const transitionAppear = useTransition([
|
|
58
|
-
from: {
|
|
59
|
-
animatedWidth: left
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
animatedWidth: width + left + right
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
animatedWidth: width + left + right
|
|
66
|
-
},
|
|
67
|
-
leave: {
|
|
68
|
-
animatedWidth: left
|
|
69
|
-
},
|
|
50
|
+
const transitionAppear = useTransition([drawingArea], {
|
|
51
|
+
from: v => ({
|
|
52
|
+
animatedWidth: v.left
|
|
53
|
+
}),
|
|
54
|
+
enter: v => ({
|
|
55
|
+
animatedWidth: v.width + v.left + v.right
|
|
56
|
+
}),
|
|
57
|
+
leave: v => ({
|
|
58
|
+
animatedWidth: v.width + v.left + v.right
|
|
59
|
+
}),
|
|
70
60
|
reset: false,
|
|
71
61
|
immediate: skipAnimation
|
|
72
62
|
});
|
|
@@ -91,7 +81,7 @@ function AnimatedLine(props) {
|
|
|
91
81
|
x: 0,
|
|
92
82
|
y: 0,
|
|
93
83
|
width: style.animatedWidth,
|
|
94
|
-
height: top + height + bottom
|
|
84
|
+
height: drawingArea.top + drawingArea.height + drawingArea.bottom
|
|
95
85
|
}))
|
|
96
86
|
}), /*#__PURE__*/_jsx("g", {
|
|
97
87
|
clipPath: `url(#${clipId})`,
|
package/LineChart/LineChart.js
CHANGED
|
@@ -200,6 +200,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
200
200
|
* Callback fired when a mark element is clicked.
|
|
201
201
|
*/
|
|
202
202
|
onMarkClick: PropTypes.func,
|
|
203
|
+
/**
|
|
204
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
205
|
+
* before it renders for the first time.
|
|
206
|
+
*
|
|
207
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
208
|
+
* the first render, like when used inside a grid.
|
|
209
|
+
*
|
|
210
|
+
* @default false
|
|
211
|
+
*/
|
|
212
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
203
213
|
/**
|
|
204
214
|
* Indicate which axis to display the right of the charts.
|
|
205
215
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
package/PieChart/PieChart.js
CHANGED
|
@@ -240,6 +240,16 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
240
240
|
* Callback fired when a pie arc is clicked.
|
|
241
241
|
*/
|
|
242
242
|
onItemClick: PropTypes.func,
|
|
243
|
+
/**
|
|
244
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
245
|
+
* before it renders for the first time.
|
|
246
|
+
*
|
|
247
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
248
|
+
* the first render, like when used inside a grid.
|
|
249
|
+
*
|
|
250
|
+
* @default false
|
|
251
|
+
*/
|
|
252
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
243
253
|
/**
|
|
244
254
|
* Indicate which axis to display the right of the charts.
|
|
245
255
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -9,6 +9,16 @@ export interface ResponsiveChartContainerProps extends Omit<ChartContainerProps,
|
|
|
9
9
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
10
10
|
*/
|
|
11
11
|
height?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
14
|
+
* before it renders for the first time.
|
|
15
|
+
*
|
|
16
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
17
|
+
* the first render, like when used inside a grid.
|
|
18
|
+
*
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
resolveSizeBeforeRender?: boolean;
|
|
12
22
|
}
|
|
13
23
|
declare const ResponsiveChartContainer: React.ForwardRefExoticComponent<ResponsiveChartContainerProps & React.RefAttributes<unknown>>;
|
|
14
24
|
export { ResponsiveChartContainer };
|
|
@@ -74,6 +74,16 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
74
74
|
* If not provided, the container supports line, bar, scatter and pie charts.
|
|
75
75
|
*/
|
|
76
76
|
plugins: PropTypes.arrayOf(PropTypes.object),
|
|
77
|
+
/**
|
|
78
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
79
|
+
* before it renders for the first time.
|
|
80
|
+
*
|
|
81
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
82
|
+
* the first render, like when used inside a grid.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
77
87
|
/**
|
|
78
88
|
* The array of series to display.
|
|
79
89
|
* Each type of series has its own specificity.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number) => {
|
|
2
|
+
export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number, resolveSizeBeforeRender?: boolean) => {
|
|
3
3
|
containerRef: React.MutableRefObject<null>;
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import ownerWindow from '@mui/utils/ownerWindow';
|
|
6
|
-
export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
7
|
-
const
|
|
6
|
+
export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
|
|
7
|
+
const stateRef = React.useRef({
|
|
8
|
+
displayError: false,
|
|
9
|
+
initialCompute: true,
|
|
10
|
+
computeRun: 0
|
|
11
|
+
});
|
|
8
12
|
const rootRef = React.useRef(null);
|
|
9
13
|
const [width, setWidth] = React.useState(0);
|
|
10
14
|
const [height, setHeight] = React.useState(0);
|
|
@@ -13,7 +17,7 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
13
17
|
const computeSize = React.useCallback(() => {
|
|
14
18
|
const mainEl = rootRef?.current;
|
|
15
19
|
if (!mainEl) {
|
|
16
|
-
return;
|
|
20
|
+
return {};
|
|
17
21
|
}
|
|
18
22
|
const win = ownerWindow(mainEl);
|
|
19
23
|
const computedStyle = win.getComputedStyle(mainEl);
|
|
@@ -21,11 +25,31 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
21
25
|
const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
22
26
|
setWidth(newWidth);
|
|
23
27
|
setHeight(newHeight);
|
|
28
|
+
return {
|
|
29
|
+
width: newWidth,
|
|
30
|
+
height: newHeight
|
|
31
|
+
};
|
|
24
32
|
}, []);
|
|
25
33
|
React.useEffect(() => {
|
|
26
34
|
// Ensure the error detection occurs after the first rendering.
|
|
27
|
-
|
|
35
|
+
stateRef.current.displayError = true;
|
|
28
36
|
}, []);
|
|
37
|
+
|
|
38
|
+
// This effect is used to compute the size of the container on the initial render.
|
|
39
|
+
// It is not bound to the raf loop to avoid an unwanted "resize" event.
|
|
40
|
+
// https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
|
|
41
|
+
useEnhancedEffect(() => {
|
|
42
|
+
// computeRun is used to avoid infinite loops.
|
|
43
|
+
if (!resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const computedSize = computeSize();
|
|
47
|
+
if (computedSize.width !== width || computedSize.height !== height) {
|
|
48
|
+
stateRef.current.computeRun += 1;
|
|
49
|
+
} else if (stateRef.current.initialCompute) {
|
|
50
|
+
stateRef.current.initialCompute = false;
|
|
51
|
+
}
|
|
52
|
+
}, [width, height, computeSize, resolveSizeBeforeRender]);
|
|
29
53
|
useEnhancedEffect(() => {
|
|
30
54
|
if (inWidth !== undefined && inHeight !== undefined) {
|
|
31
55
|
return () => {};
|
|
@@ -55,13 +79,13 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
55
79
|
};
|
|
56
80
|
}, [computeSize, inHeight, inWidth]);
|
|
57
81
|
if (process.env.NODE_ENV !== 'production') {
|
|
58
|
-
if (
|
|
82
|
+
if (stateRef.current.displayError && inWidth === undefined && width === 0) {
|
|
59
83
|
console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
60
|
-
|
|
84
|
+
stateRef.current.displayError = false;
|
|
61
85
|
}
|
|
62
|
-
if (
|
|
86
|
+
if (stateRef.current.displayError && inHeight === undefined && height === 0) {
|
|
63
87
|
console.error(`MUI X: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
|
|
64
|
-
|
|
88
|
+
stateRef.current.displayError = false;
|
|
65
89
|
}
|
|
66
90
|
}
|
|
67
91
|
return {
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
|
|
5
|
+
const _excluded = ["width", "height", "resolveSizeBeforeRender", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
|
|
6
6
|
import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
|
|
7
7
|
export const useResponsiveChartContainerProps = (props, ref) => {
|
|
8
8
|
const {
|
|
9
9
|
width,
|
|
10
10
|
height,
|
|
11
|
+
resolveSizeBeforeRender,
|
|
11
12
|
margin,
|
|
12
13
|
children,
|
|
13
14
|
series,
|
|
@@ -30,7 +31,7 @@ export const useResponsiveChartContainerProps = (props, ref) => {
|
|
|
30
31
|
containerRef,
|
|
31
32
|
width: dWidth,
|
|
32
33
|
height: dHeight
|
|
33
|
-
} = useChartContainerDimensions(width, height);
|
|
34
|
+
} = useChartContainerDimensions(width, height, resolveSizeBeforeRender);
|
|
34
35
|
const resizableChartContainerProps = _extends({}, other, {
|
|
35
36
|
ownerState: {
|
|
36
37
|
width,
|
|
@@ -177,6 +177,16 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
177
177
|
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
178
178
|
*/
|
|
179
179
|
onItemClick: PropTypes.func,
|
|
180
|
+
/**
|
|
181
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
182
|
+
* before it renders for the first time.
|
|
183
|
+
*
|
|
184
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
185
|
+
* the first render, like when used inside a grid.
|
|
186
|
+
*
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
180
190
|
/**
|
|
181
191
|
* Indicate which axis to display the right of the charts.
|
|
182
192
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -193,6 +193,16 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
193
193
|
* @default 'line'
|
|
194
194
|
*/
|
|
195
195
|
plotType: PropTypes.oneOf(['bar', 'line']),
|
|
196
|
+
/**
|
|
197
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
198
|
+
* before it renders for the first time.
|
|
199
|
+
*
|
|
200
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
201
|
+
* the first render, like when used inside a grid.
|
|
202
|
+
*
|
|
203
|
+
* @default false
|
|
204
|
+
*/
|
|
205
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
196
206
|
/**
|
|
197
207
|
* Set to `true` to highlight the value.
|
|
198
208
|
* With line, it shows a point.
|