vue-charts icon indicating copy to clipboard operation
vue-charts copied to clipboard

Cannot read property 'beginAtZero' of undefined

Open moonlik opened this issue 6 years ago • 6 comments

Hello!

After update to 1.2.8 I got this error:

[Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'beginAtZero' of undefined"

It's occurred only on Pie chart, Doughnut chart, and Radar chart. After some investigations, I found that if I rewrite options like `v-bind:option="someOption" these charts start to work normally as expected.

I guess could the problem be in the code, where you set option by default as null:

 option: {
    type: Object,
    default: () => null,
 },

So if the option: null, therefore 'beginAtZero' is a property of undefined.

moonlik avatar Sep 22 '17 10:09 moonlik

@moonlik do you have a demo of how you got it working? I tried

But is still didn't work.

craigharman avatar Sep 22 '17 12:09 craigharman

@craigharman I just added v-bind:option="myoption" to the chartjs-pie component and in the script specify myoption in the data like this:

<template>
...
         <chartjs-pie
            v-bind:labels="deviceLabels"
            v-bind:data="deviceData"
            v-bind:backgroundcolor="deviceBackgroundColor"
            v-bind:hoverbackgroundcolor="deviceHoverBackgroundColor"
            v-bind:bind="true"
            v-bind:option="myoption">
          </chartjs-pie>
...
</template>


<script>
  export default {
    data () {
      return {
        myoption: {},
...
</script>

moonlik avatar Sep 25 '17 06:09 moonlik

@craigharman I also have noticed that after npm update the package doesn't work, so it's better to reinstall it

moonlik avatar Oct 17 '17 05:10 moonlik

1.2.8... happens here too.

mikerogne avatar Dec 10 '17 01:12 mikerogne

Same here. Can't use pie chart.

albertleao avatar Dec 22 '17 20:12 albertleao

I ended up just using chart.js itself, no wrapper. Works fine & is easy.

mikerogne avatar Dec 22 '17 20:12 mikerogne