Vue-chartjs: Chart does not render inside accordion

Created on 7 Aug 2018  路  2Comments  路  Source: apertureless/vue-chartjs

Expected Behavior

When trying to render a chart inside a vuetify expansion panel(accordion), chart should render on panel open.

Actual Behavior

Chart does not render unless initial state of expanion panel is open.

Environment

  • vue.js version: 2.5.16
  • vue-chart.js version: 3.4.0
  • npm version: 6.1.0
duplicate

Most helpful comment

Hey @tcaraccia
well it is always nice to debug without code ;)
However I am pretty sure, thats because of your chart.js options.

I have no experience with vuetify, but I guess the panel works with v-show and not v-if. What v-show does is that it only adds a display: none to the element.

If you have now responsive: true in your chart options chart.js will set the width of the canvas based on the outer container.

If your panel / tab is now hidden with v-show the component still gets mounted, but the container / div width and height are 0. Because of the display: none.

In contrast v-if will unmount and remounts your components, so the chart gets initialized again with the real width and height of the container.

See #90 #235 #157

All 2 comments

Hey @tcaraccia
well it is always nice to debug without code ;)
However I am pretty sure, thats because of your chart.js options.

I have no experience with vuetify, but I guess the panel works with v-show and not v-if. What v-show does is that it only adds a display: none to the element.

If you have now responsive: true in your chart options chart.js will set the width of the canvas based on the outer container.

If your panel / tab is now hidden with v-show the component still gets mounted, but the container / div width and height are 0. Because of the display: none.

In contrast v-if will unmount and remounts your components, so the chart gets initialized again with the real width and height of the container.

See #90 #235 #157

Great! Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tirke picture Tirke  路  4Comments

Sykomaniac picture Sykomaniac  路  3Comments

m-jooibar picture m-jooibar  路  4Comments

ihrankouski picture ihrankouski  路  3Comments

bdeanindy picture bdeanindy  路  3Comments