在将其他数据添加到crossfilter后,dc.js无法重绘图表。 这是我的小提琴:http://jsfiddle.net/eugene_goldberg/v6j2ujrc/24/
$ua->simple_request()
有没有办法使这项工作?
答案 0 :(得分:1)
经过一些搜索,遇到了一个小提琴(http://jsfiddle.net/eugene_goldberg/3tf725aL/2/),它有所需的技巧:
'option strict'
var data = [{
"key": "KEY-1",
"state": "CA",
"topics": ["Technology", "Science", "Automotive"],
"date": new Date("10/02/2012")
}, {
"key": "KEY-2",
"state": "CA",
"topics": ["Health"],
"date": new Date("10/05/2012")
}, {
"key": "KEY-4",
"state": "WA",
"topics": ["Automotive", "Science"],
"date": new Date("10/09/2012")
}, {
"key": "KEY-5",
"state": "WA",
"topics": ["Science"],
"date": new Date("10/09/2012")
}
];
var cf = crossfilter(data);
var states = cf.dimension(function (d) {
return d.state;
});
var stateGroup = states.group();
var pieChart = dc.pieChart("#piechart");
pieChart.height(75).width(75).dimension(states).group(stateGroup);
dc.renderAll();
setTimeout(function () {
cf.add([{
"key": "KEY-6",
"state": "MD",
"topics": ["Science"],
"date": new Date("10/09/2012")
}]);
dc.redrawAll();
}, 1000);