Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double X-axis within same Highchart object

I am able to make the below chart with two different highchart objects. But I need to make it with a single highchart object ( within the same Y-axis, I want to apply two series data in two X-axis).

barchart

like image 658
Mohammad Habibur Rahman Avatar asked Apr 22 '26 04:04

Mohammad Habibur Rahman


1 Answers

You can achieve it easily using two xAxis and two series bonded to them:

Code:

Highcharts.chart('container', {
	chart: {
  	type: 'bar'
  },
  xAxis: [{
  	height: '50%',
    opposite: true
  }, {
  	height: '50%',
    top: '50%',
    offset: 0,
    opposite: true
  }],
  yAxis: {
  	reversed: true
  },
  plotOptions: {
  	series: {
    	pointPadding: 0,
      groupPadding: 0,
      borderWidth: 0
    }
  },
  series: [{
  	xAxis: 0,
    data: [
      439,
      525,
      571,
      696,
      970,
      119
    ]
  }, {
  	xAxis: 1,
  	data: [
    	234,
      123,
     	444,
      322,
      543,
      657
    ]
  }],
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container"></div>

Demo:

  • https://jsfiddle.net/BlackLabel/nh7Lmkqc/
like image 66
Wojciech Chmiel Avatar answered Apr 25 '26 00:04

Wojciech Chmiel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!