LineChart does not render
See original GitHub issuePossible bug or user error.
Trying to render a LineChart but nothing happens
GraphData: [{MSFT: "72.58", date: 1501545600000}, {MSFT: "72.68", date: 1501545600200}, {MSFT: "72.78", date: 1501545600300} ]
StockSymbols = ['MSFT']
Code to render chart
<ResponsiveContainer width="100%" height="50%">
<LineChart data={graphData} margin={{ top: 20, right: 30, left: 0, bottom: 0 }}>
<XAxis dataKey="date"/>
<YAxis />
{stockSymbols.map(name => {
return <Line type="monotone" key={name} dataKey={name} stroke="#8884d8"/>
})}
</LineChart>
</ResponsiveContainer>
I believe the data is formatted correctly but I’m not sure as recharts throws no error
recharts v 1.0.0-beta.6 macOS High Sierra 10.13.2 Chrome 63.0.3239.84 and does not work in safari either
Any advice?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
It appears that some fixed hight must be specified to the responsive container. Also it does not complain that the data inputed is not a number. In my case the parseFloat().toFixed(2) changed the value to a string without me knowing.
In my opinion it would be good if recharts could throw an error message or something if it cannot render. This issue was caused by me and can be closed but some lessons learned maybe 😃
Hey, I was having a similar issue and not sure if you were able to fix this. For me, I realized having the data that I want to present inside quotes (i.e. ‘143.14’) doesn’t render the graph. And I see your data also has “72.58” instead of 72.58. I recommend try changing that and see if it works. Hope this helps!