Angular horizontal bar chart.js

jhkqcmku  于 2023-08-05  发布在  Chart.js
关注(0)|答案(1)|浏览(107)

我想创建水平条数据集:[]只给出正值,我需要在我想要的this图像之间放置y轴线,但我得到的this方式不符合我的要求。

New chart(ctx,{
type:'bar';
data:{
 datasets:[{   
     Labels: [-5,-4,-3,-2,-1,0,1,2,3,4,5]
     data:[20,40,100,80]
     Backgroundcolor: blue;
     }],

    Options:{
      responsive:true,
      indexAxis:'y',
      Scales:{
         Position:top
    }
  }
 }
}

字符串

c8ib6hqw

c8ib6hqw1#

试试这个

const config = {
  type: 'bar',
  data,
  options: {
    indexAxis: 'y',
    scales: {
      y: {
        position: 'top',
      },
    },
  },
};

const data = {
  labels: [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],
  datasets: [{
    label: 'My Dataset',
    data: [20, 40, 100, 80],
    backgroundColor: 'blue',
  }],
};

字符串

相关问题