【问题标题】:DC.js - disabling brush also disables chart click events / crossfilterDC.js - 禁用画笔也会禁用图表点击事件/交叉过滤器
【发布时间】:2014-01-28 05:04:59
【问题描述】:

禁用条形图上的画笔似乎也禁用了此图表与其他图表之间的交叉过滤器。单击条形不再导致过滤其他图表数据。

我错过了什么?

  bar
    .width(100)
    .height(100)
    .margins({top: 5, right: 5, bottom: 5, left: 5})
    .dimension(dim)
    .group(tot) 
    .x(d3.scale.linear().domain([0,10]))
    .centerBar(true)
    .brushOn(false)
    .renderHorizontalGridLines(true)
    .elasticY(true)
    .yAxisLabel("Amount") 
    .yAxis().tickFormat(d3.format("s"))

【问题讨论】:

  • 您是否收到任何错误消息?
  • 不 - 单击条形图不会发生任何事情。我添加了一个点击监听器来验证点击正在被注册并且它们是。是否还有其他考虑因素可以确保该图表与所有其他图表相关联?除了这个之外,所有图表都会交叉过滤,这似乎很奇怪。

标签: javascript d3.js crossfilter


【解决方案1】:

我能够通过将比例更改为序数并添加 xUnits 来实现条形选择:

.x(d3.scale.ordinal().domain([0,1,2,3,4,5,6,7,8,9,10]))
.xUnits(dc.units.ordinal)

有趣的是,这导致条形图偏离中心。这已通过删除以下内容得到修复:

.centerBar(true)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-13
    • 1970-01-01
    相关资源
    最近更新 更多