victorgarciaesgi / vue-chart-3

📊 A simple wrapper around Chart.js 3 for Vue 2 & 3
https://vue-chart-3.netlify.app/
MIT License
310 stars 112 forks source link

Accessing the ref #131

Open refjord opened 2 years ago

refjord commented 2 years ago

Describe the bug

A clear and concise description of what the bug is.

Hi guys,

I'm trying to access the ref using a setup as described in the docs:

<template>
    <LineChart ref="chart" :chartData="data" :options="options" />
</template>

<script lang="ts">
import { defineComponent, ref, onMounted } from "vue";
import { LineChart } from "vue-chart-3";
import { Chart, registerables } from "chart.js";
import gradient from "chartjs-plugin-gradient";

Chart.register(...registerables);

export default defineComponent({
    props: ["data"],
    name: "Chart",
    components: { LineChart },

  setup() {
    const lineRef = ref();

    onMounted(() => {
      console.log(lineRef.value);
    })
    return lineRef;
  },

The value of ref always returns undefined. Is there something I'm missing?

Version of vue-chart-3

3.1.8

Version of Vue

rbartholomay commented 2 years ago

same here

blood1shot commented 1 year ago

same