vue3 usa Echarts

Primero instale Echarts

npm install echarts

 Presente Echarts a las páginas que necesita usar

import * as echarts from 'echarts';

Configurar un contenedor

<div ref="chart" style="height: 400px;width: 100%;"></div>

Usar echarts

const chart = ref()
const data33 = ref([150, 230, 224, 218, 135, 147, 360])

const init = () => {
  const myChart = echarts.init(chart.value);

  window.addEventListener('resize', function () {
    myChart.resize();
  });//动态设置echarts的大小

  let option = {
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: data33.value,
        type: 'line'
      }
    ]
  };
  myChart.setOption(option,);

}

onMounted(() => {
  init() //调用
})

Supongo que te gusta

Origin blog.csdn.net/qq_43319351/article/details/131510904
Recomendado
Clasificación