Git Product home page Git Product logo

Comments (5)

patryk-matis avatar patryk-matis commented on June 15, 2024 1

Nevermind, I forgot about adding { } to return

from vue-chart-3.

victorgarciaesgi avatar victorgarciaesgi commented on June 15, 2024

Hi no you can't access chartInstance like that because it's not the same behaviour as vue-chartjs. They need you to declare a new component for each Chart whereas here you juste have to import the pre-made component.

So like this:

<template>
  <DoughnutChart ref="doughtnutRef" />
</template>

<script>
import { DoughnutChart } from 'vue-chart-3';

export default defineComponent({
  name: 'Home',
  components: { DoughnutChart },
  setup() {
    const doughtnutRef = ref();
    // ....
    onMounted(() => {
      doughtnutRef.value.chartInstance.toBase64Image();
    });

    return { doughtnutRef };
  },
});
</script>

from vue-chart-3.

patryk-matis avatar patryk-matis commented on June 15, 2024

Hi no you can't access chartInstance like that because it's not the same behaviour as vue-chartjs. They need you to declare a new component for each Chart whereas here you juste have to import the pre-made component.

So like this:

<template>
  <DoughnutChart ref="doughtnutRef" />
</template>

<script>
import { DoughnutChart } from 'vue-chart-3';

export default defineComponent({
  name: 'Home',
  components: { DoughnutChart },
  setup() {
    const doughtnutRef = ref();
    // ....
    onMounted(() => {
      doughtnutRef.value.chartInstance.toBase64Image();
    });

    return { doughtnutRef };
  },
});
</script>

On 0.3.2 version refs value was undefined.
After upgrading to the newest version (0.3.7), it seems that this version is not working at all?
I mean, whole website is unresponsive.

from vue-chart-3.

victorgarciaesgi avatar victorgarciaesgi commented on June 15, 2024

@Krulaks upgraded to the newest version 0.4.7, there were breaking changes and fixes to get it working on both Vue 2 & 3

from vue-chart-3.

patryk-matis avatar patryk-matis commented on June 15, 2024

On 0.4.7,
using this code:

<template>
  <LineChart ref="lineRef" :chartData="chartData" :options="computeOptions" :styles="chartStyle" />
</template>

<script>
import { defineComponent, onMounted, ref } from "@vue/composition-api";
import { LineChart } from "vue-chart-3";
import "chartjs-adapter-moment";

export default defineComponent({
  components: { LineChart },
  props: ["chartdata", "options", "parsestyles"],
  setup() {
    const lineRef = ref();

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

It returns:
image

from vue-chart-3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.