How to create interaction with selectMenu in dc.js

只谈情不闲聊 提交于 2019-12-07 12:02:31

There are two bugs here, one in dc.js and one in your code.

First, it looks like the selectMenu has not been debugged for non-string keys. It is filtering on the value it retrieves from the <option> tag, which has been converted to a string.

As usual, there is a workaround. You can explicitly convert the strings to dates before they get to the dimension by changing the filterHandler:

var oldHandler = selectField2.filterHandler();
selectField2.filterHandler(function(dimension, filters) {
  var parseFilters = filters.map(function(d) { return new Date(d);})
  oldHandler(dimension, parseFilters);
  return filters;
});

Second, you have a copy-paste bug in your code. You've got the right idea assigning a fresh dimension and group to each chart, but groupdate and groupline should each draw from the corresponding dimension:

var groupdate = dimdate.group().reduceSum(function(d){return d.ead/1000000;});
var groupline = dimline.group().reduceSum(function(d){return d.ead/1000000;});

Working fork of your fiddle: http://jsfiddle.net/gordonwoodhull/uterbmhd/9/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!