Search code examples
d3.jschartsbrush

Brush.extent is returning wrong yMax and yMin values


I am using brush.extent to get the brush coordinates on my bubble chart. At the beginning it works just fine. After I zoom the chart, then the y coordinates are lower than 1 always. But the x coordinates are just fine.

I assume this happening because of d3.Call (yAxis), which is a linear axis.

I was trying to take care the scale value and multiply the yMin and yMax with a bigger value:

yMin = extent[0][1] * 800/scaleValue and yMax = extent[1][1] * 800/scaleValue

It works better, but still this is not working correctly. I write 800, because it gave me the best results while trying.


Solution

  • For anyone facing the same problem:

    Setting the domain while creating the datatype based on scale:

    before I had:

    d3.scale.linear().range([min, max])
    

    Now:

    d3.scale.linear().domain([0 , 1000 ]).range([min, max])
    

    Suggestion: don't use hardcoded values to set the domains. I did it just to be understandable.