Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant design Area chart - remove canvas margins

Im trying to set Ant Desing Area chart to not have margin/padding on the sides so my chart will perfectly fit inside the wrapping container - but for some reason i couldn't find the attribute for that on Ant's documentation. Also i would like the Chart to start from 0 on the Y axis i tried the "beginAtZero" attribute but also didnt worked

these are my configurations:

const config = {
    height: 60,
    data: volumeData,
    autoFit: true,
    xField: "date",
    yField: "count",
    padding: [5],
    xAxis: false,
    yAxis: false,
    color: "#916afc",
    legend: false,
    point: {
      shape: 'circle'
    },
  };

wrpper container css

    width: 100%;
    background-color: #ffffff;
    box-shadow: 0px 5px 10px rgb(0 0 0 / 5%);
    border-radius: 10px;
    padding: 20px;

and the chart:

<Area {...config} />

enter image description here

like image 759
Raz Avatar asked Oct 19 '25 04:10

Raz


1 Answers

You should set the scale.min of y field to 0.

{ 
  /* ... */
  meta: {
    count: { min: 0 }
  }
}

Then the y axis will start wiht zero.

like image 74
atool Avatar answered Oct 21 '25 17:10

atool



Donate For Us

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