前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >简述vue项目中如何使用ECharts图表

简述vue项目中如何使用ECharts图表

作者头像
江咏之
发布2022-06-17 13:26:50
2890
发布2022-06-17 13:26:50
举报
文章被收录于专栏:技术社区技术社区

1、安装

代码语言:javascript
复制
npm install echarts

2、项目中

代码语言:javascript
复制
<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>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-09-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档