
Notice how the line at the top of the chart is thinner than the lines inside the plotting area, because it lands on the edge.
How can I fix this?
I tried adding a margin property, but that adds space around the entire chart component, instead of increasing the plotting area. I don't want my points landing right on the edge. This is a common configuration in charting libraries.
<LineChartPro
width={600}
height={300}
/>
Looking at the MUI X Charts 7+ docs, one possible solution could be adding a prop like this.
margin={{ left: 30, right: 30, top: 30, bottom: 30 }}
as seen here https://mui.com/x/react-charts/lines/#system-GridDemo.js
<LineChart
dataset={dataset}
xAxis={[{ dataKey: 'x' }]}
series={[{ dataKey: 'y' }]}
height={300}
margin={{ left: 30, right: 30, top: 30, bottom: 30 }}
grid={{ vertical: true, horizontal: true }}
/>
As you can see below, if i set the margin to 0 on all sides, the x and y axis are not in view, which is similar to your problem where the top of the chart isn't in view. Presumably, if you set the margin top to be greater, it will look as expected

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With