recharts / recharts

Redefined chart library built with React and D3
http://recharts.org
MIT License
23.96k stars 1.7k forks source link

brush positioning with a single data item #4844

Open tryonelove opened 2 months ago

tryonelove commented 2 months ago

Do you want to request a feature or report a bug?

I was wondering if it's the expected behavior when you pass a single data item to a chart with Brush, the traveller is rendered fully zoomed in.

image

What is the current behavior?

Traveller is rendered with the same start and end position.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar (template: https://codesandbox.io/p/sandbox/simple-line-chart-v25dl4).

https://codesandbox.io/p/sandbox/bar-chart-with-brush-forked-qs947f

What is the expected behavior?

I'd expect the traveller to fill the entire Brush, indicating that it's actually all data that can be shown at the moment.

image

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

Recharts 2.12.7, Chrome, Windows 11. Did not work in previous versions.

ckifer commented 2 months ago

Yeah that is currently the expected behavior.

If I have many data items and I reduce it to 1 with the brush then that is how it renders

image

If I start with one data item that is also how it renders. 1 === 1 so technically it should be at the same start and end position.

Maybe it should have them extended or maybe it should have the area filled in but not show the grab points at all since there is nothing to move.

But not a bug, and to change something like this would be breaking. If we were to change it we would need some rationale I think -what do other libraries with Brush components do?