Search code examples
javascriptapexcharts

ApexCharts force 100% height


I've been struggling with this problem for a while, I need to have the 100% graphic at the height of your container.

To weights that I indicate to him that his height: '100%' still follows with spaces above and below, tabiem I gave false value to yaxis but still the problem persists.

Someone who can solve it would appreciate it.

var options = {
  chart: {
    type: 'line',
    width: '100%',
    height: '100%',
    toolbar: {
      show: false
    },
  },
  grid: {
    show: false,
    padding: {
      left: 0,
      right: 0
    }
  },
  tooltip: {
    intersect: false,
    x: {
      show: false
    },
    marker: {
      show: false
    }
  },
  dataLabels: {
          enabled: false
        },
  yaxis: {
    show: false,
  },
  xaxis: {
    tooltip: {
      enabled: false
    },
    labels: {
      show: false
    },
    axisBorder: {
      show: false
    }
  },
  

  series: [{
    name: 'sales',
    data: [30,40,35,50,49,60,70,91,125]
  }]
}

var chart = new ApexCharts(document.querySelector("#chart"), options);

chart.render();
#chart{
  width: 500px;
  height: 200px;
  border: 1px solid #000;
}
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>

<div id="chart"></div>


Solution

  • If you don't need x-axis, y-axis to be displayed, you can turn on the sparkline.enabled flag to remove all unnecessary spaces above and below chart area

    chart: {
       sparkline: {
          enabled: true
       }
    }