React-chartjs-2: Reload on height and width changes

Created on 21 Nov 2016  路  10Comments  路  Source: reactchartjs/react-chartjs-2

I am trying to reload if height and width change. I can't find any methods to do that.

Are there any plans to add this functionality?

Most helpful comment

hey @volkandkaya ,

I have an issue with getting tests to pass on Travis, while working nicely locally..
So besides that there are no issues on merging it in.

I need to think whether I can skip that test stuff for now.
Will let you know shortly.

All 10 comments

hey @volkandkaya ,

I have #59 open which should include that possibility too, needs a bit fine tuning and then it's ready to go.

@gor181 how long until it will be ready for use? This package is perfect except for the reloading.

hey @volkandkaya ,

I have an issue with getting tests to pass on Travis, while working nicely locally..
So besides that there are no issues on merging it in.

I need to think whether I can skip that test stuff for now.
Will let you know shortly.

hey @volkandkaya ,

1.6.0 has been released.

Basically all you need is to modify the width or / and height props.
let me know how it goes.

Thanks, I can't get it working. It refreshes but the height and width don't change.

However I was also changing the colours and that didn't work, after 1.6 it now works which is great. So I am not sure why height and width don't work.

hey,

I would suggest to add the div with style (width, height) around as we render only canvas element which width/height seems to be overriden by chart.js regardless of what options are set.

Is there anyway to force a refresh, if I switch using react-router it fixes itself.

I had to use
<ChartComponent key={chart.height * chart.width} />

Key basically makes it re-render.

Tried redraw={true} ?

Didn't work. I will stick to key for now. Thanks for all the help.

This is still a problem for me. I also ended up using

key={`${width}x${height}`}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexchoiweb picture alexchoiweb  路  3Comments

ekobayu picture ekobayu  路  5Comments

jbbae picture jbbae  路  5Comments

flyingpath picture flyingpath  路  5Comments

LuizMoreira picture LuizMoreira  路  3Comments