dc js - 创建多列维度 [英] dc js - Create Multiple Column Dimension

查看:169
本文介绍了dc js - 创建多列维度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 dc.js 总结数据表,我使用 dynaTable 插件用于分页和其他选项。



通常在 dc.js 数据表中,数据。但我想尝试像透视表一样汇总数据,并将其显示在网络上,当选择发生时,数据表需要更改。



通过创建,我将该组传递给 dynaTable 。它工作正常。



假设我有5列数据。我可以在它的任何列上创建一个维度。



示例:我在第一列创建一个维度,并对最后一列的值进行分组,是 A-20,B-42,C-50,D-20。。现在我的组包含那些值和变量。



但我想要创建一个包含2-3列的维度。



示例:

 
A,AA,20
A,AB,10
A,AC, 30
A,AD,80
B,BA,30
B,BB,40
B,BC,50
B,BD,90
C,CA,70
C,CB,20
C,CC,10
C,CD,80
D,DA,30
D,DB,40
D,DC,60
D,DD,80



这里是小提琴: http://jsfiddle.net/3v68c/3/

解决方案

如果你提供一个JSFiddle或类似的东西,我可以为你提供一个工作示例。但答案是肯定的,你可以根据你想要的列数定义一个维度。您只需要有一个未在任何值中使用的分隔符。假设你有列a,b和c,你将使用分隔符','。然后你:

  var xfilter = crossfilter(data); 
var multidimension = xfilter.dimension(function(d){
return d.a +','+ d.b +','+ d.c;
});


I'm trying to summarize the data table using dc.js and I'm using dynaTable plugin for for pagination and other options.

Normally in the dc.js data table we get the entire data displayed in the data. But I'm trying to summarize the data like a pivot table and display it on the web and when the selection happens the data table needs to change.

I've done it by creating a dimension and group and i passed that group to dynaTable. And it's working fine.

Suppose I have 5 columns of data. I can create a dimension on any column of it.

Example : I'm creating a dimension on the first columns and grouping on the value of the last column, say it is A-20, B-42, C-50, D-20.. Now my group contains that values and variable.

But i'm looking to create a dimension combining 2-3 columns.

Example:

A,AA,20
A,AB,10
A,AC,30
A,AD,80
B,BA,30
B,BB,40
B,BC,50
B,BD,90
C,CA,70
C,CB,20
C,CC,10
C,CD,80
D,DA,30
D,DB,40
D,DC,60
D,DD,80

Is it possible to create a dimension on multiple columns like that?

If so please help me.

Here is the fiddle: http://jsfiddle.net/3v68c/3/

解决方案

If you provide a JSFiddle or something similar I can provide you a working example. But the answer is yes, you can define a dimension based on as many columns as you want. You just need to have a delimiter that isn't used in any of the values. Let's say you have columns a, b, and c and you're going to use delimiter ',' . Then you:

var xfilter = crossfilter(data); 
var multidimension = xfilter.dimension(function (d) {   
  return d.a + ',' + d.b + ',' + d.c;
});

这篇关于dc js - 创建多列维度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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