Search code examples
javascriptd3.jschartslinereal-time

What are the units of d3.js zoom.translate vector?


I am trying to use the following code taken from this example to pan my time-series line-chart sideways, as new data is added to the graph:

       d3.select("path")
            .datum(globalData)
            .attr("class", "line")
            .attr("d", valueline(globalData))
        .transition()
            .ease("linear")
            .attr("transform", "translate(" + x(-dx) + ")");

But this does't work - my line disappears. I am trying to understand what the units of the translate vector need to be for this to work. In my case dx would be the difference between the first and last x-values of the new data.


Solution

  • The units used in translate are screen pixels in the default coordinate system.