Search code examples
paddingamchartsamcharts4

AmCharts4 Remove Padding / Margin between Graph and Container


Is there a way to remove the padding between the container and the graph in AmCharts4?

I have tried chart.padding(0, 0, 0, 0) but it doesn't have an effect.

https://codepen.io/ChazUK/pen/JjKVvNv

const chart = am4core.create('chart', am4charts.GaugeChart);
chart.innerRadius = am4core.percent(80);
chart.logo.disabled = true;
chart.responsive.enabled = true;

... rest in codepen

Remove Padding


Solution

  • You need to increase the outer radius of the gauge, and also set padding to 0 on all edges of the chart itself:

    chart.radius = am4core.percent(100);
    chart.innerRadius = am4core.percent(80);
    chart.paddingTop = 0;
    chart.paddingRight = 0;
    chart.paddingBottom = 0;
    chart.paddingLeft = 0;