Warm tip: This article is reproduced from serverfault.com, please click

Higcharts population pyramid with csv data

发布于 2020-11-30 17:51:24

I want to create a population pyramid with CSV data in highcharts. But the second (right) x-axis is not labeled correctly. Instead of the age groups the Ids of the bars appear. How can I label the right x-axis analogous to the left x-axis?

Jsfiddle: https://jsfiddle.net/martindfurrer/d4r0oxc9/

xAxis: [{
   type: 'category',
   reversed: false,
   title: {
      text: 'Age category',
   },
}, { // mirror axis on right side
   opposite: true,
   linkedTo: 0,
   type: 'category',
   reversed: false,
   title: {
      text: 'Age category',
   },
}],
Questioner
Martin F.
Viewed
0
Sebastian Wędzel 2020-12-01 17:06:21

You need to define which series belongs to that second xAxis.

  series: [{
      name: 'Foreign men',
    },
    {
      name: 'Swiss men',
    },
    {
      name: 'Foreign women',
            xAxis: 1
    },
    {
      name: 'Swiss women ',
            xAxis: 1
    },
  ],

Demo: https://jsfiddle.net/BlackLabel/rk4bufx7/

API: https://api.highcharts.com/highcharts/series.line.xAxis