javascript - 如何将 3 种颜色设置为同一个 chartjs 栏?
解决方案
我不确定您是否可以将三种颜色应用于同一个“条”(这是一个相对术语)。但我知道你有能力像这里的这个例子一样创建堆叠图表:
https://www.chartjs.org/samples/latest/charts/bar/stacked.html
关键是在设置图表选项时将stacked 属性作为true 传递。例子:
...
options: {
title: {
display: true,
text: 'Chart.js Bar Chart - Stacked'
},
tooltips: {
mode: 'index',
intersect: false
},
responsive: true,
scales: {
xAxes: [{
// MAGIC HERE
stacked: true,
}],
yAxes: [{
// AND HERE
stacked: true
}]
}
}
我希望这可以帮助你。
推荐阅读
- javascript - 如何强制正则表达式尽可能少地抓取?
- python - 问题制作 FizzBuzz
- azure - "message": "调用 Microsoft.Web/sites 失败。错误消息:SkuCode 'SKU' 无效。",
- mysql - 查询以不同方式显示表中的值
- python-3.x - 使用 Django Factory Boy,我如何为外键生成工厂?
- json - jq : 继续解析忽略无效的文字
- kotlin - 如何通过传递类型来创建类的实例
- r - ggplot:轴线、值和标签不绘图
- android - 我销毁了我的代码并想在 android studio 中恢复以前的日期
- vue.js - 在 Nuxt 的模块中使用 $axios