如何使用dc.js显示行图的底部数据 [英] how to display bottom data for row chart using dc.js

查看:148
本文介绍了如何使用dc.js显示行图的底部数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Dimensional Charting javascript库dc.js制作行图,它基于d3和crossfilter。我显示的顶部(10)数据的行图,但我试图显示底部(10)数据的行图,但图形可以显示相同的顶部(10)data.how显示底部(10)数据。

I'm making a rowchart using the Dimensional Charting javascript library dc.js, which is based on d3 and crossfilter. i am display the rowchart for top(10) data.but i am trying to display rowchart for bottom(10) data but graph can be display same as the top(10) data.how to display bottom(10) data.

  constRowChart.width(350)
    .height(1000)
    .margins({top: 20, left: 120, right: 10, bottom: 20})
    .transitionDuration(750)
    .dimension(density)
    .group(const_total)
    .renderLabel(true)
    .gap(1)
    .title(function (d) {
        return "";
    })
    .elasticX(true)
    .colors(d3.scale.category20c())
    .ordering(function(d) { return d.value })
    .xAxis().ticks(3).tickFormat(d3.format("s"));

constRowChart.data(function (group) {
    return group.top(10);
});


推荐答案

如果您不想创建另一个维度/ group as @LarsKotthoff建议,你也可以使用 .top(Infinity),然后 .splice(-10)最后十个条目关闭数组。

If you don't want to create another dimension/group as @LarsKotthoff suggests, you can also use .top(Infinity) and then .splice(-10) the last ten entries off the array.

有额外的维度和排序所有数据之间存在效率权衡,因此您可以尝试查看哪些效果更好。

There are efficiency tradeoffs between having extra dimensions versus sorting all the data, so you might try both to see which performs better.

这篇关于如何使用dc.js显示行图的底部数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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