我正在使用交叉过滤器绘制两个条形图。图表很好。但是,我想禁用第一个条形图的多选。这就是我想要做的:
var barChart2 = dc.barChart("#dc-mv-chart");
var depValue = facts.dimension(function(d) {return d.d;});
var depValueGroupSum = depValue.group().reduceSum(function(d) {return +d.g;});
var mvValue = facts.dimension(function(d,i) {return d.b;});
var mvValueGroupSum = mvValue.group().reduceSum(function(d) {return +d.g;});
barChart1.width(1200)
.height(200)
.margins({top: 10, right: 10, bottom: 20, left: 80})
.dimension(depValue)
.group(depValueGroupSum)
.transitionDuration(800)
.centerBar(true)
.gap(10)
.x(d3.scale.ordinal().domain(["AUTO & TIRES", "BABY", "CLOTHING", "ELECTRONICS", "GARDEN", "GROCERY", "HEALTH", "HOME", "HOME IMPROVEMENT", "PHOTO", "SPORTS", "TOYS", "VIDEO GAMES"]))
.elasticY(true)
.xUnits(dc.units.ordinal)
.renderHorizontalGridLines(true)
.renderlet(function (chart) {
chart.selectAll("dc-department-chart").on("click", function (d) {
chart.filter(null);
chart.filter(d.M);
})
});
//barChart1.filter = function() {}
barChart2.width(600)
.height(300)
.margins({top: 10, right: 10, bottom: 20, left: 80})
.dimension(mvValue)
.group(mvValueGroupSum)
.transitionDuration(800)
.centerBar(true)
.gap(20)
.x(d3.scale.ordinal().domain(["SEM", "SEO", "SOCIAL", "CSE", "ORGANIC", "MOBILEWEB", "AFFILIATES", "EMAIL", "DISPLAYADS"]))
.elasticY(true)
.renderHorizontalGridLines(true)
.xUnits(dc.units.ordinal);
// Render the Charts
dc.renderAll();
然而,这并没有禁用第一张图的多选。我该如何解决?
答案 0 :(得分:0)
看起来你的选择器错了,你试图选择图表ID而不是其中的条形图。请改为.selectAll('rect.bar')
。