-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '587f7c5757e0d66222ea1f3d37c923a0814e9d86' into axis-siz…
…e-poc
- Loading branch information
Showing
90 changed files
with
1,244 additions
and
560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
Broken links found by `docs:link-check` that exist: | ||
|
||
- https://mui.com/x/react-charts/getting-started/ | ||
- https://mui.com/x/react-data-grid/#premium-plan | ||
- https://mui.com/x/react-data-grid/getting-started/ | ||
- https://mui.com/x/react-data-grid/getting-started/#feature-comparison | ||
- https://mui.com/x/react-date-pickers/fields/#accessible-dom-structure | ||
- https://mui.com/x/react-date-pickers/getting-started/ | ||
- https://mui.com/x/react-date-pickers/quickstart/#date-and-time-types | ||
- https://mui.com/x/react-tree-view/#rich-tree-view | ||
- https://mui.com/x/react-tree-view/#simple-tree-view | ||
- https://mui.com/x/react-tree-view/getting-started/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import * as React from 'react'; | ||
import { ChartsXAxis } from '@mui/x-charts/ChartsXAxis'; | ||
import { ChartsYAxis } from '@mui/x-charts/ChartsYAxis'; | ||
import { LinePlot } from '@mui/x-charts/LineChart'; | ||
import { useLineSeries, useXAxis, useXScale, useYScale } from '@mui/x-charts/hooks'; | ||
import { ChartsSurface } from '@mui/x-charts/ChartsSurface'; | ||
import { ChartDataProvider } from '@mui/x-charts/ChartDataProvider'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
|
||
function ExtremaLabels() { | ||
const lineSeries = useLineSeries(); | ||
|
||
if (!lineSeries) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
{lineSeries.seriesOrder.map((seriesId) => ( | ||
<SingleSeriesExtremaLabels series={lineSeries.series[seriesId]} /> | ||
))} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function SingleSeriesExtremaLabels({ series }) { | ||
const xAxis = useXAxis('x'); | ||
|
||
const min = series.data.reduce( | ||
(acc, value, index) => | ||
value != null && value < acc.value ? { index, value } : acc, | ||
{ index: -1, value: Infinity }, | ||
); | ||
const max = series.data.reduce( | ||
(acc, value, index) => | ||
value != null && value > acc.value ? { index, value } : acc, | ||
{ index: -1, value: -Infinity }, | ||
); | ||
|
||
return ( | ||
<React.Fragment> | ||
<PointLabel | ||
x={xAxis.data?.[min.index]} | ||
y={min.value} | ||
placement="below" | ||
color={series.color} | ||
/> | ||
<PointLabel | ||
x={xAxis.data?.[max.index]} | ||
y={max.value} | ||
placement="above" | ||
color={series.color} | ||
/> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function PointLabel({ x, y, placement, color }) { | ||
const xAxisScale = useXScale(); | ||
const yAxisScale = useYScale(); | ||
|
||
const left = xAxisScale(x) ?? 0; | ||
const top = (yAxisScale(y) ?? 0) + (placement === 'below' ? 20 : -20); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
position: 'absolute', | ||
left, | ||
top, | ||
translate: '-50% -50%', | ||
border: `2px solid ${color}`, | ||
borderRadius: 1, | ||
px: 1, | ||
}} | ||
> | ||
<Typography variant="caption">{y}</Typography> | ||
</Box> | ||
); | ||
} | ||
|
||
export default function SeriesDemo() { | ||
return ( | ||
<Box sx={{ position: 'relative', width: '100%' }}> | ||
<ChartDataProvider | ||
xAxis={[{ id: 'x', data: [1, 2, 3, 5, 8, 10] }]} | ||
series={[ | ||
{ id: 'a', type: 'line', data: [4, 6, 4, 9, 3, 5] }, | ||
{ id: 'b', type: 'line', data: [3, 7, 8, 2, 4, 9] }, | ||
]} | ||
yAxis={[{ min: 0, max: 10 }]} | ||
height={300} | ||
> | ||
<ChartsSurface> | ||
<LinePlot /> | ||
<ChartsXAxis /> | ||
<ChartsYAxis /> | ||
</ChartsSurface> | ||
<ExtremaLabels /> | ||
</ChartDataProvider> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import * as React from 'react'; | ||
import { ChartsXAxis } from '@mui/x-charts/ChartsXAxis'; | ||
import { ChartsYAxis } from '@mui/x-charts/ChartsYAxis'; | ||
import { LinePlot } from '@mui/x-charts/LineChart'; | ||
import { useLineSeries, useXAxis, useXScale, useYScale } from '@mui/x-charts/hooks'; | ||
import { ChartsSurface } from '@mui/x-charts/ChartsSurface'; | ||
import { ChartDataProvider } from '@mui/x-charts/ChartDataProvider'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import { DefaultizedLineSeriesType } from '@mui/x-charts/models'; | ||
|
||
function ExtremaLabels() { | ||
const lineSeries = useLineSeries(); | ||
|
||
if (!lineSeries) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
{lineSeries.seriesOrder.map((seriesId) => ( | ||
<SingleSeriesExtremaLabels series={lineSeries.series[seriesId]} /> | ||
))} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function SingleSeriesExtremaLabels({ | ||
series, | ||
}: { | ||
series: DefaultizedLineSeriesType; | ||
}) { | ||
const xAxis = useXAxis('x'); | ||
|
||
const min = series.data.reduce( | ||
(acc, value, index) => | ||
value != null && value < acc.value ? { index, value } : acc, | ||
{ index: -1, value: Infinity }, | ||
); | ||
const max = series.data.reduce( | ||
(acc, value, index) => | ||
value != null && value > acc.value ? { index, value } : acc, | ||
{ index: -1, value: -Infinity }, | ||
); | ||
|
||
return ( | ||
<React.Fragment> | ||
<PointLabel | ||
x={xAxis.data?.[min.index]} | ||
y={min.value} | ||
placement="below" | ||
color={series.color} | ||
/> | ||
<PointLabel | ||
x={xAxis.data?.[max.index]} | ||
y={max.value} | ||
placement="above" | ||
color={series.color} | ||
/> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function PointLabel({ | ||
x, | ||
y, | ||
placement, | ||
color, | ||
}: { | ||
x: number; | ||
y: number; | ||
placement: 'above' | 'below'; | ||
color: string; | ||
}) { | ||
const xAxisScale = useXScale(); | ||
const yAxisScale = useYScale(); | ||
|
||
const left = xAxisScale(x) ?? 0; | ||
const top = (yAxisScale(y) ?? 0) + (placement === 'below' ? 20 : -20); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
position: 'absolute', | ||
left, | ||
top, | ||
translate: '-50% -50%', | ||
border: `2px solid ${color}`, | ||
borderRadius: 1, | ||
px: 1, | ||
}} | ||
> | ||
<Typography variant="caption">{y}</Typography> | ||
</Box> | ||
); | ||
} | ||
|
||
export default function SeriesDemo() { | ||
return ( | ||
<Box sx={{ position: 'relative', width: '100%' }}> | ||
<ChartDataProvider | ||
xAxis={[{ id: 'x', data: [1, 2, 3, 5, 8, 10] }]} | ||
series={[ | ||
{ id: 'a', type: 'line', data: [4, 6, 4, 9, 3, 5] }, | ||
{ id: 'b', type: 'line', data: [3, 7, 8, 2, 4, 9] }, | ||
]} | ||
yAxis={[{ min: 0, max: 10 }]} | ||
height={300} | ||
> | ||
<ChartsSurface> | ||
<LinePlot /> | ||
<ChartsXAxis /> | ||
<ChartsYAxis /> | ||
</ChartsSurface> | ||
<ExtremaLabels /> | ||
</ChartDataProvider> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<ChartDataProvider | ||
xAxis={[{ id: 'x', data: [1, 2, 3, 5, 8, 10] }]} | ||
series={[ | ||
{ id: 'a', type: 'line', data: [4, 6, 4, 9, 3, 5] }, | ||
{ id: 'b', type: 'line', data: [3, 7, 8, 2, 4, 9] }, | ||
]} | ||
yAxis={[{ min: 0, max: 10 }]} | ||
height={300} | ||
> | ||
<ChartsSurface> | ||
<LinePlot /> | ||
<ChartsXAxis /> | ||
<ChartsYAxis /> | ||
</ChartsSurface> | ||
<ExtremaLabels /> | ||
</ChartDataProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.