d3.js:初始画笔大小/图形选择

时间:2017-12-31 14:05:09

标签: javascript d3.js

enter image description here

我目前使用d3.brush为视口设置基本线图。我输入的数据来自postgres数据库中的各种查询,因此可能会发生变化。

加载页面时,整个数据集跨越图形,下面的选择反映了该图形。有没有办法让我可以在视口中进行选择(因此图形本身)选择说,一天或几个小时左右,然后用户可以跨越这个或调整视口大小他们认为合适?

因为有时我处理的数据可能相对较大,如果我要将数百个点放入一个小区域,它会破坏很多图形。

目前,我的"刷过"功能看起来像这样:

function brushed() {
    var selection = d3.event.selection;
    console.log(x2);
    x.domain(selection.map(x2.invert, x2));
    focus.selectAll(".point")
        .attr("cx", function(d){
            var time = timeParser(d.timestamp);
            return x(time);
        })
        .attr("cy", function(d){
            return y(d.value);
        });
    focus.selectAll(".trendline")
        .attr("d", function(d){
            return line(d);
        });
    focus.selectAll(".area")
        .attr("d", function(d){
            return area(d);
        });
    focus.select(".axis.x").call(xAxis);
}

我认为x.domain的选择是一个必须在这里影响的参数吗?

0 个答案:

没有答案
相关问题