简体   繁体   English

dc.js 分组条形图

[英]dc.js grouped bar chart

I need to do this grouped bar chart like this one but the.renderType() doesn`t work.我需要像这样做这个分组条形图,但是 .renderType() 不起作用。 Are there any solutions to do a chart like this?有什么解决方案可以做这样的图表吗? Thanks!谢谢!

You're right, it's non-trivial to find a branch or fork of dc.js and use it in your project.你是对的,找到一个 dc.js 的分支或分支并在你的项目中使用它并非易事。

The PR you linked is rather old and was replaced by this one .您链接的 PR 相当旧,已被这个取代 Unfortunately all grouped bar implementations had design shortcomings and none are ready to merge, which is why we still have to use forks or branches of the code.不幸的是,所有分组的 bar 实现都有设计缺陷,没有一个准备好合并,这就是为什么我们仍然必须使用代码的分支或分支。

Instead of renderType the API on this fork changed to而不是renderType这个分支上的 API 改为

.groupBars(true)

The fork and branch for the new PR are here:新 PR 的 fork 和 branch 在这里:

https://github.com/jaklub/dc.js/tree/grouped-or-stacked-barshttps://github.com/jaklub/dc.js/tree/grouped-or-stacked-bars

The artifacts (dc.js and dc.css) can be found on the grouped-or-stacked-bars-artifacts branch.工件(dc.js 和 dc.css)可以在grouped-or-stacked-bars-artifacts分支上找到。

One way to fetch them is using jsdelivr:获取它们的一种方法是使用 jsdelivr:

https://cdn.jsdelivr.net/gh/jaklub/dc.js@grouped-or-stacked-bars-artifacts/dc.js
https://cdn.jsdelivr.net/gh/jaklub/dc.js@grouped-or-stacked-bars-artifacts/dc.css

Or, if you're using npm, you can declare the dependency as so:或者,如果你使用的是 npm,你可以这样声明依赖:

"dc": "git+git@github.com:jaklub/dc.js#grouped-or-stacked-bars-artifacts"

Shorter version for any recent version of npm: npm 的任何最新版本的较短版本:

"dc": "jaklub/dc.js#grouped-or-stacked-bars-artifacts"

Although this is a fork of the last major version (3) of dc, it's compatible with the latest d3, as demonstrated in this demo fiddle .尽管这是 dc 的最后一个主要版本 (3) 的一个分支,但它与最新的 d3 兼容,如演示 fiddle 中所示

分组条的屏幕截图

Clearly you need a lot more horizontal space in order to display grouped bars, but that's a separate issue.显然,您需要更多的水平空间才能显示分组条,但这是一个单独的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM