React-chartjs-2: Bar Chart resizes incorrectly (funky responsive issue)

Created on 20 Nov 2017  路  5Comments  路  Source: reactchartjs/react-chartjs-2

There's some weird behavior when resizing an app that uses Bar Charts. This behavior can be seen right on the docs page: http://jerairrest.github.io/react-chartjs-2/

Video (click to view):

Alt text

Environment info:

  • Chrome 62.0.3202.94 (latest)
  • macOS High Sierra 10.13.1

react-chartjs-2 versions

  • 2.4.0 (public docs page linked above)
  • 2.6.4 - seeing something similar where the element is creating some bad feedback with react-flexbox-grid, starting at a normal size and then continually growing heightwise, eventually resulting in a canvas 200,000+ pixels high. This is done without the user resizing the browser, though I think react-flexbox-grid is doing something behind the scenes to mutate the DOM, which react-chartjs-2 is probably reacting responsively to.

Most helpful comment

@daru23
hey I realized what should I do
just set maintainAspectRatio True like this:
<Bar data={data} width={100} height={50} options={{ maintainAspectRatio: true }} />
and it all be done

All 5 comments

+1

This seems to happen when maintainAspectRatio is set to false.

I have the same problem and I don't know what should I do

I have the same problem :(

@daru23
hey I realized what should I do
just set maintainAspectRatio True like this:
<Bar data={data} width={100} height={50} options={{ maintainAspectRatio: true }} />
and it all be done

Closing for now. Please supply a sandbox or code example with the latest versions of both libraries. If the problem persists, feel free to open a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thanh121094 picture thanh121094  路  3Comments

alphakennyn picture alphakennyn  路  3Comments

ekobayu picture ekobayu  路  5Comments

cbroberg picture cbroberg  路  5Comments

selimovicz picture selimovicz  路  6Comments