1

So far I've been able to adjust the size of the pointWidth on a bar chart, which simply changes the width of the bar. But what I really want is the axis to also match that size. For example, take a look at this:

Highcharts.chart('container', {
  chart: {
    type: 'bar'
  },
  xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  },

  plotOptions: {
    series: {
      pointWidth: 10
    }
  },

  series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
  }]
});
<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px"></div>

The pointWidth means the bar is actually smaller, but the xAxis is actually not adjusting it's size to match it. How can I adjust that size?

b.lyte
  • 6,518
  • 4
  • 40
  • 51

1 Answers1

1

Height of each data point container is calculated depending on the height of the main container. See the 320px vs 400px container height in the example below.

var opt = {
  chart: {
    type: 'bar'
  },
  xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
  },

  plotOptions: {
    series: {
      pointWidth: 10
    }
  },

  series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
  }]
};

Highcharts.chart('container1', opt);
Highcharts.chart('container2', opt);
<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container1" style="height: 320px"></div>
<div id="container2" style="height: 400px"></div>
Dmitry
  • 6,716
  • 14
  • 37
  • 39