Horizontal stacked bar chart with chart.js(带有 chart.js 的水平堆积条形图)
问题描述
我正在尝试找出是否有任何插件可以使用 chart.js 制作水平堆积条形图
I am trying to find out if there is any plugin to do a horizontal stacked bar chart with chart.js
我看到有用于堆叠条形图和水平条形图的插件,但我没有找到将两者结合在一起的插件.
I see there are plugins for stacked bar charts and also for horizontal bar charts, but I didn't find one that combines both.
https://github.com/Regaddi/Chart.StackedBar.js
有人知道如何实现吗?
推荐答案
我知道这已经几个月了,但我想我会为后代添加我的答案.
I know this is a few months old, but I thought I'd add my answer for future generations.
我可以不用额外的插件.如果在 scales 下将 xAxes 和 yAxes 设置为stacked:true,则可以创建一个堆叠的水平图.
I was able to do without extra plugins. If you set the xAxes and yAxes to stacked:true under scales, you can create a stacked horizontal graph.
scales: {
xAxes: [{
stacked: true,
}],
yAxes: [{
stacked: true
}]
}
这是一个快速的笔来展示我是如何做到的.http://codepen.io/jamiecalder/pen/NrROeB
Here's a quick pen to show how I did it. http://codepen.io/jamiecalder/pen/NrROeB
奖励:包括在图表上显示值的代码
Bonus: Includes code to show the values on the graph
这篇关于带有 chart.js 的水平堆积条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有 chart.js 的水平堆积条形图
基础教程推荐
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
