与chart.js的水平的被堆积的长条图 [英] Horizontal stacked bar chart with chart.js

查看:372
本文介绍了与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

任何人都知道如何实现这一目标?

Anyone know how to achieve this?

推荐答案

我知道这已经有几个月了,但我想我会为后代添加我的答案。

I know this is a few months old, but I thought I'd add my answer for future generations.

我没有额外的插件就能做到。如果您将xAxes和yAxes设置为堆叠: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的水平的被堆积的长条图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆