javascript - Chart.js 2.7:如何在分组条上删除值为 0 的条?
问题描述
我正在尝试删除分组条形图条上值为 0 的条,但即使我在很多地方看到此解决方案,它对我也不起作用。
我创建了这个codepen。它包含一个 ChartJS 分组条形图:
Vue.component('bar-chart', {
extends: VueChartJs.Bar,
mounted () {
this.renderChart({
labels: [1500,1600,1700,1750,1800,1850,1900],
datasets: [{
data: [168,17,0,190,0,276,108],
label: "Europe",
backgroundColor: "#3cba9f",
fill: false
}, {
data: [0,202,0,161,0,38,0],
label: "Asian",
backgroundColor: "#n8c9b2",
fill: false
},{
data: [0,202,0,161,224,38,0],
label: "Latin America",
backgroundColor: "#e8c3b9",
fill: false
}, {
data: [260,43,80,82,0,26,82],
label: "North America",
backgroundColor: "#c45850",
fill: false
}]
},
{
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [{
categoryPercentage: 0.8,
barPercentage: 0.9
}],
yAxes: [{
scaleLabel: {
display: true
},
ticks: {
beginAtZero: true // minimum value will be 0.
}
}]
}
})
}
})
var vm = new Vue({
el: '.app'
})
关于如何实现想要的行为的任何想法?
解决方案
推荐阅读
- keyboard-shortcuts - Shift+Enter 在 JupyterLab 的编辑模式下不起作用
- python - 如何让 Jupyter Notebook 在顶部显示内核、小部件、Python 3?
- reactjs - 更新和删除功能后嵌套路由不重新渲染父组件?
- regex - 用列表文件中的每一行替换每个出现的单词
- reactjs - 在 React 的路由中使用重定向时出现循环问题
- reactjs - npm install npm run build --prod / build 失败 jenkins
- python - 如何在for循环中将整数附加到列表中?理解列表理解
- eloquent - Laravel 6 中 isEmpty() 和 isEmpty 的区别
- azure - 使用 ARM 创建事件网格订阅以收集订阅的事件
- directx - 如何在 DirectX 中绘制不同的几何图形?