react-chartjs-2 icon indicating copy to clipboard operation
react-chartjs-2 copied to clipboard

First and Last Points joining on re-render

Open sahilanguralla opened this issue 9 years ago • 4 comments

Hi, I am trying to draw a line graph. The issue is, on re-render first and the last point gets joined. This looks like unexpected behavior. I have added an image of the same. Graph Image

Thanks

sahilanguralla avatar Oct 15 '17 15:10 sahilanguralla

Can you upload your dataset as well?

Thanks!

jerairrest avatar Oct 15 '17 19:10 jerairrest

The dataset is dynamically generated. Below given is current graph and dataset: Graph

datasets = [   {     "data": [       {         "x": 17,         "y": "8809.22"       },       {         "x": 18,         "y": "7872.22"       },       {         "x": 19,         "y": "7479.22"       },       {         "x": 20,         "y": "5271.26"       },       {         "x": 21,         "y": "302.26"       },       {         "x": 22,         "y": "209.26"       },       {         "x": 29,         "y": "32965.26"       },       {         "x": 2,         "y": "24965.26"       },       {         "x": 4,         "y": "24865.26"       },       {         "x": 6,         "y": "24695.26"       },       {         "x": 9,         "y": "9423.26"       },       {         "x": 11,         "y": "8178.26"       },       {         "x": 13,         "y": "10495.70"       },       {         "x": 14,         "y": "10383.70"       },       {         "x": 16,         "y": "10383.70"       }     ],     "label": [],     "fill": true,     "lineTension": 0.2,     "backgroundColor": "transparent",     "borderWidth": 1.5,     "borderColor": "#afafaf",     "borderCapStyle": "round",     "borderDash": [],     "borderDashOffset": 0,     "borderJoinStyle": "round",     "pointBackgroundColor": [       "#e21f2b",       "#e21f2b",       "#e21f2b",       "#e21f2b",       "#e21f2b",       "#e21f2b",       "#06b08a",       "#e21f2b",       "#e21f2b",       "#e21f2b",       "#e21f2b",       "#e21f2b",       "#06b08a",       "#e21f2b",       "#06b08a"     ],     "pointBorderColor": "#fff",     "pointBorderWidth": 0,     "pointHoverRadius": 6,     "pointHoverBorderColor": "rgba(220,220,220,1)",     "pointHoverBorderWidth": 2,     "pointRadius": 6,     "pointHitRadius": 10   } ]

sahilanguralla avatar Oct 16 '17 05:10 sahilanguralla

Sorry, my bad. I was appending data to old dataset before clearing it.

BTW I have a question not related to this library. How can we (deep) clone a raw javascript object?

sahilanguralla avatar Oct 18 '17 08:10 sahilanguralla

https://lodash.com/docs/4.17.4#cloneDeep is what you're probably looking for. :)

jerairrest avatar Oct 18 '17 13:10 jerairrest