reactjs - 如何在堆叠条之间添加间隙
问题描述
问题是我找不到在堆叠条之间添加间隙的方法,所以我最终得到了这样的图表:
我正在使用 react-chartjs-2 版本 3.0.4,我的代码是:
<Bar
data={{
labels: ['1', '2', '3', '4', '5', '6'],
datasets: [
{
label: 'First',
data: [65, 59, 80, 81, 56, 55],
backgroundColor: 'rgba(30,223,129, 0.8)',
borderColor: 'transparent',
borderWidth: 0,
barThickness: 60,
},
{
label: 'Second',
data: [20, 30, 78, 26, 45, 22],
backgroundColor: 'rgba(181,190,232,0.8)',
borderColor: 'transparent',
borderWidth: 0,
barThickness: 60,
}
]
}}
options={{
plugins: {
legend: {
display: false,
},
},
scales: {
x: {
display: false,
ticks: {
display: false,
},
grid: {
display: false,
},
stacked: true,
},
y: {
grid: {
drawBorder: false,
lineWidth: 0.6,
},
ticks: {
display: false,
},
},
}
}}/>
解决方案
推荐阅读
- angularjs - 将鼠标悬停在按钮上时,角度 ui 工具提示会触发其他按钮的 ng-disabled
- python-3.x - 检查按钮列表是否有文本
- r - 这是 R 3.5 中的错误吗?
- javascript - 更优雅的创建对象的方式
- java - 如何覆盖 jar 中捆绑的 database.properties
- algorithm - 用一条线将一组圆分成两等分
- multithreading - Sys.set_signal 在主线程上中断 input_line,但在子线程中不中断
- java - ActiveMQMessageConsumer 仅在 5 秒内从 Java 上的 Topic 接收消息
- angular - 如何在数组中分配随机颜色?
- git - 澄清 gitignore 文档