簡述vue項目中如何使用ECharts圖表


1、安裝

npm install echarts

2、項目中

<template>
  <div>
    <div id="main" style="width: 1000px;height:400px;" ref="main"></div>
  </div>
</template>

<script>
import echarts from "echarts";   //導入EChats
import { http } from "../../network/index";   //網絡請求模塊
export default {
  mounted() {
    this.save();
  },
  methods: {
    save() {
      var myChart = echarts.init(this.$refs.main);
      //請求數據
      http.getreports().then((res) => {
        myChart.setOption({
          title: {
            text: "用戶來源",
          },
          tooltip: {
            trigger: "axis",
            axisPointer: {
              type: "cross",
              label: {
                backgroundColor: "#6a7985",
              },
            },
          },
          toolbox: {
            // 工具箱
            show: true,
            feature: {
              dataZoom: {
                yAxisIndex: "none",
              },
              dataView: { readOnly: false },
              magicType: { type: ["line", "bar", "stack", "tiled"] },
              restore: {},
            },
          },
          ...res.data.data,
        });
      });
    },
  },
};
</script>

<style>
</style>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM