Recharts line chart cut off top line

B.M. Rafiul Alam

I am using recharts line chart it's working nicely but sometimes cut off top of the line. Please check the snippet in jsfiddle.

const {LineChart, Line, XAxis, YAxis, ReferenceLine, CartesianGrid, Tooltip, Legend} = Recharts;
const data = [
 {"Date":"16 May","Download":"40717"},{"Date":"17 May","Download":"39640"},{"Date":"18 May","Download":"52122"},{"Date":"19 May","Download":"51800"},{"Date":"20 May","Download":"49605"},{"Date":"21 May","Download":"45601"},{"Date":"22 May","Download":"43798"},{"Date":"23 May","Download":"36113"},{"Date":"24 May","Download":"278531"},{"Date":"25 May","Download":"323521"},{"Date":"26 May","Download":"154527"},{"Date":"27 May","Download":"119990"},{"Date":"28 May","Download":"100524"},{"Date":"29 May","Download":"83121"},{"Date":"30 May","Download":"60536"},{"Date":"31 May","Download":"58208"},{"Date":"01 Jun","Download":"304154"},{"Date":"02 Jun","Download":"538870"},{"Date":"03 Jun","Download":"213244"},{"Date":"04 Jun","Download":"130246"},{"Date":"05 Jun","Download":"104131"},{"Date":"06 Jun","Download":"72564"},{"Date":"07 Jun","Download":"69012"},{"Date":"08 Jun","Download":"96166"},{"Date":"09 Jun","Download":"89748"},{"Date":"10 Jun","Download":"80895"},{"Date":"11 Jun","Download":"155434"},{"Date":"12 Jun","Download":"81735"},{"Date":"13 Jun","Download":"56838"}
];
const SimpleLineChart = React.createClass({
    render () {
    return (
        <LineChart width={600} height={300} data={data}
            margin={{top: 0, right: 50, left: 20, bottom: 5}}>
       <CartesianGrid strokeDasharray="3 3"/>
       <XAxis dataKey="Date"/>
       <YAxis/>
       <Tooltip/>
       <Legend />

       <Line type="monotone" dataKey="Download" stroke="#8884d8" />

      </LineChart>
    );
  }
})

ReactDOM.render(
  <SimpleLineChart />,
  document.getElementById('container')
);

https://jsfiddle.net/rafiul_fiddle/tp0zL5s1/

Vivek Doshi

Issue :

The issue is due to "Download":"40717"


Solution :

convert download -> string to int

// data={data.map(d => ({...d , "Download" : +d.Download }))

<LineChart 
  width={600} 
  height={300} 
  data={data.map(d => ({...d , "Download" : +d.Download }))} // <---- HERE
  margin={{top: 0, right: 50, left: 20, bottom: 5}}>

WORKING DEMO

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

ChartJS Line chart cut off at the top and bottom

Line at the top of a ridgeline density plot is cut off

Chart.js - the rightmost data point cut off for line chart

How to remove points from line chart in ReCharts?

Line Chart Series gets cut at top Sencha touch 2 charts

d3 line chart cutting off at the top

Width of top major grid line changing when using expand=expansion() - axis line cut off

Vertical line within bars of a stacked bar chart using recharts or highcharts

Recharts: How do I label only the last point on a line chart?

Kendo Charts for Angular: Line Chart gets cut off with set max value

Overlay text on top of a Recharts chart

SVG half circle animation: line cut off

var line extend right but cut off on candle

minimum line height to ensure text is not cut off

Android: Last line of textview cut off

Drawing a line where the UIBezierPath gets cut off

How to cut off int at the end of a line

Draw line chart on top of area chart

Is there any way that I can change the color of only the clicked line in Line Chart (Recharts)?

sed: cut line X and append to top of the file

Recharts remove line from linechart

Removing tick line in recharts react

Iframe: Cut off the top

How to display the last interval as a dotted line in Recharts library with same interpolation as the chart?

How to make two gradients with different gradientUnits looks the same in recharts line chart?

Simple line chart joining top of histograms

How to plot a line on the top of a grouped bar chart?

How to add a line on top of a bar chart?

Chart.js Clipping on Top of Line Graph