在dc.js条形图上绘制组的最高值 [英] Plotting top values of a group on dc.js bar chart

查看:59
本文介绍了在dc.js条形图上绘制组的最高值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图仅绘制特定Crossfilter的 top(n)最小(n)值组在dc.js中,但我不确定如何实现。我已经在 console.log()中检查了我的组正在根据需要返回值,但是如何在图表中绘制这些最高值?

I'm trying to plot only top(n) or least(n) values of a particular Crossfilter group in dc.js, but I'm not sure how to achieve this. I've checked it in console.log() that my group is returning values as needed, but how can I plot those top values in the chart?

groupForBandwidthConsumed = dimByOrgName.group().reduceSum(function (d) {
return d.bandwidthConsumed;
});
groupForBandwidthConsumed.top(Infinity).forEach(function (d) {
console.log(d.key, d.value);
});

我读到 .data()函数有助于做到这一点,但不适用于条形图。有人可以解释一下我该怎么做吗?

I read that .data() function helps in doing this but it doesn't work with bar chart. Can somebody explain me how to do this?

这里是 JSFiddle 显示我正在处理的条形图。

Here is the JSFiddle for the bar chart I'm working on.

推荐答案

好吧,我能够使用假分组的想法自己整理出来。

Well, I was able to sort it out myself using 'fake grouping' idea.

function getTops(source_group) {
return {
    all: function () {
        return source_group.top(2);
    }
};
}
var fakeGroup = getTops(groupForBandwidthConsumed);

然后将group属性修改为: .group(fakeGroup) ... JSFiddle

Then modified the group attribute as: .group(fakeGroup)... JSFiddle

这篇关于在dc.js条形图上绘制组的最高值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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