Scatter Chart linear X-Axis
See original GitHub issueWhat is the current behavior?
I am trying to generate a scatter chart with some data which has an x and y values. X ranges from 1-5 and y ranges from 0-25. I just want to plot all data points into a single chart which respects the ranges as axis.
Example
My Current Component looks like this:
render() {
const { data } = this.props;
const mapped = data.map(d => {
return {
x: parseInt(d.orig_x),
y: Math.round(d.orig_y)
}
})
console.log(mapped.slice(1, 10))
const limitedData = _.sortBy(mapped.slice(1, 10), 'x')
return (
<ScatterChart width={500} height={400} margin={{ top: 20, right: 20, bottom: 20, left: 20 }}>
<XAxis dataKey="x" name='x' domain={[0, 5]} />
<YAxis dataKey="y" name='y' domain={[0, 25]} />
<CartesianGrid horizontal={false} vertical={false} />
<Scatter name='data' data={limitedData} fill='#8884d8' />
<Tooltip cursor={{ strokeDasharray: '3 3' }} />
</ScatterChart>
)
}
The current code results in a chart which looks like this:
What is the expected behavior?
The expected behaviour would be that all data points with an X value of e.g. 3 would be on the same point on the x-axis. But in the current version, there are multiple 3 on the x-axis. Is there a way to prevent this?
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
Recharts: 1.0.0-alpha.6 Browser: Chrome
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Present your data in a scatter chart or a line chart
In a scatter chart, the daily rainfall values from column A are displayed as x values on the horizontal (x) axis, and the...
Read more >Scatter Chart - Chart.js
Scatter charts are based on basic line charts with the x axis changed to a linear axis. ... The index scale is of...
Read more >Scatterplot with 2 x-axis variables in Excel - YouTube
Need to make a graph, but have two x-axis variables? In this video I show you how to plot a second x-axis variable...
Read more >4.3 The Scatter Chart - GitHub Pages
In a scatter chart, the X axis operates just like the Y axis. In other words, the distance between the values on the...
Read more >How to Make a Scatter Plot in Excel (XY Chart)
A scatter plot has dots where each dot represents two values (X-axis value and ... The above steps would add a linear trendline...
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
Try setting
allowDuplicatedCategory={false}
on the XAxis component.@KeKs0r Update the
type
of <XAxis> which has default value ‘category’.