Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ApexCharts Remove extra bottom padding

I have the following bar chart configuration.

const series = [
    {
      name: 'Net Profit',
      data: [18, 34, 55, 57, 80, 70],
    },
  ];
  const options = {
    chart: {
      type: 'bar',
      height: '50px',
      toolbar: {
        show: false,
      },
    },
    grid: {
      show: false,
      padding: {
        top: 0,
        bottom: 0,
      },
      xaxis: {
        lines: {
          show: false,
        },
      },
      yaxis: {
        lines: {
          show: false,
        },
      },
    },
    plotOptions: {
      bar: {
        horizontal: false,
        columnWidth: '80%',
        barHeight: '100%',
      },
    },
    dataLabels: {
      enabled: false,
    },
    stroke: {
      show: false,
      width: 0,
      colors: ['transparent'],
    },
    fill: {
      opacity: 1,
      colors: [
        '#000000',
        '#B32824',
        '#1A73E8',
        '#B32824',
        '#1A73E8',
        '#B32824',
      ],
      type: 'solid',
    },
    tooltip: {
      enabled: false,
    },
    xaxis: {
      axisTicks: {
        show: false,
      },
      axisBorder: {
        show: false,
      },
      labels: {
        show: false,
      },
    },
    yaxis: {
      axisTicks: {
        show: false,
      },
      axisBorder: {
        show: false,
      },
      labels: {
        show: false,
      },
    },
  };

I am getting extra padding at the bottom as below. how can I remove that? enter image description here

like image 680
Harsha M V Avatar asked Oct 17 '25 12:10

Harsha M V


1 Answers

If you don't want to show x-axis and y-axis in your chart, you can simply do

const options = {
  chart: {
    type: 'bar',
    height: '250px',
    sparkline: {
      enabled: true
    }
  },
}

The sparkline option will remove all paddings/margins around the chart.

like image 71
junedchhipa Avatar answered Oct 19 '25 01:10

junedchhipa