@mui/x-charts 7.1.0 → 7.2.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/extremums.js +1 -1
- package/CHANGELOG.md +261 -4
- package/ChartsTooltip/ChartsTooltip.d.ts +8 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +2 -2
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +15 -16
- package/ChartsXAxis/ChartsXAxis.js +5 -5
- package/ChartsYAxis/ChartsYAxis.js +10 -5
- package/esm/BarChart/extremums.js +1 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +15 -16
- package/esm/ChartsXAxis/ChartsXAxis.js +5 -5
- package/esm/ChartsYAxis/ChartsYAxis.js +10 -5
- package/hooks/useTicks.d.ts +1 -1
- package/index.js +1 -1
- package/modern/BarChart/extremums.js +1 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +15 -16
- package/modern/ChartsXAxis/ChartsXAxis.js +5 -5
- package/modern/ChartsYAxis/ChartsYAxis.js +10 -5
- package/modern/index.js +1 -1
- package/package.json +2 -2
package/BarChart/extremums.js
CHANGED
|
@@ -19,7 +19,7 @@ const getValueExtremum = params => {
|
|
|
19
19
|
isDefaultAxis
|
|
20
20
|
} = params;
|
|
21
21
|
return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
|
|
22
|
-
const [seriesMin, seriesMax] = series[seriesId].stackedData
|
|
22
|
+
const [seriesMin, seriesMax] = series[seriesId].stackedData?.reduce((seriesAcc, values) => [Math.min(...values, ...(seriesAcc[0] === null ? [] : [seriesAcc[0]])), Math.max(...values, ...(seriesAcc[1] === null ? [] : [seriesAcc[1]]))], series[seriesId].stackedData[0]) ?? [null, null];
|
|
23
23
|
return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
|
|
24
24
|
}, [null, null]);
|
|
25
25
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,193 @@
|
|
|
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.2.0
|
|
7
|
+
|
|
8
|
+
_Apr 12, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎨 Make grid colors customizable through the MUI themes API
|
|
13
|
+
- 🌍 Improve French (fr-FR), German (de-DE), and Swedish (sv-SE) locales on the Data Grid and Pickers
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
### Data Grid
|
|
18
|
+
|
|
19
|
+
#### `@mui/x-data-grid@7.2.0`
|
|
20
|
+
|
|
21
|
+
- [DataGrid] Add missing `api` property to `GridCallbackDetails` (#12742) @sai6855
|
|
22
|
+
- [DataGrid] Do not escape double quotes when copying to clipboard (#12722) @cherniavskii
|
|
23
|
+
- [DataGrid] Fix column vertical border (#12741) @romgrk
|
|
24
|
+
- [DataGrid] Fix invalid date error when filtering `date`/`dateTime` columns (#12709) @cherniavskii
|
|
25
|
+
- [DataGrid] Fix overflow with dynamic row height (#12683) @romgrk
|
|
26
|
+
- [DataGrid] Make colors customizable (#12614) @romgrk
|
|
27
|
+
- [l10n] Improve French (fr-FR) locale (#12755) @derek-0000
|
|
28
|
+
- [l10n] Improve German (de-DE) locale (#12752) @Jens-Schoen
|
|
29
|
+
- [l10n] Improve Swedish (sv-SE) locale (#12731) @pontusdacke
|
|
30
|
+
|
|
31
|
+
#### `@mui/x-data-grid-pro@7.2.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
32
|
+
|
|
33
|
+
Same changes as in `@mui/x-data-grid@7.2.0`.
|
|
34
|
+
|
|
35
|
+
#### `@mui/x-data-grid-premium@7.2.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
36
|
+
|
|
37
|
+
Same changes as in `@mui/x-data-grid-pro@7.2.0`, plus:
|
|
38
|
+
|
|
39
|
+
- [DataGridPremium] Fix clipboard paste not working when cell loses focus (#12724) @cherniavskii
|
|
40
|
+
|
|
41
|
+
### Date and Time Pickers
|
|
42
|
+
|
|
43
|
+
#### `@mui/x-date-pickers@7.2.0`
|
|
44
|
+
|
|
45
|
+
- [fields] Fix field editing after closing the picker (#12675) @LukasTy
|
|
46
|
+
- [l10n] Improve French (fr-FR) locale (#12692) @FaroukBel
|
|
47
|
+
- [l10n] Improve German (de-DE) locale (#12752) @Jens-Schoen
|
|
48
|
+
- [l10n] Improve Swedish (sv-SE) locale (#12731) @pontusdacke
|
|
49
|
+
- [pickers] Fix desktop date time Pickers grid layout (#12748) @LukasTy
|
|
50
|
+
|
|
51
|
+
#### `@mui/x-date-pickers-pro@7.2.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
52
|
+
|
|
53
|
+
Same changes as in `@mui/x-date-pickers@7.2.0`, plus:
|
|
54
|
+
|
|
55
|
+
- [DateTimeRangePicker] Fix desktop toolbar style (#12760) @LukasTy
|
|
56
|
+
|
|
57
|
+
### Charts
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-charts@7.2.0`
|
|
60
|
+
|
|
61
|
+
- [charts] Fix Bar chart with empty dataset throwing an error (#12708) @JCQuintas
|
|
62
|
+
- [charts] Fix `tickLabelInterval` not working on `YAxis` (#12746) @JCQuintas
|
|
63
|
+
|
|
64
|
+
### Tree View
|
|
65
|
+
|
|
66
|
+
#### `@mui/x-tree-view@7.2.0`
|
|
67
|
+
|
|
68
|
+
- [TreeView] Add a new lookup to access an item index without expansive computation (#12729) @flaviendelangle
|
|
69
|
+
- [TreeView] Clean up usage of term "node" in internals (#12655) @noraleonte
|
|
70
|
+
- [TreeView] Improve performance by removing `getNavigableChildrenIds` method (#12713) @flaviendelangle
|
|
71
|
+
- [TreeView] Remove `state.items.itemTree` (#12717) @flaviendelangle
|
|
72
|
+
- [TreeView] Remove remaining occurences of the word "node" in the codebase (#12712) @flaviendelangle
|
|
73
|
+
- [TreeView] Return `instance` and `publicAPI` methods from plugin and populate the main objects inside `useTreeView` (#12650) @flaviendelangle
|
|
74
|
+
- [TreeView] Fix behaviors when the item order changes (#12369) @flaviendelangle
|
|
75
|
+
|
|
76
|
+
### Docs
|
|
77
|
+
|
|
78
|
+
- [docs] Add `AxisFormatter` documentation for customizing tick/tooltip value formatting (#12700) @JCQuintas
|
|
79
|
+
- [docs] Add file explorer example to rich tree view customization docs (#12707) @noraleonte
|
|
80
|
+
- [docs] Do not use import of depth 3 in the doc (#12716) @flaviendelangle
|
|
81
|
+
- [docs] Explain how to clip plots with composition (#12679) @alexfauquette
|
|
82
|
+
- [docs] Fix typo in Data Grid v7 migration page (#12720) @bfaulk96
|
|
83
|
+
- [docs] Fix typo in Pickers v7 migration page (#12721) @bfaulk96
|
|
84
|
+
|
|
85
|
+
### Core
|
|
86
|
+
|
|
87
|
+
- [core] Support multiple resolved `l10n` PR packages (#12735) @LukasTy
|
|
88
|
+
- [core] Update Netlify release references in release README (#12687) @LukasTy
|
|
89
|
+
- [core] Use `describeTreeView` for icons tests (#12672) @flaviendelangle
|
|
90
|
+
- [core] Use `describeTreeView` in existing tests for `useTreeViewItems` (#12732) @flaviendelangle
|
|
91
|
+
|
|
92
|
+
## 7.1.1
|
|
93
|
+
|
|
94
|
+
_Apr 5, 2024_
|
|
95
|
+
|
|
96
|
+
We'd like to offer a big thanks to the 19 contributors who made this release possible. Here are some highlights ✨:
|
|
97
|
+
|
|
98
|
+
- 🚀 Add `setItemExpansion` Tree View API method (#12595) @flaviendelangle
|
|
99
|
+
- 🌍 Improve Persian (fa-IR), Portuguese (pt-BR), and Spanish (es-ES) locale on the Data Grid
|
|
100
|
+
- 🌍 Improve Persian (fa-IR), Portuguese (pt-BR), and Ukrainian (uk-UA) locale on the Pickers
|
|
101
|
+
- 🐞 Bugfixes
|
|
102
|
+
- 📚 Documentation improvements
|
|
103
|
+
|
|
104
|
+
### Data Grid
|
|
105
|
+
|
|
106
|
+
#### `@mui/x-data-grid@7.1.1`
|
|
107
|
+
|
|
108
|
+
- [DataGrid] Allow higher packages' props to be used in MIT (#12365) @MBilalShafi
|
|
109
|
+
- [DataGrid] Fix RTL mode (#12583) @romgrk
|
|
110
|
+
- [DataGrid] Fix `ColDefChangesGridNoSnap` demo crash (#12663) @MBilalShafi
|
|
111
|
+
- [DataGrid] Fix server-side filter demo not working (#12662) @MBilalShafi
|
|
112
|
+
- [DataGrid] Log error if `rowCount` is used with client-side pagination (#12448) @michelengelen
|
|
113
|
+
- [DataGrid] Remove `GridFormatterParams` completely (#12660) @romgrk
|
|
114
|
+
- [DataGrid] Restore main slot (#12657) @romgrk
|
|
115
|
+
- [l10n] Improve Persian (fa-IR) locale (#12630) @amirhosseinzf
|
|
116
|
+
- [l10n] Improve Portuguese (pt-BR) locale (#12618) @hugoalkimim
|
|
117
|
+
- [l10n] Improve Spanish (es-ES) locale (#12606) @aitor40
|
|
118
|
+
|
|
119
|
+
#### `@mui/x-data-grid-pro@7.1.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
120
|
+
|
|
121
|
+
Same changes as in `@mui/x-data-grid@7.1.1`.
|
|
122
|
+
|
|
123
|
+
#### `@mui/x-data-grid-premium@7.1.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
124
|
+
|
|
125
|
+
Same changes as in `@mui/x-data-grid-pro@7.1.1`.
|
|
126
|
+
|
|
127
|
+
### Date and Time Pickers
|
|
128
|
+
|
|
129
|
+
#### `@mui/x-date-pickers@7.1.1`
|
|
130
|
+
|
|
131
|
+
- [fields] Fix `readOnly` behavior (#12609) @LukasTy
|
|
132
|
+
- [l10n] Improve Persian (fa-IR) locale (#12632) @misafari
|
|
133
|
+
- [l10n] Improve Portuguese (pt-BR) locale (#12613) @cnHealth
|
|
134
|
+
- [l10n] Improve Ukrainian (uk-UA) locale (#12627) @alexkobylansky
|
|
135
|
+
|
|
136
|
+
#### `@mui/x-date-pickers-pro@7.1.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
137
|
+
|
|
138
|
+
Same changes as in `@mui/x-date-pickers@7.1.1`, plus:
|
|
139
|
+
|
|
140
|
+
- [DateTimeRangePicker] Fix selection on same day (#12604) @LukasTy
|
|
141
|
+
|
|
142
|
+
### Charts
|
|
143
|
+
|
|
144
|
+
#### `@mui/x-charts@7.1.1`
|
|
145
|
+
|
|
146
|
+
- [charts] Fix `tickInterval` usage for y-axis (#12592) @alexfauquette
|
|
147
|
+
- [charts] Fix Scatter series highlight when `id` is a `number` (#12677) @JCQuintas
|
|
148
|
+
- [charts] Fix TS error when using `sx` property on `ChartsTooltip` (#12659) @JCQuintas
|
|
149
|
+
|
|
150
|
+
### Tree View
|
|
151
|
+
|
|
152
|
+
#### `@mui/x-tree-view@7.1.1`
|
|
153
|
+
|
|
154
|
+
- [TreeView] Add JSDoc to all `publicAPI` methods (#12649) @flaviendelangle
|
|
155
|
+
- [TreeView] Create `RichTreeViewPro` component (not released yet) (#12610) @flaviendelangle
|
|
156
|
+
- [TreeView] Create pro package (not released yet) (#12240) @flaviendelangle
|
|
157
|
+
- [TreeView] Fix typo in errors (#12623) @alissa-tung
|
|
158
|
+
- [TreeView] New API method: `setItemExpansion` (#12595) @flaviendelangle
|
|
159
|
+
|
|
160
|
+
### Docs
|
|
161
|
+
|
|
162
|
+
- [docs] Add a recipe for the `checkboxSelectionVisibleOnly` prop (#12646) @michelengelen
|
|
163
|
+
- [docs] Explain the use of `_action: 'delete'` in `processRowUpdate` (#12670) @michelengelen
|
|
164
|
+
- [docs] Fix formatting and typo on migration guide @oliviertassinari
|
|
165
|
+
- [docs] Fix formatting in changelog @oliviertassinari
|
|
166
|
+
- [docs] Fix grammar in TreeView migration doc (#12615) @joshkel
|
|
167
|
+
- [docs] Fix missing closing props in `PieShapeNoSnap` demo (#12636) @alp-ex
|
|
168
|
+
- [docs] Fix type arguments in Custom Field page (#12619) @Juneezee
|
|
169
|
+
- [docs] Fix typo in `getItemId` prop description (#12637) @flaviendelangle
|
|
170
|
+
- [docs] Make the Charts `margin` usage more visible (#12591) @alexfauquette
|
|
171
|
+
- [docs] Match IE 11 spacing with Material UI @oliviertassinari
|
|
172
|
+
- [docs] Move data grid interfaces to standard API page layout (#12016) @alexfauquette
|
|
173
|
+
- [docs] Remove ` around @default values (#12158) @alexfauquette
|
|
174
|
+
- [docs] Remove `day` from the default `dayOfWeekFormatter` function params (#12644) @LukasTy
|
|
175
|
+
- [docs] Use `TreeItem2` for icon expansion example on `RichTreeView` (#12563) @flaviendelangle
|
|
176
|
+
|
|
177
|
+
### Core
|
|
178
|
+
|
|
179
|
+
- [core] Add cherry-pick `master` to `v6` action (#12648) @LukasTy
|
|
180
|
+
- [core] Fix typo in `@mui/x-tree-view-pro/themeAugmentation` (#12674) @flaviendelangle
|
|
181
|
+
- [core] Introduce `describeTreeView` to run test on `SimpleTreeView` and `RichTreeView`, using `TreeItem` and `TreeItem2` + migrate expansion tests (#12428) @flaviendelangle
|
|
182
|
+
- [core] Limit `test-types` CI step allowed memory (#12651) @LukasTy
|
|
183
|
+
- [core] Remove explicit `express` package (#12602) @LukasTy
|
|
184
|
+
- [core] Update to new embedded translations in the docs package (#12232) @Janpot
|
|
185
|
+
- [core] Use PR labels to identify the package a `l10n` PR belongs to (#12639) @LukasTy
|
|
186
|
+
- [core] Use `describeTreeView` for selection tests (#12647) @flaviendelangle
|
|
187
|
+
- [docs-infra] Adjust the links to search for issues (#11995) @michelengelen
|
|
188
|
+
- [infra] Polish support survey experience (#12624) @oliviertassinari
|
|
189
|
+
- [support-infra] Replace author association with a permission check in survey action (#12068) @michelengelen
|
|
190
|
+
- [support-infra] Fix user permission check (#12669) @michelengelen
|
|
191
|
+
- [test] Fix Tree View test import (#12668) @LukasTy
|
|
192
|
+
|
|
6
193
|
## 7.1.0
|
|
7
194
|
|
|
8
195
|
_Mar 28, 2024_
|
|
@@ -74,7 +261,7 @@ Same changes as in `@mui/x-date-pickers@7.1.0`, plus:
|
|
|
74
261
|
- [core] Include `DateTimeRangePicker` tag in `releaseChangelog` (#12526) @LukasTy
|
|
75
262
|
- [core] Upgrade monorepo (#12536) @cherniavskii
|
|
76
263
|
|
|
77
|
-
##
|
|
264
|
+
## 7.0.0
|
|
78
265
|
|
|
79
266
|
_Mar 22, 2024_
|
|
80
267
|
|
|
@@ -530,13 +717,13 @@ We'd like to offer a big thanks to the 10 contributors who made this release pos
|
|
|
530
717
|
|
|
531
718
|
- 🎁 Introduce a new DOM structure for the field components that provides a better accessibility
|
|
532
719
|
- 🚀 Simplify Data Grid DOM structure for improved performance (#12013) @romgrk
|
|
533
|
-
- 🕥 The support for
|
|
720
|
+
- 🕥 The support for IE 11 has been removed (#12151) @flaviendelangle
|
|
534
721
|
- 🐞 Bugfixes
|
|
535
722
|
- 📚 Documentation improvements
|
|
536
723
|
|
|
537
724
|
### Breaking changes
|
|
538
725
|
|
|
539
|
-
- The support for
|
|
726
|
+
- The support for IE 11 has been removed from all MUI X packages. The `legacy` bundle that used to support old browsers like IE 11 is no longer included.
|
|
540
727
|
|
|
541
728
|
### Data Grid
|
|
542
729
|
|
|
@@ -641,7 +828,7 @@ These components are no longer exported from `@mui/x-charts`:
|
|
|
641
828
|
|
|
642
829
|
### Tree View / `@mui/x-tree-view@7.0.0-beta.4`
|
|
643
830
|
|
|
644
|
-
- [TreeView] Stop using custom `findIndex` to support
|
|
831
|
+
- [TreeView] Stop using custom `findIndex` to support IE 11 (#12129) @flaviendelangle
|
|
645
832
|
|
|
646
833
|
### Docs
|
|
647
834
|
|
|
@@ -2871,6 +3058,76 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
|
|
|
2871
3058
|
- [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
|
|
2872
3059
|
- [license] Correctly throw errors (#10924) @oliviertassinari
|
|
2873
3060
|
|
|
3061
|
+
## 6.19.9
|
|
3062
|
+
|
|
3063
|
+
_Apr 5, 2024_
|
|
3064
|
+
|
|
3065
|
+
We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
|
|
3066
|
+
|
|
3067
|
+
- 🐞 Bugfixes
|
|
3068
|
+
- 📚 Documentation improvements
|
|
3069
|
+
|
|
3070
|
+
### Data Grid
|
|
3071
|
+
|
|
3072
|
+
#### `@mui/x-data-grid@6.19.9`
|
|
3073
|
+
|
|
3074
|
+
- [DataGrid] Remove legacy editing API event: `rowEditCommit` (#12087) @MBilalShafi
|
|
3075
|
+
|
|
3076
|
+
#### `@mui/x-data-grid-pro@6.19.9` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
3077
|
+
|
|
3078
|
+
Same changes as in `@mui/x-data-grid@6.19.9`.
|
|
3079
|
+
|
|
3080
|
+
#### `@mui/x-data-grid-premium@6.19.9` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
3081
|
+
|
|
3082
|
+
Same changes as in `@mui/x-data-grid-pro@6.19.9`.
|
|
3083
|
+
|
|
3084
|
+
### Date Pickers
|
|
3085
|
+
|
|
3086
|
+
#### `@mui/x-date-pickers@6.19.9`
|
|
3087
|
+
|
|
3088
|
+
No changes.
|
|
3089
|
+
|
|
3090
|
+
#### `@mui/x-date-pickers-pro@6.19.9` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
3091
|
+
|
|
3092
|
+
- [DateRangePicker] Fix selection behavior with single input field when `readOnly` (#12605) @LukasTy
|
|
3093
|
+
|
|
3094
|
+
### Docs
|
|
3095
|
+
|
|
3096
|
+
- [docs] Add a recipe for the `checkboxSelectionVisibleOnly` prop (#12667) @michelengelen
|
|
3097
|
+
- [docs] Explain the use of `_action: 'delete'` in `processRowUpdate` (#12673) @michelengelen
|
|
3098
|
+
|
|
3099
|
+
### Core
|
|
3100
|
+
|
|
3101
|
+
- [core] Use Circle CI context (#12607) @cherniavskii
|
|
3102
|
+
|
|
3103
|
+
## 6.19.8
|
|
3104
|
+
|
|
3105
|
+
_Mar 20, 2024_
|
|
3106
|
+
|
|
3107
|
+
We'd like to offer a big thanks to the 3 contributors who made this release possible.
|
|
3108
|
+
|
|
3109
|
+
### Data Grid
|
|
3110
|
+
|
|
3111
|
+
#### `@mui/x-data-grid@6.19.8`
|
|
3112
|
+
|
|
3113
|
+
- [DataGrid] Fix `ElementType` usage (#12505) @cherniavskii
|
|
3114
|
+
- [DataGrid] Fix cell value formatting on copy (#12483) @sai6855
|
|
3115
|
+
- [DataGrid] Fix checkbox selection when filtering (#12485) @g1mishra
|
|
3116
|
+
|
|
3117
|
+
#### `@mui/x-data-grid-pro@6.19.8` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
3118
|
+
|
|
3119
|
+
Same changes as in `@mui/x-data-grid@6.19.8`.
|
|
3120
|
+
|
|
3121
|
+
#### `@mui/x-data-grid-premium@6.19.8` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
3122
|
+
|
|
3123
|
+
Same changes as in `@mui/x-data-grid-pro@6.19.8`, plus:
|
|
3124
|
+
|
|
3125
|
+
- [DataGridPremium] Add support for confirmation before clipboard paste (#12466) @cherniavskii
|
|
3126
|
+
|
|
3127
|
+
### Docs
|
|
3128
|
+
|
|
3129
|
+
- [docs] Update links to v7 (#12495) @cherniavskii
|
|
3130
|
+
|
|
2874
3131
|
## 6.19.7
|
|
2875
3132
|
|
|
2876
3133
|
_Mar 14, 2024_
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { PopperProps as BasePopperProps } from '@mui/base/Popper';
|
|
3
4
|
import { TriggerOptions } from './utils';
|
|
4
5
|
import { ChartsItemContentProps } from './ChartsItemTooltipContent';
|
|
5
6
|
import { ChartsAxisContentProps } from './ChartsAxisTooltipContent';
|
|
6
7
|
import { ChartsTooltipClasses } from './chartsTooltipClasses';
|
|
8
|
+
export type PopperProps = BasePopperProps & {
|
|
9
|
+
/**
|
|
10
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
11
|
+
*/
|
|
12
|
+
sx?: SxProps<Theme>;
|
|
13
|
+
};
|
|
7
14
|
export interface ChartsTooltipSlots {
|
|
8
15
|
/**
|
|
9
16
|
* Custom component for the tooltip popper.
|
|
@@ -8,8 +8,8 @@ export type ChartsVoronoiHandlerProps = {
|
|
|
8
8
|
voronoiMaxRadius?: number | undefined;
|
|
9
9
|
/**
|
|
10
10
|
* Callback fired when clicking on a scatter item.
|
|
11
|
-
* @param {MouseEvent} event Mouse event
|
|
12
|
-
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify
|
|
11
|
+
* @param {MouseEvent} event Mouse event caught at the svg level
|
|
12
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify which item got clicked
|
|
13
13
|
*/
|
|
14
14
|
onItemClick?: (event: MouseEvent, scatterItemIdentifier: ScatterItemIdentifier) => void;
|
|
15
15
|
};
|
|
@@ -44,6 +44,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
44
44
|
seriesOrder
|
|
45
45
|
} = React.useContext(_SeriesContextProvider.SeriesContext).scatter ?? {};
|
|
46
46
|
const voronoiRef = React.useRef({});
|
|
47
|
+
const delauneyRef = React.useRef(undefined);
|
|
47
48
|
const defaultXAxisId = xAxisIds[0];
|
|
48
49
|
const defaultYAxisId = yAxisIds[0];
|
|
49
50
|
(0, _useEnhancedEffect.default)(() => {
|
|
@@ -82,12 +83,13 @@ function ChartsVoronoiHandler(props) {
|
|
|
82
83
|
y
|
|
83
84
|
}) => [getXPosition(x), getYPosition(y)]);
|
|
84
85
|
voronoiRef.current[seriesId] = {
|
|
86
|
+
seriesId,
|
|
85
87
|
startIndex: points.length,
|
|
86
88
|
endIndex: points.length + seriesPoints.length
|
|
87
89
|
};
|
|
88
90
|
points = points.concat(seriesPoints);
|
|
89
91
|
});
|
|
90
|
-
|
|
92
|
+
delauneyRef.current = new _d3Delaunay.Delaunay(points);
|
|
91
93
|
}, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis]);
|
|
92
94
|
React.useEffect(() => {
|
|
93
95
|
const element = svgRef.current;
|
|
@@ -95,7 +97,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
95
97
|
return undefined;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
// TODO: A perf optimisation of voronoi could be to use the last point as the
|
|
100
|
+
// TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
|
|
99
101
|
function getClosestPoint(event) {
|
|
100
102
|
// Get mouse coordinate in global SVG space
|
|
101
103
|
const svgPoint = (0, _utils.getSVGPoint)(svgRef.current, event);
|
|
@@ -104,26 +106,23 @@ function ChartsVoronoiHandler(props) {
|
|
|
104
106
|
if (outsideX || outsideY) {
|
|
105
107
|
return 'outside-chart';
|
|
106
108
|
}
|
|
107
|
-
if (!
|
|
109
|
+
if (!delauneyRef.current) {
|
|
108
110
|
return 'no-point-found';
|
|
109
111
|
}
|
|
110
|
-
const closestPointIndex =
|
|
112
|
+
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y);
|
|
111
113
|
if (closestPointIndex === undefined) {
|
|
112
114
|
return 'no-point-found';
|
|
113
115
|
}
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
return 2 * closestPointIndex >= voronoiRef.current[id].startIndex && 2 * closestPointIndex < voronoiRef.current[id].endIndex;
|
|
116
|
+
const closestSeries = Object.values(voronoiRef.current).find(value => {
|
|
117
|
+
return 2 * closestPointIndex >= value.startIndex && 2 * closestPointIndex < value.endIndex;
|
|
119
118
|
});
|
|
120
|
-
if (
|
|
119
|
+
if (closestSeries === undefined) {
|
|
121
120
|
return 'no-point-found';
|
|
122
121
|
}
|
|
123
|
-
const dataIndex = (2 * closestPointIndex - voronoiRef.current[seriesId].startIndex) / 2;
|
|
122
|
+
const dataIndex = (2 * closestPointIndex - voronoiRef.current[closestSeries.seriesId].startIndex) / 2;
|
|
124
123
|
if (voronoiMaxRadius !== undefined) {
|
|
125
|
-
const pointX =
|
|
126
|
-
const pointY =
|
|
124
|
+
const pointX = delauneyRef.current.points[2 * closestPointIndex];
|
|
125
|
+
const pointY = delauneyRef.current.points[2 * closestPointIndex + 1];
|
|
127
126
|
const dist2 = (pointX - svgPoint.x) ** 2 + (pointY - svgPoint.y) ** 2;
|
|
128
127
|
if (dist2 > voronoiMaxRadius ** 2) {
|
|
129
128
|
// The closest point is too far to be considered.
|
|
@@ -131,7 +130,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
return {
|
|
134
|
-
seriesId,
|
|
133
|
+
seriesId: closestSeries.seriesId,
|
|
135
134
|
dataIndex
|
|
136
135
|
};
|
|
137
136
|
}
|
|
@@ -209,8 +208,8 @@ process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
|
|
|
209
208
|
// ----------------------------------------------------------------------
|
|
210
209
|
/**
|
|
211
210
|
* Callback fired when clicking on a scatter item.
|
|
212
|
-
* @param {MouseEvent} event Mouse event
|
|
213
|
-
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify
|
|
211
|
+
* @param {MouseEvent} event Mouse event caught at the svg level
|
|
212
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify which item got clicked
|
|
214
213
|
*/
|
|
215
214
|
onItemClick: _propTypes.default.func,
|
|
216
215
|
/**
|
|
@@ -71,7 +71,7 @@ function addLabelDimension(xTicks, {
|
|
|
71
71
|
|
|
72
72
|
// Filter label to avoid overlap
|
|
73
73
|
let currentTextLimit = 0;
|
|
74
|
-
let
|
|
74
|
+
let previousTextLimit = 0;
|
|
75
75
|
const direction = reverse ? -1 : 1;
|
|
76
76
|
return withDimension.map((item, labelIndex) => {
|
|
77
77
|
const {
|
|
@@ -85,14 +85,14 @@ function addLabelDimension(xTicks, {
|
|
|
85
85
|
const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
|
|
86
86
|
|
|
87
87
|
currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
|
|
88
|
-
if (labelIndex > 0 && direction * currentTextLimit < direction *
|
|
88
|
+
if (labelIndex > 0 && direction * currentTextLimit < direction * previousTextLimit) {
|
|
89
89
|
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
90
|
-
// Notice that the early return prevents `
|
|
90
|
+
// Notice that the early return prevents `previousTextLimit` from being updated.
|
|
91
91
|
return (0, _extends2.default)({}, item, {
|
|
92
92
|
skipLabel: true
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
previousTextLimit = textPosition + direction * (gapRatio * distance) / 2;
|
|
96
96
|
return item;
|
|
97
97
|
});
|
|
98
98
|
}
|
|
@@ -354,7 +354,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
354
354
|
*/
|
|
355
355
|
tickMinStep: _propTypes.default.number,
|
|
356
356
|
/**
|
|
357
|
-
* The number of ticks. This number is not
|
|
357
|
+
* The number of ticks. This number is not guaranteed.
|
|
358
358
|
* Not supported by categorical axis (band, points).
|
|
359
359
|
*/
|
|
360
360
|
tickNumber: _propTypes.default.number,
|
|
@@ -89,7 +89,9 @@ function ChartsYAxis(inProps) {
|
|
|
89
89
|
slots,
|
|
90
90
|
slotProps,
|
|
91
91
|
tickPlacement,
|
|
92
|
-
tickLabelPlacement
|
|
92
|
+
tickLabelPlacement,
|
|
93
|
+
tickInterval,
|
|
94
|
+
tickLabelInterval
|
|
93
95
|
} = defaultizedProps;
|
|
94
96
|
const theme = (0, _styles.useTheme)();
|
|
95
97
|
const classes = useUtilityClasses((0, _extends2.default)({}, defaultizedProps, {
|
|
@@ -107,7 +109,8 @@ function ChartsYAxis(inProps) {
|
|
|
107
109
|
tickNumber,
|
|
108
110
|
valueFormatter,
|
|
109
111
|
tickPlacement,
|
|
110
|
-
tickLabelPlacement
|
|
112
|
+
tickLabelPlacement,
|
|
113
|
+
tickInterval
|
|
111
114
|
});
|
|
112
115
|
const positionSign = position === 'right' ? 1 : -1;
|
|
113
116
|
const labelRefPoint = {
|
|
@@ -154,17 +157,19 @@ function ChartsYAxis(inProps) {
|
|
|
154
157
|
}, slotProps?.axisLine)), yTicks.map(({
|
|
155
158
|
formattedValue,
|
|
156
159
|
offset,
|
|
157
|
-
labelOffset
|
|
160
|
+
labelOffset,
|
|
161
|
+
value
|
|
158
162
|
}, index) => {
|
|
159
163
|
const xTickLabel = positionSign * (tickSize + 2);
|
|
160
164
|
const yTickLabel = labelOffset;
|
|
165
|
+
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
161
166
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
162
167
|
transform: `translate(0, ${offset})`,
|
|
163
168
|
className: classes.tickContainer,
|
|
164
169
|
children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
|
|
165
170
|
x2: positionSign * tickSize,
|
|
166
171
|
className: classes.tick
|
|
167
|
-
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
|
|
172
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
|
|
168
173
|
x: xTickLabel,
|
|
169
174
|
y: yTickLabel,
|
|
170
175
|
text: formattedValue.toString()
|
|
@@ -284,7 +289,7 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
284
289
|
*/
|
|
285
290
|
tickMinStep: _propTypes.default.number,
|
|
286
291
|
/**
|
|
287
|
-
* The number of ticks. This number is not
|
|
292
|
+
* The number of ticks. This number is not guaranteed.
|
|
288
293
|
* Not supported by categorical axis (band, points).
|
|
289
294
|
*/
|
|
290
295
|
tickNumber: _propTypes.default.number,
|
|
@@ -13,7 +13,7 @@ const getValueExtremum = params => {
|
|
|
13
13
|
isDefaultAxis
|
|
14
14
|
} = params;
|
|
15
15
|
return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
|
|
16
|
-
const [seriesMin, seriesMax] = series[seriesId].stackedData
|
|
16
|
+
const [seriesMin, seriesMax] = series[seriesId].stackedData?.reduce((seriesAcc, values) => [Math.min(...values, ...(seriesAcc[0] === null ? [] : [seriesAcc[0]])), Math.max(...values, ...(seriesAcc[1] === null ? [] : [seriesAcc[1]]))], series[seriesId].stackedData[0]) ?? [null, null];
|
|
17
17
|
return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
|
|
18
18
|
}, [null, null]);
|
|
19
19
|
};
|
|
@@ -35,6 +35,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
35
35
|
seriesOrder
|
|
36
36
|
} = React.useContext(SeriesContext).scatter ?? {};
|
|
37
37
|
const voronoiRef = React.useRef({});
|
|
38
|
+
const delauneyRef = React.useRef(undefined);
|
|
38
39
|
const defaultXAxisId = xAxisIds[0];
|
|
39
40
|
const defaultYAxisId = yAxisIds[0];
|
|
40
41
|
useEnhancedEffect(() => {
|
|
@@ -73,12 +74,13 @@ function ChartsVoronoiHandler(props) {
|
|
|
73
74
|
y
|
|
74
75
|
}) => [getXPosition(x), getYPosition(y)]);
|
|
75
76
|
voronoiRef.current[seriesId] = {
|
|
77
|
+
seriesId,
|
|
76
78
|
startIndex: points.length,
|
|
77
79
|
endIndex: points.length + seriesPoints.length
|
|
78
80
|
};
|
|
79
81
|
points = points.concat(seriesPoints);
|
|
80
82
|
});
|
|
81
|
-
|
|
83
|
+
delauneyRef.current = new Delaunay(points);
|
|
82
84
|
}, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis]);
|
|
83
85
|
React.useEffect(() => {
|
|
84
86
|
const element = svgRef.current;
|
|
@@ -86,7 +88,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
86
88
|
return undefined;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
// TODO: A perf optimisation of voronoi could be to use the last point as the
|
|
91
|
+
// TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
|
|
90
92
|
function getClosestPoint(event) {
|
|
91
93
|
// Get mouse coordinate in global SVG space
|
|
92
94
|
const svgPoint = getSVGPoint(svgRef.current, event);
|
|
@@ -95,26 +97,23 @@ function ChartsVoronoiHandler(props) {
|
|
|
95
97
|
if (outsideX || outsideY) {
|
|
96
98
|
return 'outside-chart';
|
|
97
99
|
}
|
|
98
|
-
if (!
|
|
100
|
+
if (!delauneyRef.current) {
|
|
99
101
|
return 'no-point-found';
|
|
100
102
|
}
|
|
101
|
-
const closestPointIndex =
|
|
103
|
+
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y);
|
|
102
104
|
if (closestPointIndex === undefined) {
|
|
103
105
|
return 'no-point-found';
|
|
104
106
|
}
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return 2 * closestPointIndex >= voronoiRef.current[id].startIndex && 2 * closestPointIndex < voronoiRef.current[id].endIndex;
|
|
107
|
+
const closestSeries = Object.values(voronoiRef.current).find(value => {
|
|
108
|
+
return 2 * closestPointIndex >= value.startIndex && 2 * closestPointIndex < value.endIndex;
|
|
110
109
|
});
|
|
111
|
-
if (
|
|
110
|
+
if (closestSeries === undefined) {
|
|
112
111
|
return 'no-point-found';
|
|
113
112
|
}
|
|
114
|
-
const dataIndex = (2 * closestPointIndex - voronoiRef.current[seriesId].startIndex) / 2;
|
|
113
|
+
const dataIndex = (2 * closestPointIndex - voronoiRef.current[closestSeries.seriesId].startIndex) / 2;
|
|
115
114
|
if (voronoiMaxRadius !== undefined) {
|
|
116
|
-
const pointX =
|
|
117
|
-
const pointY =
|
|
115
|
+
const pointX = delauneyRef.current.points[2 * closestPointIndex];
|
|
116
|
+
const pointY = delauneyRef.current.points[2 * closestPointIndex + 1];
|
|
118
117
|
const dist2 = (pointX - svgPoint.x) ** 2 + (pointY - svgPoint.y) ** 2;
|
|
119
118
|
if (dist2 > voronoiMaxRadius ** 2) {
|
|
120
119
|
// The closest point is too far to be considered.
|
|
@@ -122,7 +121,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
return {
|
|
125
|
-
seriesId,
|
|
124
|
+
seriesId: closestSeries.seriesId,
|
|
126
125
|
dataIndex
|
|
127
126
|
};
|
|
128
127
|
}
|
|
@@ -200,8 +199,8 @@ process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
|
|
|
200
199
|
// ----------------------------------------------------------------------
|
|
201
200
|
/**
|
|
202
201
|
* Callback fired when clicking on a scatter item.
|
|
203
|
-
* @param {MouseEvent} event Mouse event
|
|
204
|
-
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify
|
|
202
|
+
* @param {MouseEvent} event Mouse event caught at the svg level
|
|
203
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify which item got clicked
|
|
205
204
|
*/
|
|
206
205
|
onItemClick: PropTypes.func,
|
|
207
206
|
/**
|
|
@@ -63,7 +63,7 @@ function addLabelDimension(xTicks, {
|
|
|
63
63
|
|
|
64
64
|
// Filter label to avoid overlap
|
|
65
65
|
let currentTextLimit = 0;
|
|
66
|
-
let
|
|
66
|
+
let previousTextLimit = 0;
|
|
67
67
|
const direction = reverse ? -1 : 1;
|
|
68
68
|
return withDimension.map((item, labelIndex) => {
|
|
69
69
|
const {
|
|
@@ -77,14 +77,14 @@ function addLabelDimension(xTicks, {
|
|
|
77
77
|
const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
|
|
78
78
|
|
|
79
79
|
currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
|
|
80
|
-
if (labelIndex > 0 && direction * currentTextLimit < direction *
|
|
80
|
+
if (labelIndex > 0 && direction * currentTextLimit < direction * previousTextLimit) {
|
|
81
81
|
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
82
|
-
// Notice that the early return prevents `
|
|
82
|
+
// Notice that the early return prevents `previousTextLimit` from being updated.
|
|
83
83
|
return _extends({}, item, {
|
|
84
84
|
skipLabel: true
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
previousTextLimit = textPosition + direction * (gapRatio * distance) / 2;
|
|
88
88
|
return item;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -346,7 +346,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
346
346
|
*/
|
|
347
347
|
tickMinStep: PropTypes.number,
|
|
348
348
|
/**
|
|
349
|
-
* The number of ticks. This number is not
|
|
349
|
+
* The number of ticks. This number is not guaranteed.
|
|
350
350
|
* Not supported by categorical axis (band, points).
|
|
351
351
|
*/
|
|
352
352
|
tickNumber: PropTypes.number,
|
|
@@ -81,7 +81,9 @@ function ChartsYAxis(inProps) {
|
|
|
81
81
|
slots,
|
|
82
82
|
slotProps,
|
|
83
83
|
tickPlacement,
|
|
84
|
-
tickLabelPlacement
|
|
84
|
+
tickLabelPlacement,
|
|
85
|
+
tickInterval,
|
|
86
|
+
tickLabelInterval
|
|
85
87
|
} = defaultizedProps;
|
|
86
88
|
const theme = useTheme();
|
|
87
89
|
const classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
@@ -99,7 +101,8 @@ function ChartsYAxis(inProps) {
|
|
|
99
101
|
tickNumber,
|
|
100
102
|
valueFormatter,
|
|
101
103
|
tickPlacement,
|
|
102
|
-
tickLabelPlacement
|
|
104
|
+
tickLabelPlacement,
|
|
105
|
+
tickInterval
|
|
103
106
|
});
|
|
104
107
|
const positionSign = position === 'right' ? 1 : -1;
|
|
105
108
|
const labelRefPoint = {
|
|
@@ -146,17 +149,19 @@ function ChartsYAxis(inProps) {
|
|
|
146
149
|
}, slotProps?.axisLine)), yTicks.map(({
|
|
147
150
|
formattedValue,
|
|
148
151
|
offset,
|
|
149
|
-
labelOffset
|
|
152
|
+
labelOffset,
|
|
153
|
+
value
|
|
150
154
|
}, index) => {
|
|
151
155
|
const xTickLabel = positionSign * (tickSize + 2);
|
|
152
156
|
const yTickLabel = labelOffset;
|
|
157
|
+
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
153
158
|
return /*#__PURE__*/_jsxs("g", {
|
|
154
159
|
transform: `translate(0, ${offset})`,
|
|
155
160
|
className: classes.tickContainer,
|
|
156
161
|
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
157
162
|
x2: positionSign * tickSize,
|
|
158
163
|
className: classes.tick
|
|
159
|
-
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
164
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
160
165
|
x: xTickLabel,
|
|
161
166
|
y: yTickLabel,
|
|
162
167
|
text: formattedValue.toString()
|
|
@@ -276,7 +281,7 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
276
281
|
*/
|
|
277
282
|
tickMinStep: PropTypes.number,
|
|
278
283
|
/**
|
|
279
|
-
* The number of ticks. This number is not
|
|
284
|
+
* The number of ticks. This number is not guaranteed.
|
|
280
285
|
* Not supported by categorical axis (band, points).
|
|
281
286
|
*/
|
|
282
287
|
tickNumber: PropTypes.number,
|
package/hooks/useTicks.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface TickParams {
|
|
|
13
13
|
*/
|
|
14
14
|
tickMinStep?: number;
|
|
15
15
|
/**
|
|
16
|
-
* The number of ticks. This number is not
|
|
16
|
+
* The number of ticks. This number is not guaranteed.
|
|
17
17
|
* Not supported by categorical axis (band, points).
|
|
18
18
|
*/
|
|
19
19
|
tickNumber?: number;
|
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const getValueExtremum = params => {
|
|
|
13
13
|
isDefaultAxis
|
|
14
14
|
} = params;
|
|
15
15
|
return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
|
|
16
|
-
const [seriesMin, seriesMax] = series[seriesId].stackedData
|
|
16
|
+
const [seriesMin, seriesMax] = series[seriesId].stackedData?.reduce((seriesAcc, values) => [Math.min(...values, ...(seriesAcc[0] === null ? [] : [seriesAcc[0]])), Math.max(...values, ...(seriesAcc[1] === null ? [] : [seriesAcc[1]]))], series[seriesId].stackedData[0]) ?? [null, null];
|
|
17
17
|
return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
|
|
18
18
|
}, [null, null]);
|
|
19
19
|
};
|
|
@@ -35,6 +35,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
35
35
|
seriesOrder
|
|
36
36
|
} = React.useContext(SeriesContext).scatter ?? {};
|
|
37
37
|
const voronoiRef = React.useRef({});
|
|
38
|
+
const delauneyRef = React.useRef(undefined);
|
|
38
39
|
const defaultXAxisId = xAxisIds[0];
|
|
39
40
|
const defaultYAxisId = yAxisIds[0];
|
|
40
41
|
useEnhancedEffect(() => {
|
|
@@ -73,12 +74,13 @@ function ChartsVoronoiHandler(props) {
|
|
|
73
74
|
y
|
|
74
75
|
}) => [getXPosition(x), getYPosition(y)]);
|
|
75
76
|
voronoiRef.current[seriesId] = {
|
|
77
|
+
seriesId,
|
|
76
78
|
startIndex: points.length,
|
|
77
79
|
endIndex: points.length + seriesPoints.length
|
|
78
80
|
};
|
|
79
81
|
points = points.concat(seriesPoints);
|
|
80
82
|
});
|
|
81
|
-
|
|
83
|
+
delauneyRef.current = new Delaunay(points);
|
|
82
84
|
}, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis]);
|
|
83
85
|
React.useEffect(() => {
|
|
84
86
|
const element = svgRef.current;
|
|
@@ -86,7 +88,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
86
88
|
return undefined;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
// TODO: A perf optimisation of voronoi could be to use the last point as the
|
|
91
|
+
// TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
|
|
90
92
|
function getClosestPoint(event) {
|
|
91
93
|
// Get mouse coordinate in global SVG space
|
|
92
94
|
const svgPoint = getSVGPoint(svgRef.current, event);
|
|
@@ -95,26 +97,23 @@ function ChartsVoronoiHandler(props) {
|
|
|
95
97
|
if (outsideX || outsideY) {
|
|
96
98
|
return 'outside-chart';
|
|
97
99
|
}
|
|
98
|
-
if (!
|
|
100
|
+
if (!delauneyRef.current) {
|
|
99
101
|
return 'no-point-found';
|
|
100
102
|
}
|
|
101
|
-
const closestPointIndex =
|
|
103
|
+
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y);
|
|
102
104
|
if (closestPointIndex === undefined) {
|
|
103
105
|
return 'no-point-found';
|
|
104
106
|
}
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return 2 * closestPointIndex >= voronoiRef.current[id].startIndex && 2 * closestPointIndex < voronoiRef.current[id].endIndex;
|
|
107
|
+
const closestSeries = Object.values(voronoiRef.current).find(value => {
|
|
108
|
+
return 2 * closestPointIndex >= value.startIndex && 2 * closestPointIndex < value.endIndex;
|
|
110
109
|
});
|
|
111
|
-
if (
|
|
110
|
+
if (closestSeries === undefined) {
|
|
112
111
|
return 'no-point-found';
|
|
113
112
|
}
|
|
114
|
-
const dataIndex = (2 * closestPointIndex - voronoiRef.current[seriesId].startIndex) / 2;
|
|
113
|
+
const dataIndex = (2 * closestPointIndex - voronoiRef.current[closestSeries.seriesId].startIndex) / 2;
|
|
115
114
|
if (voronoiMaxRadius !== undefined) {
|
|
116
|
-
const pointX =
|
|
117
|
-
const pointY =
|
|
115
|
+
const pointX = delauneyRef.current.points[2 * closestPointIndex];
|
|
116
|
+
const pointY = delauneyRef.current.points[2 * closestPointIndex + 1];
|
|
118
117
|
const dist2 = (pointX - svgPoint.x) ** 2 + (pointY - svgPoint.y) ** 2;
|
|
119
118
|
if (dist2 > voronoiMaxRadius ** 2) {
|
|
120
119
|
// The closest point is too far to be considered.
|
|
@@ -122,7 +121,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
return {
|
|
125
|
-
seriesId,
|
|
124
|
+
seriesId: closestSeries.seriesId,
|
|
126
125
|
dataIndex
|
|
127
126
|
};
|
|
128
127
|
}
|
|
@@ -200,8 +199,8 @@ process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
|
|
|
200
199
|
// ----------------------------------------------------------------------
|
|
201
200
|
/**
|
|
202
201
|
* Callback fired when clicking on a scatter item.
|
|
203
|
-
* @param {MouseEvent} event Mouse event
|
|
204
|
-
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify
|
|
202
|
+
* @param {MouseEvent} event Mouse event caught at the svg level
|
|
203
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify which item got clicked
|
|
205
204
|
*/
|
|
206
205
|
onItemClick: PropTypes.func,
|
|
207
206
|
/**
|
|
@@ -63,7 +63,7 @@ function addLabelDimension(xTicks, {
|
|
|
63
63
|
|
|
64
64
|
// Filter label to avoid overlap
|
|
65
65
|
let currentTextLimit = 0;
|
|
66
|
-
let
|
|
66
|
+
let previousTextLimit = 0;
|
|
67
67
|
const direction = reverse ? -1 : 1;
|
|
68
68
|
return withDimension.map((item, labelIndex) => {
|
|
69
69
|
const {
|
|
@@ -77,14 +77,14 @@ function addLabelDimension(xTicks, {
|
|
|
77
77
|
const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
|
|
78
78
|
|
|
79
79
|
currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
|
|
80
|
-
if (labelIndex > 0 && direction * currentTextLimit < direction *
|
|
80
|
+
if (labelIndex > 0 && direction * currentTextLimit < direction * previousTextLimit) {
|
|
81
81
|
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
82
|
-
// Notice that the early return prevents `
|
|
82
|
+
// Notice that the early return prevents `previousTextLimit` from being updated.
|
|
83
83
|
return _extends({}, item, {
|
|
84
84
|
skipLabel: true
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
previousTextLimit = textPosition + direction * (gapRatio * distance) / 2;
|
|
88
88
|
return item;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -346,7 +346,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
346
346
|
*/
|
|
347
347
|
tickMinStep: PropTypes.number,
|
|
348
348
|
/**
|
|
349
|
-
* The number of ticks. This number is not
|
|
349
|
+
* The number of ticks. This number is not guaranteed.
|
|
350
350
|
* Not supported by categorical axis (band, points).
|
|
351
351
|
*/
|
|
352
352
|
tickNumber: PropTypes.number,
|
|
@@ -81,7 +81,9 @@ function ChartsYAxis(inProps) {
|
|
|
81
81
|
slots,
|
|
82
82
|
slotProps,
|
|
83
83
|
tickPlacement,
|
|
84
|
-
tickLabelPlacement
|
|
84
|
+
tickLabelPlacement,
|
|
85
|
+
tickInterval,
|
|
86
|
+
tickLabelInterval
|
|
85
87
|
} = defaultizedProps;
|
|
86
88
|
const theme = useTheme();
|
|
87
89
|
const classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
@@ -99,7 +101,8 @@ function ChartsYAxis(inProps) {
|
|
|
99
101
|
tickNumber,
|
|
100
102
|
valueFormatter,
|
|
101
103
|
tickPlacement,
|
|
102
|
-
tickLabelPlacement
|
|
104
|
+
tickLabelPlacement,
|
|
105
|
+
tickInterval
|
|
103
106
|
});
|
|
104
107
|
const positionSign = position === 'right' ? 1 : -1;
|
|
105
108
|
const labelRefPoint = {
|
|
@@ -146,17 +149,19 @@ function ChartsYAxis(inProps) {
|
|
|
146
149
|
}, slotProps?.axisLine)), yTicks.map(({
|
|
147
150
|
formattedValue,
|
|
148
151
|
offset,
|
|
149
|
-
labelOffset
|
|
152
|
+
labelOffset,
|
|
153
|
+
value
|
|
150
154
|
}, index) => {
|
|
151
155
|
const xTickLabel = positionSign * (tickSize + 2);
|
|
152
156
|
const yTickLabel = labelOffset;
|
|
157
|
+
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
153
158
|
return /*#__PURE__*/_jsxs("g", {
|
|
154
159
|
transform: `translate(0, ${offset})`,
|
|
155
160
|
className: classes.tickContainer,
|
|
156
161
|
children: [!disableTicks && /*#__PURE__*/_jsx(Tick, _extends({
|
|
157
162
|
x2: positionSign * tickSize,
|
|
158
163
|
className: classes.tick
|
|
159
|
-
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
164
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/_jsx(TickLabel, _extends({
|
|
160
165
|
x: xTickLabel,
|
|
161
166
|
y: yTickLabel,
|
|
162
167
|
text: formattedValue.toString()
|
|
@@ -276,7 +281,7 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
276
281
|
*/
|
|
277
282
|
tickMinStep: PropTypes.number,
|
|
278
283
|
/**
|
|
279
|
-
* The number of ticks. This number is not
|
|
284
|
+
* The number of ticks. This number is not guaranteed.
|
|
280
285
|
* Not supported by categorical axis (band, points).
|
|
281
286
|
*/
|
|
282
287
|
tickNumber: PropTypes.number,
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "The community edition of the
|
|
3
|
+
"version": "7.2.0",
|
|
4
|
+
"description": "The community edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"license": "MIT",
|