使用chart.js制作浮动条形图的麻烦

问题描述 投票:1回答:1

据此chart.js支持此(https://github.com/chartjs/Chart.js/pull/5262)浮动条

所以我尝试了,但是没有得到结果。这是我的代码示例:

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>
<body>
  <div class = "container">
    <canvas id="myChart3"></canvas>
  </div>
</body>
<script>
let myChart3 = document.getElementById('myChart3').getContext('2d');
let massPopChart3 = new Chart(myChart3, {
type:'bar',
data:{
  labels:[1,2],
  datasets:[{
    label:'data1',
    data:[[2,10],[3,2]],
    backgroundColor:'rgba(255,99,132, 0.6)'
  }]
},
options: {
  responsive: true,
  legend: {
    position: 'top',
  },
  title: {
    display: true,
    text: 'Chart.js Bar Chart'
    }
  }
})
</script>

下面是chartjs提供的工作示例http://pravopys.net/chartjs/samples/charts/bar/vertical.html

charts chart.js
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.