[Vuejs]-How can i use view charts in my js file using vuejs?

2👍

You need use global variable to register component. (Ref)

So, change IEcharts to "v-chart": VueECharts

For example:

// https://github.com/ecomfe/vue-echarts#using-the-component
var app = new Vue({
    el: "#app",
    components: {
        "v-chart": VueECharts
    },
    data() {
    
       let data = []

    for (let i = 0; i <= 360; i++) {
        let t = i / 180 * Math.PI
        let r = Math.sin(2 * t) * Math.cos(2 * t)
        data.push([r, i])
    }

    return {
      polar: {
        title: {
          text: 'Demo'
        },
        legend: {
          data: ['line']
        },
        polar: {
          center: ['50%', '54%']
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        angleAxis: {
          type: 'value',
          startAngle: 0
        },
        radiusAxis: {
          min: 0
        },
        series: [
          {
            coordinateSystem: 'polar',
            name: 'line',
            type: 'line',
            showSymbol: false,
            data: data
          }
        ],
        animationDuration: 2000
      }
    }
    }
});
 <script src="https://cdn.jsdelivr.net/npm/echarts@4.1.0/dist/echarts.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/vue-echarts@4.0.2"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<div id="app">
    <v-chart :options="polar"/>

</div>

Leave a comment