-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[charts] Allow to specify y-axis configuration (mui#13438)
Signed-off-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Co-authored-by: Jose C Quintas Jr <juniorquintas@gmail.com>
- Loading branch information
Showing
6 changed files
with
206 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as React from 'react'; | ||
import Stack from '@mui/material/Stack'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import { SparkLineChart } from '@mui/x-charts/SparkLineChart'; | ||
|
||
const settings = { | ||
valueFormatter: (v) => `${v}%`, | ||
height: 100, | ||
showTooltip: true, | ||
showHighlight: true, | ||
}; | ||
|
||
const smallValues = [0, 2, 3, 4, 6, 8, 7, 9, 15, 6, 8, 7, 12]; | ||
const largeValues = [60, 65, 66, 68, 87, 82, 83, 89, 92, 75, 76, 77, 91]; | ||
export default function CustomYAxis() { | ||
return ( | ||
<Stack sx={{ width: '100%' }}> | ||
<Typography>Without fixed y-range</Typography> | ||
<Stack sx={{ width: '100%', mb: 2 }} direction="row" spacing={2}> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart data={smallValues} colors={['red']} {...settings} /> | ||
</Box> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart data={largeValues} {...settings} /> | ||
</Box> | ||
</Stack> | ||
<Typography>With y-range fixed to [0, 100]</Typography> | ||
<Stack sx={{ width: '100%' }} direction="row" spacing={2}> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart | ||
data={smallValues} | ||
yAxis={{ | ||
min: 0, | ||
max: 100, | ||
}} | ||
colors={['red']} | ||
{...settings} | ||
/> | ||
</Box> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart | ||
data={largeValues} | ||
yAxis={{ | ||
min: 0, | ||
max: 100, | ||
}} | ||
{...settings} | ||
/> | ||
</Box> | ||
</Stack> | ||
</Stack> | ||
); | ||
} |
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,54 @@ | ||
import * as React from 'react'; | ||
import Stack from '@mui/material/Stack'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import { SparkLineChart } from '@mui/x-charts/SparkLineChart'; | ||
|
||
const settings = { | ||
valueFormatter: (v: number | null) => `${v}%`, | ||
height: 100, | ||
showTooltip: true, | ||
showHighlight: true, | ||
} as const; | ||
|
||
const smallValues = [0, 2, 3, 4, 6, 8, 7, 9, 15, 6, 8, 7, 12]; | ||
const largeValues = [60, 65, 66, 68, 87, 82, 83, 89, 92, 75, 76, 77, 91]; | ||
export default function CustomYAxis() { | ||
return ( | ||
<Stack sx={{ width: '100%' }}> | ||
<Typography>Without fixed y-range</Typography> | ||
<Stack sx={{ width: '100%', mb: 2 }} direction="row" spacing={2}> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart data={smallValues} colors={['red']} {...settings} /> | ||
</Box> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart data={largeValues} {...settings} /> | ||
</Box> | ||
</Stack> | ||
<Typography>With y-range fixed to [0, 100]</Typography> | ||
<Stack sx={{ width: '100%' }} direction="row" spacing={2}> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart | ||
data={smallValues} | ||
yAxis={{ | ||
min: 0, | ||
max: 100, | ||
}} | ||
colors={['red']} | ||
{...settings} | ||
/> | ||
</Box> | ||
<Box sx={{ flexGrow: 1 }}> | ||
<SparkLineChart | ||
data={largeValues} | ||
yAxis={{ | ||
min: 0, | ||
max: 100, | ||
}} | ||
{...settings} | ||
/> | ||
</Box> | ||
</Stack> | ||
</Stack> | ||
); | ||
} |
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
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