'How to remove amCharts container padding?

I'm trying to remove the padding / margin of amChart.

I've tried to use am4core.percent(100) for chart.width and chart.plotContainer.width.

I'm browsing the web for a bit, without success. I don't know if it's because of the amChart logo in bottom left creating that padding.



Solution 1:[1]

    chart.paddingTop = 0;
    chart.paddingBottom = 0;
    chart.paddingLeft = 0;
    chart.paddingRight = 0;

Example: https://codepen.io/rsaraceni/pen/xxRGGvQ

Solution 2:[2]

For AmCharts 5 the correct way for setting padding to 0 is:

  const chart = root.container.children.push(am5xy.XYChart.new(root, {
    paddingRight: 0,
    paddingTop: 0,
    paddingBottom: 0,
    paddingLeft: 0,
  }));

Have a look at their doc: https://www.amcharts.com/docs/v5/reference/xychart/#paddingBottom_setting

Also knowing how a XY chart is structured in AmCharts 5 can be very handy: https://www.amcharts.com/docs/v5/charts/xy-chart/xy-chart-containers/

Solution 3:[3]

If you are using amcharts 5 I got a slightly different answer. The paddings is part of the charts "_settings" attribute

chart._settings.paddingRight = 0;
chart._settings.paddingLeft = 0;
chart._settings.paddingTop = 0;
chart._settings.paddingBottom = 0;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rsaraceni
Solution 2 Andrei T
Solution 3 syntactic