Vue-chartjs: this.renderChart is not a function when using default example

Created on 4 May 2018  路  7Comments  路  Source: apertureless/vue-chartjs

What other configurations or imports do I need to make, i get TypeError: this.renderChart is not a function when I use the example given as,

import { Bar } from 'vue-chartjs'

export default {
  extends: Bar,
  mounted () {
    // Overwriting base render method with actual data.
    this.renderChart({
      labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
      datasets: [
        {
          label: 'GitHub Commits',
          backgroundColor: '#f87979',
          data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
        }
      ]
    })
  }
}

do i need to define the function or what?

Most helpful comment

I have the same error, and using mixins doesn't work too.

All 7 comments

Are you using the latest version of vue-chartjs ?

As per the last the commit, yes i'm using the latest version

Can you post a reproduction?
Generally this seems right.

You are extending the Bar component and like a mixin you have all methods and props defined in there. So this.renderChart() should be available.

You could try mixins: [Bar] instead of extends

mixins: [Bar] works thanks,

I have the same error, and using mixins doesn't work too.

I am having the same error and mixins also do not work.

I found how to solve this problem. I added BaseCharts.js in example packages on project and then It works.

image

image

hope to solve the problem you have

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LeeLenaleee picture LeeLenaleee  路  3Comments

Sykomaniac picture Sykomaniac  路  3Comments

kurbar picture kurbar  路  4Comments

sergeynilov picture sergeynilov  路  3Comments

aido179 picture aido179  路  3Comments