Im trying to get the value of the brush in a d3.js chart.

_chart.brush().value; 

I just want to get the value of the range of the brush when you select a range in the chart.

有帮助吗?

解决方案

I think you might be looking for

brush.extent()

Note that a brush is associated with x- and y- scales and these determine what the extent call returns.

Typically you use a brush with a quantitative scale which means the extent should give you a value from the scale's domain (data space) but if you use an ordinal scale then the extent will return values form the scale's range (pixel space).

The other thing to note is that you can get a simple range back if the brush only has one scale associated (x or y) but will give you a 2-d matrix if you've set both scales.

Have a look here for details.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top