score:0

please read the documentation to understand how the data is populated.

all the properties in labels corresponds to what is to be shown in the xaxis in your case it is inverted.

the number of items in the datasets corresponds to the legend and the label property of each dataset is used as the text for the legend.

please see the changes code as per my understanding of your problem or fiddle -> https://jsfiddle.net/bcxzu39v/

var mesecontext = document.getelementbyid("mesestatuscanvas").getcontext("2d");
var mesedata = {
  labels: [
    "amer",
    "apac",
    "emea"
  ],
  datasets: [{
      label: ['sfo'],
      data: [23.2, 0, 0],
      backgroundcolor: 'red'
    },
    {
      label: ['chi'],
      data: [6.3, 0],
      backgroundcolor: 'brown'
    },
    {
      label: ['india'],
      data: [0, 3, 0],
      backgroundcolor: 'green'
    },
    {
      label: ['anz'],
      data: [0, 7, 0],
      backgroundcolor: 'lightgreen'
    }
  ]
};

var mesechart = new chart(mesecontext, {
  type: 'horizontalbar',
  data: mesedata,
  options: {
    responsive: true,
    scales: {
      xaxes: [{
        stacked: true,
      }],
      yaxes: [{
        stacked: true,

      }]
    }
  }
});

Related Query

More Query from same tag