Brush can't be used with ScatterChart
See original GitHub issueWhen I try to use a Brush
with a ScatterChart
, no Brush
shows up, and no warning or error is visible. Is this expected behavior? Because of this issue, I am now trying to create a scatter-like chart from of a LineChart
(in order to get Brush
functionality) but it is a lot more difficult.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Brushing Scatter Plots Example - Vega & Vega-Lite
This example uses an interactive scatter plot matrix of penguin measurements, and echoes the original Brushing Scatterplots paper by Becker & Cleveland. Click ......
Read more >Creating a scatter plot with brush using D3.js v4 - Raj Vansia
Today we will be creating the above graph which will give you the basic recipe to create a scatterplot with brush functionality in...
Read more >Brushing Scatterplots
Brushing is a collection of dynamic methods for viewing multidimensional data. It is very effective when used on a scatterplot matrix, a rectangular...
Read more >Can you build a dynamic scatter plot with proportional brushing?
The scatter plot is built to be dynamic, with both the axes and ... used Orders – I chose to use Orders too...
Read more >echarts - Brush by default active on scatter chart - Stack Overflow
Similarly you can enable any echarts toolbar feature using the same mechanism. Note: If you are using latest EChart then you may have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@xile611 Why do the docs have
<ScatterChart />
listed as a parent of<Brush />
then?I’m not sure this solution works in general. The
startIndex
andendIndex
are compared to thehour
column of yourdata
. What if there are some hours missing from the data, which is possible in a scatter plot? What if there are multiple y-values for a given x-axis?I think Recharts Brush assumes that
startIndex
andendIndex
are indices into the data passed to the ScatterChart. However, for any value of x there can be multiple y values and vice versa. There is only one data point for any given x and y value, then Brush might work for the Scatter. But if not, let’s say the the Brush is configured (via its dataKey property) to limit the data based on the x-axis and there are a few values of x that appear multiple times in the data because there are multiple y values for that x. When the user changes the startIndex, the Brush’s onChange is called with a startIndex that refers to the original data array, not to the domain of the x-axis.For example, let’s say we have the following data:
Let’s assume the XAxis’s dataKey is x and so it the Brush’s. Since there are 3 entries in the data array, the Brush will initialize to startIndex=0 and endIndex=2. If the user slides the left Brush traveler from startIndex 0 to startIndex 2, then what should happen? It will remove the first two data points from the data and only show the final one. However, data[1] and data[2] share the same x coordinate. That sounds like a very goofy user experience. Probably what’s desired is for the Brush’s startIndex and endIndex to refer to the unique values for the XAxis. But instead if refers to the data’s indices.
Another issue is the label on the Brush which should only ever say on x-value a single time but since it actually refers to the data, when the user slides the traveler, the label could end up saying the same value twice.
I have been able to get a solution to work with a slider widget (https://mui.com/material-ui/react-slider/) that’s not part of Recharts. I just pass it the unique values of my x-axis and use its
onChange
. Here is a rough sketch using the example from above: