Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
I cant put echartinstance into data In vue 3

I am using Vue 3 and Echart. The function was that when options were detected to be changed, the chart will update accordingly.

<template>
  <div ref="theChart" :style="{ height: '400px' }"></div>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import * as echarts from "echarts";
import * as _ from "lodash";

type EChartsOption = echarts.EChartsOption;

export default defineComponent({
  name: "LineChart",
  components: {},
  props: {
    options: {
      type: Object,
      required: true,
    },
  },
  mounted() {
    this.drawChart(this.options);
  },
  watch: {
    options: {
      handler(newOptions, oldOptions) {
        if (!_.isEqual(oldOptions, newOptions)) {
          console.info("hello");
          this.drawChart(newOptions);
        }
      },
      deep: true,
    },
  },
  methods: {
    drawChart(options: EChartsOption) {
      const chartElement = this.$refs.theChart as HTMLElement;
      const chart = echarts.init(chartElement, undefined, {
        renderer: "svg",
      });
      chart.setOption(options, true);
    },
  },
});
</script>

But I got the following "warning" but it works fineenter image description hereWarning

Of course, I tried to put this.echartsModule.init(XXXX) into a component data. But I got the following error when I clicked on the legend of the chart https://github.com/apache/echarts/issues/14198 That is why I used to put this.echartsModule.init(XXXX) into const as zhenghaiyang said. Do you have a better solution to avoid rewrite echartsModule.init(XXXX)? Thanks in advance!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda