zingchart / zingchart-vue

A Vue component to create charts with ZingChart
https://www.zingchart.com/docs/integrations/vue
MIT License
26 stars 5 forks source link

Error in v-on handler: "TypeError: this.$refs.chart.addnode is not a function" #7

Closed cymig closed 4 years ago

cymig commented 4 years ago

HI,

I'm trying to make ZingChart work with Vuex/VueJs. Based on the doc I have found this example:

{
    ...
    methods: {
        myCustomAddNode() {
            this.$refs.chart.addnode({
                value: 55,
            });
        }
    }
}

For some reason, I can't add a node and make the graph refresh and I got this error in the browser's console. [Vue warn]: Error in v-on handler: "TypeError: this.$refs.chart.addnode is not a function"

Thanks for your help!

Here is my code:

<template>
  <div>
    <zingchart :data="myData" :series="mySeries" ref="chart" />
    <button type="button" class="btn" @click="myCustomAddNode()">Add Node</button>
  </div>
</template>

<script>
import { mapGetters } from "vuex";

import zingchartVue from "zingchart-vue";
export default {
  components: {
    zingchart: zingchartVue
  },
  computed: {
    ...mapGetters([
      "getTrendsData",
      "getLoadingStatus",
      "getlabelChartData",
      "getvalueChartData"
    ])
  },
  methods: {
    myCustomAddNode() {
      this.$refs.chart.addnode({
        value: 55
      });
    }
  },
  data() {
    return {
      keyword: "",
      results: "",
      myData: {
        type: "line",
        plot: {
          aspect: "spline"
        },
        "scale-x": {
          label: {
            /* Add a scale title with a label object. */
            text: "Above is an example of a category scale"
          },
          /* Add your scale labels with a labels array. */
          labels: ["Jan", "Feb", "March", "April", "May", "June", "July", "Aug"]
        },
        title: {
          text: "Trends"
        }
      },
      mySeries: [{ values: [0, 2] }]
    };
  }
};
</script>
mike-schultz commented 4 years ago

Hi @cymig, sorry for the delay. Are you able to reproduce this on a online editor like codesandbox for me to debug easier? I dont see anything wrong with the code.

damntrecky commented 4 years ago

@cymig Is this still an issue? Can we close this out?

antonioreyna commented 3 years ago

i have the same problem

antonioreyna commented 3 years ago

did you solve it?