Giter Site home page Giter Site logo

vue3-echarts's Issues

i need refresh data from api like this How can i

https://echarts.apache.org/en/api.html#echartsInstance

function greetings() {

  mychart.setOption({
    option.color = ['#1319CCs'];
   option.xAxis = {
   data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
    type: 'category',
   };
  option.series = [
    {
      data: ['150', '230', '224', '218', '135', '147', '260'],
     name: 'Line1',
      type: 'line',
     },
     {
     data: ['130', '230', '424', '618', '125', '117', '620'],
    name: 'Line2',
     type: 'line',
     },
   ];
  });

}

    setInterval(greetings, 2000);

vite项目用了这个插件页面HMR怎么失效了?

<template>
  <div class="home-center-right">
    <div class="title">
      <p>用印统计</p>
      <div>
        <span>全部</span>
        <span>一个月</span>
        <span>六个月</span>
        <span>一年</span>
      </div>
    </div>
    <vue-echarts :option="props.echartslineoption" style="height: 350px" />
  </div>
</template>

<script setup>
import { VueEcharts } from "vue3-echarts";

import { defineProps } from 'vue'
const props = defineProps({
  echartslineoption: {
    type: Object,
    default: () => {
      return {
        tooltip: {},
        legend: {
          data: ['智能用印', '普通用印']
        },
        xAxis: {
          axisLabel: {
            interval: 0,
            rotate: 45,
          },
          data: [
            "2022-01",
            "2022-02",
            "2022-03",
            "2022-04",
            "2022-05",
            "2022-06",
            "2022-07",
            "2022-08",
            "2022-09",
            "2022-10",
            "2022-11",
            "2022-10",
          ],
        },
        yAxis: {},
        series: [{
          name: "智能用印",
          type: "line",
          data: [10, 41, 35, 51, 49, 62, 69, 91, 148, 35, 34, 78],
        },
        {
          name: "普通用印",
          color: "#00bd9d",
          type: "line",
          data: [40, 120, 83, 45, 31, 74, 35, 34, 78, 35, 34, 78],
        },
        ],
      }
    },
  }
})
</script>

Question: Property 'chart' does not exist on type 'CreateComponentPublicInstance

Hi,
I added the vue3 echarts component globally in main.ts as shown below:

main.ts

import Notifications from '@kyvg/vue3-notification';
import { VueEcharts } from 'vue3-echarts';

import App from './App.vue';
import router from './router';

import './styles/main.css';
import Iam from './common/iam';

const app = createApp(App);

app.use(Notifications);
app.use(createPinia());
app.use(VueAxios, axios);
app.use(router);

app.component('vue-echarts', VueEcharts)

Iam.init();

app.mount('#app');

page vue:

<template>
...
                <vue-echarts :option="option" style="height: 500px" ref="chart" />
...
</template>

<script setup lang="ts">
-----snipped---

const option = reactive({
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line'
    }
  ]
});
-----snipped---
</script>

It works in dev mode, but when trying to check type using vue-tsc. I get the error below.

npx vue-tsc --noEmit -p tsconfig.vitest.json 
node_modules/vue3-echarts/index.ts:148:14 - error TS2339: Property 'chart' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{ option: { type: PropType<EChartsOption>; }; theme: { type: StringConstructor; default: string; }; groupId: { type: StringConstructor; default: null; }; loadingOption: { ...; }; initCfg: PropType<...>; }>> & { ...; }, ... 17 more ..., { ...; }>'.

148         this.chart.hideLoading();

Package versions:

     "vue": "^3.2.41"
    "vue3-echarts": "^1.1.0",
    "typescript": "~4.7.4",
    "vite": "^3.1.8",
    "vitest": "^0.24.5",
    "vue-tsc": "^1.0.8"

Are there any option that I should enable?

How to SetOption

vue3-echarts
function greetings() {
VueEcharts.setOption({
xAxis: {
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
type: 'category',
},
series: [
{
data: ['150', '230', '224', '218', '135', '147', '260'],
name: 'Line1',
type: 'line',
},
],
});
}
setInterval(greetings, 2000);

Can't get DOM width or height

Hi @CarterLi ,thanks for creating this Echarts binding for Vue3!
In the point 3 where shall I place the line with (this.$refs.chart as VueEcharts).refreshOption();?

I pass my option to the option props. However, I got this error:
Can't get DOM width or height. Please check dom.clientWidth and dom.clientHeight. They should not be 0.For example, you may need to call this in the callback of window.onload.
How can I fix the error?
My template code of my component is like this:

<template>
  <div class="col-auto row">
    <template v-if="checkValues()">
      <vue-echarts :option="line" style="height: 500px" ref="chart" />
    </template>
  </div>
</template>

<script>
import { VueEcharts } from 'vue3-echarts';
export default {
data: () => ({
    loading: true,
    line: {....}
}),
};
</script>

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.