score:0

you can have dynamic configuration for bar as well as horizontalbar you can use this configurations

fiddle demo

var data = {
  labels: ["label1", "label2", "label3", "label4", "label5"],
  datasets: [{
    "label": "total v",
    "yaxisid": "a",
    "backgroundcolor": "rgba(53,81,103,1)",
    "bordercolor": "rgba(53,81,103,.4)",
    "data": [100, 90, 80, 70, 60]
  }, {
    "label": "total c",
    "yaxisid": "a",
    "backgroundcolor": "rgba(255,153,0,1)",
    "bordercolor": "rgba(255,153,0,.4)",
    "data": [10, 9, 8, 7, 6]
  }]
};

var options = {
  scales: {
    yaxes: [{
      id: 'a',
      position: 'left'
    }]
  }
};

var ctx = document.getelementbyid("mychart");
new chart(ctx, {
  type: "horizontalbar",
  data: data,
  options: options
});

coming to your question the actual problem is with var options={...} it is made to work only with bar charts. hope you understand

update

replace following as option in the chart above for required axis scales

var options = {scales:{yaxes:[{id: 'a',position: 'left',gridlines:{color:"rgba(53,81,103,.4)"}},{position:"top",id:"c", gridlines:{color:"rgba(255,153,0,.4)"},ticks: { min: 0,max: 100,}},]}};

updated fiddle

score:0

basically you will need a y-axis for the first dataset which going to hold the labels. and you will need two x-axis for showing the values in the top and in the bottom.

the second dataset will go to the x-axis which is shown at the top.

working fiddle included:

{
  scales: {
    yaxes: [{
      id: 'a',
      position: 'left',
      display: true,
      gridlines: {
        color: "rgba(53,81,103,.4)"
      }
    }, ],
    xaxes: [{
      barpercentage: 0.4,
      display: true,
      id: "1",
      position: 'bottom',
      ticks: {
        fontcolor: 'rgb(0, 0, 0)'
      },
      fontsize: 500,
    }, {
      stacked: false,
      barpercentage: 1,
      display: true,
      type: 'linear',
      id: '2',
      position: 'top',
      ticks: {
        fontcolor: 'rgb(0, 0, 0)'
      },
      fontsize: 500,
    }],
  }
};

fiddle for two axis horizontal bar chart


Related Query

More Query from same tag