score:2

Accepted answer

the problem is not your margins but where highcharts is setting up the xaxis ticks. easiest fix is to set min/max values.

$(function() {
  $('#chart-container').highcharts({
    chart: {
      type: 'area',
      renderto: 'container',
      margin: [0, 0, 0, 0]
    },
    title: {
      text: '',
      x: -20 //center
    },
    subtitle: {
      text: '',
      x: -20
    },
    exporting: {
      enabled: false
    },
    xaxis: {
      categories: ['januar', 'februar', 'marts', 'april', 'maj', 'juni', 'juli', 'august', 'septemper', 'oktober', 'november', 'december'],
      "tickwidth": 0,
      linewidth: 0,
      minorgridlinewidth: 0,
      labels: {
        enabled: false
      },
      min: 0.5, //<- added this
      max: 10.5
    },
    yaxis: {
      gridlinewidth: 0,
      minorgridlinewidth: 0,
      title: {
        text: ''
      },
      labels: {
        enabled: false
      },

    },
    tooltip: {
      valuesuffix: ' kr.'
    },
    legend: {
      layout: 'vertical',
      align: 'right',
      verticalalign: 'middle',
      borderwidth: 0
    },
    credits: {
      enabled: false
    },
    series: [{
      showinlegend: false,
      name: 'profit',
      data: [0.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
      color: '#cc0000',

    }]
  });
});
.t-box {
  background-color: #fff;
  border: 1px solid #cccccc;
  float: left;
  width: 100%;
  height: auto;
}
.chart-box {
  width: 100%;
  height: 300px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<div class="t-box">
  <div class="chart-box">

    <div id="chart-container" style="min-width: 310px; height: 100%; margin: 0 auto"></div>

  </div>
</div>


Related Query

More Query from same tag