可以使用DC.js控件来过滤D3.js控件吗?

时间:2016-06-23 20:59:48

标签: d3.js dc.js

有许多示例显示DC.js控件之间的无缝分组和过滤。但是,可以使用DC控件来过滤D3.js控件显示的结果吗? (例如:DC pieChart用于按颜色组过滤D3力导向图表)

所需的结果是从饼图中选择颜色组,并让它从D3控件中过滤节点。我理解2可以在同一页面上共存;然而,DC能否以这种方式与D3相互作用,还是存在不同的方法?

示例(伪代码)

//Color Group Data
data = [
    {
     "Group": "Orange",
     "Color": "Coral"
    },
    {
     "Group": "Orange",
     "Color": "Dark Orange"
    },
    {
     "Group": "Yellow",
     "Color": "LemonChiffon"
    },
    {
     "Group": "Yellow",
     "Color": "PapayaWhip"
    },
    ...
]

//Crossfilter Code Here to establish Dimension
var ndx = crossfilter(data);
groupDim = ndx.dimension(function(d) {return "" + d.Group;}); 


//Pie Chart to Display Simple Colors
var colorsChart = dc.pieChart("chartColors");
...
dc.renderAll(); 


//Force Directed chart, would be used to display all nodes of colors
var force = d3.layout.force()
.charge(-120)
.linkDistance(30)
.size([width, height]);

var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);

... 

0 个答案:

没有答案