Sample Code
import * as React from 'react';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';
import { SparkLineChart } from '@mui/x-charts/SparkLineChart';
import { useTheme } from '@mui/material';
const BCrumb = [
{
to: '/',
title: 'Home',
},
{
title: 'BasicSparkLineCustomizationChart ',
},
];
export default function BasicSparkLineCustomizationChart() {
const [showHighlight, setShowHighlight] = React.useState(true);
const [showTooltip, setShowTooltip] = React.useState(true);
const theme = useTheme();
const primary = theme.palette.primary.main;
const handleHighlightChange = (event) => {
setShowHighlight(event.target.checked);
};
const handleTooltipChange = (event) => {
setShowTooltip(event.target.checked);
};
return (
<Stack direction="column" sx={{ width: '100%' }}>
<Stack direction="row">
<FormControlLabel
value="end"
control={
<Switch
color="primary"
checked={showHighlight}
onChange={handleHighlightChange}
/>
}
label="showHighlight"
labelPlacement="end"
/>
<FormControlLabel
value="end"
control={
<Switch
color="primary"
checked={showTooltip}
onChange={handleTooltipChange}
/>
}
label="showTooltip"
labelPlacement="end"
/>
</Stack>
<Stack direction="row" sx={{ width: '100%' }}>
<Box sx={{ flexGrow: 1 }}>
<SparkLineChart
data={[1, 4, 2, 5, 7, 2, 4, 6]}
height={100}
showHighlight={showHighlight}
showTooltip={showTooltip}
colors={[primary]}
/>
</Box>
<Box sx={{ flexGrow: 1 }}>
<SparkLineChart
plotType="bar"
data={[1, 4, 2, 5, 7, 2, 4, 6]}
height={100}
showHighlight={showHighlight}
showTooltip={showTooltip}
colors={[primary]}
/>
</Box>
</Stack>
</Stack>
);
}