【发布时间】:2016-02-25 21:02:40
【问题描述】:
我正在尝试制作一个可以接收 csv 并构建仪表板的通用交叉过滤器。以下是工作示例:
- https://ubershmekel.github.io/gfilter/?dl=https://ubershmekel.github.io/csvData/spent.csv
- https://ubershmekel.github.io/gfilter/?dl=https://ubershmekel.github.io/csvData/Sacramentorealestatetransactions.csv
但由于某种原因,航班数据缓慢且无响应。比较分析相同数据的这两个:
- https://ubershmekel.github.io/gfilter/?dl=https://ubershmekel.github.io/csvData/flights-3m.csv
- https://github.com/square/crossfilter
我认为这是因为直方图分箱过于详细,但我在 api 参考中找不到调整它的好方法。 @gordonwoodhull mentioned:
如果分箱是错误的,你真的想看看你设置交叉过滤器的方式 - dc.js 只是使用它给定的东西。
如何调整交叉过滤器的分箱?我试过弄乱xUnits、dimension和group四舍五入无济于事。
This is the problem code I suspect is slow/wrong:
var dim = ndx.dimension(function (d) { return d[propName]; });
if (isNumeric(data[0][propName])) {
var theChart = dc.barChart("#" + chartId);
var countGroup = dim.group().reduceCount();
var minMax = d3.extent(data, function (d) { return +d[propName] });
var min = +minMax[0];
var max = +minMax[1];
theChart
.width(gfilter.width).height(gfilter.height)
.dimension(dim)
.group(countGroup)
.x(d3.scale.linear().domain([min, max]))
.elasticY(true);
theChart.yAxis().ticks(2);
【问题讨论】:
-
Crossfilter 是一个独立于 dc.js 的库 - 您想调整调用
ndx.dimension()和dim.group()的方式。不幸的是the documentation is rather dense,但你可以从how they initialize the dimensions and groups for the crossfilter demo得到一些提示 -
这方面有进展吗?
标签: d3.js analytics dc.js crossfilter