Skip to content

Commit 3530878

Browse files
committed
feedback
1 parent a0588fc commit 3530878

43 files changed

Lines changed: 462 additions & 686 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/data/charts/highlighting/ControlledAxisHighlight.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import RadioGroup from '@mui/material/RadioGroup';
1313
import { LineChart } from '@mui/x-charts/LineChart';
1414

1515
export default function ControlledAxisHighlight() {
16-
const [xAxisHighlight, setXAxisHighlight] = React.useState({
16+
const [highlightedAxis, setHighlightedAxis] = React.useState({
1717
axisId: 'x-axis',
1818
dataIndex: 2,
19-
value: null,
19+
direction: 'x',
2020
});
2121

2222
const [chartType, setChartType] = React.useState('bar');
@@ -28,10 +28,10 @@ export default function ControlledAxisHighlight() {
2828
};
2929

3030
const handleAxisHighlight = (event) => {
31-
setXAxisHighlight({
31+
setHighlightedAxis({
3232
axisId: 'x-axis',
3333
dataIndex: Number(event.target.value),
34-
value: null,
34+
direction: 'x',
3535
});
3636
};
3737

@@ -55,7 +55,7 @@ export default function ControlledAxisHighlight() {
5555
<RadioGroup
5656
aria-labelledby="axis-index-radio-group"
5757
name="radio-buttons-group"
58-
value={xAxisHighlight?.dataIndex ?? null}
58+
value={highlightedAxis?.dataIndex ?? null}
5959
onChange={handleAxisHighlight}
6060
row
6161
>
@@ -70,17 +70,17 @@ export default function ControlledAxisHighlight() {
7070
{chartType === 'bar' ? (
7171
<BarChart
7272
{...barChartsProps}
73-
xAxisHighlight={xAxisHighlight}
74-
onXAxisInteraction={(newState) =>
75-
setXAxisHighlight(newState && newState[0])
73+
highlightedAxis={highlightedAxis}
74+
onAxisInteraction={(newState) =>
75+
setHighlightedAxis(newState && newState[0])
7676
}
7777
/>
7878
) : (
7979
<LineChart
8080
{...lineChartsProps}
81-
xAxisHighlight={xAxisHighlight}
82-
onXAxisInteraction={(newState) =>
83-
setXAxisHighlight(newState && newState[0])
81+
highlightedAxis={highlightedAxis}
82+
onAxisInteraction={(newState) =>
83+
setHighlightedAxis(newState && newState[0])
8484
}
8585
/>
8686
)}

docs/data/charts/highlighting/ControlledAxisHighlight.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import FormControlLabel from '@mui/material/FormControlLabel';
99
import FormLabel from '@mui/material/FormLabel';
1010
import Radio from '@mui/material/Radio';
1111
import RadioGroup from '@mui/material/RadioGroup';
12-
import { AxisPointerIdentifier } from '@mui/x-charts/models';
12+
import { CartesianAxisItemIdentifier } from '@mui/x-charts/models';
1313
import { LineChart, LineChartProps } from '@mui/x-charts/LineChart';
1414

1515
export default function ControlledAxisHighlight() {
16-
const [xAxisHighlight, setXAxisHighlight] =
17-
React.useState<AxisPointerIdentifier | null>({
16+
const [highlightedAxis, setHighlightedAxis] =
17+
React.useState<CartesianAxisItemIdentifier | null>({
1818
axisId: 'x-axis',
1919
dataIndex: 2,
20-
value: null,
20+
direction: 'x',
2121
});
2222

2323
const [chartType, setChartType] = React.useState<'bar' | 'line'>('bar');
@@ -29,10 +29,10 @@ export default function ControlledAxisHighlight() {
2929
};
3030

3131
const handleAxisHighlight = (event: any) => {
32-
setXAxisHighlight({
32+
setHighlightedAxis({
3333
axisId: 'x-axis',
3434
dataIndex: Number(event.target.value),
35-
value: null,
35+
direction: 'x',
3636
});
3737
};
3838

@@ -56,7 +56,7 @@ export default function ControlledAxisHighlight() {
5656
<RadioGroup
5757
aria-labelledby="axis-index-radio-group"
5858
name="radio-buttons-group"
59-
value={xAxisHighlight?.dataIndex ?? null}
59+
value={highlightedAxis?.dataIndex ?? null}
6060
onChange={handleAxisHighlight}
6161
row
6262
>
@@ -71,17 +71,17 @@ export default function ControlledAxisHighlight() {
7171
{chartType === 'bar' ? (
7272
<BarChart
7373
{...barChartsProps}
74-
xAxisHighlight={xAxisHighlight}
75-
onXAxisInteraction={(newState) =>
76-
setXAxisHighlight(newState && newState[0])
74+
highlightedAxis={highlightedAxis}
75+
onAxisInteraction={(newState) =>
76+
setHighlightedAxis(newState && newState[0])
7777
}
7878
/>
7979
) : (
8080
<LineChart
8181
{...lineChartsProps}
82-
xAxisHighlight={xAxisHighlight}
83-
onXAxisInteraction={(newState) =>
84-
setXAxisHighlight(newState && newState[0])
82+
highlightedAxis={highlightedAxis}
83+
onAxisInteraction={(newState) =>
84+
setHighlightedAxis(newState && newState[0])
8585
}
8686
/>
8787
)}

docs/data/charts/highlighting/highlighting.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,19 @@ You can set the `highlightedItem` value based on inputs, and sync it when the us
5555

5656
### Axis
5757

58-
The highlight can be controlled by using `xAxisHighlight`/`yAxisHighlight` and the `onXAxisInteraction`/`onYAxisInteraction`.
58+
The highlight can be controlled by using `highlightedAxis` prop.
59+
Its value can be `null` to remove axis highlight, or an object `{ direction: 'x' | 'y', axisId: string, dataIndex: number }`.
5960

60-
The `xAxisHighlight`/`yAxisHighlight` are objects `{ axisId, dataIndex, value }`.
61-
If the `dataIndex` is provided, the axis `value` is ignored an computed from the `dataIndex` and `axis.data`.
62-
63-
The `onXAxisInteraction`/`onYAxisInteraction` handler are trigger each time pointer moves from one axis value to another.
64-
Its parameter is an array of objects `{ axisId, dataIndex, value }`.
61+
The `onAxisInteraction` handler is trigger each time the pointer crosses the boundaries between two axis values.
62+
Its parameter is an array of objects `{ direction, axisId, dataIndex }`.
6563
One per axis.
64+
Axes without data are ignored by the handler.
6665

6766
:::warning
68-
The handler get an array of axis value identifier.
69-
Whereas the controlled value only accept on objects.
67+
The handler gets an array of objects.
68+
Whereas the controlled value only accept one object.
7069

7170
For now highlight components assume you use the first axis.
72-
Being able to highlight any axis will arrive in further development.
7371
:::
7472

7573
{{"demo": "ControlledAxisHighlight.js"}}

0 commit comments

Comments
 (0)