d3js比例/轴通过(用户)选择获得刻度

时间:2018-08-02 20:49:48

标签: d3.js selection date-range axis-labels timeline

我通过d3js v5创建了一个时间刻度:

    let domain = ["1989-02-03T23:00:00.000Z","1989-02-03T23:00:00.000Z",
                  "2012-12-11T23:00:00.000Z","2013-04-11T22:00:00.000Z",
                  "1941-04-11T22:00:00.000Z","1940-03-31T23:00:00.000Z",
                  "2040-04-18T22:00:00.000Z"];

    let x = d3.scaleLinear().domain([minDate, maxDate]).range([0, verticalWidth]);

    let xAxis = d3.axisBottom(x).tickFormat(d3.timeFormat("%Y-%M-%d")).tickValues(domain);

    // TODO fix if ticks/dates to close to each other ( => overlapping)
    horizontalTreeSVG.append('g').attr("id", "xAxis")
        .call(xAxis)
        .selectAll("text")
        .style("text-anchor", "end")
        .attr("dx", "-.8em")
        .attr("dy", ".15em")
        .attr("transform", "rotate(-65)");

哪个给我这个xAxisenter image description here

现在我需要从轴中选择一个(sub)时间范围,有点像: enter image description here 并获得此选择中的刻度/日期。

我该怎么做?

0 个答案:

没有答案