vue 集成eacharts

<template>
  <div class="user-info">
    <h2>个人信息</h2>
    <ul>
      <li>
        <label>昵称:</label>
        <span>测试数据</span>
      </li>
      <li>
        <label>账号:</label>
        <span>13678380508</span>
      </li>
      <li>
        <label>性别:</label>
        <span>男</span>
      </li>
      <li>
        <label>积分:</label>
        <span>1300</span>
      </li>
    </ul>
    <div ref="main" class="main"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "userInfo",
  mounted() {
    const { vm } = { vm: this };
    // 基于准备好的dom,初始化echarts实例
    let myChart = echarts.init(vm.$refs.main);
    // 绘制图表
    myChart.setOption({
      title: {
        text: "数据统计",
      },
      tooltip: {
        trigger: "axis",
      },
      legend: {
        data: ["资源浏览量", "课程学习量", "答题量", "面试题评论", "积分"],
      },
      grid: {
        left: "3%",
        right: "4%",
        bottom: "3%",
        containLabel: true,
      },
      toolbox: {
        feature: {
          saveAsImage: {},
        },
      },
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: [
          "星期一",
          "星期二",
          "星期三",
          "星期四",
          "星期五",
          "星期六",
          "星期日",
        ],
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          name: "资源浏览量",
          type: "line",
          stack: "Total",
          data: [1220, 1322, 101, 9134, 390, 3230, 3210],
        },
        {
          name: "课程学习量",
          type: "line",
          stack: "Total",
          data: [2240, 8182, 9191, 2344, 290, 3430, 1310],
        },
        {
          name: "答题量",
          type: "line",
          stack: "Total",
          data: [150, 2932, 2031, 154, 8490, 5330, 4410],
        },
        {
          name: "面试题评论",
          type: "line",
          stack: "Total",
          data: [3320, 332, 301, 334, 3930, 330, 3320],
        },
        {
          name: "积分",
          type: "line",
          stack: "Total",
          data: [820, 932, 901, 934, 1290, 1330, 1320],
        },
      ],
    });
  },
};
</script>

<style scoped lang="less">
.user-info {
  h2 {
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
  }
  ul {
    margin-bottom: 20px;
    li {
      label {
        font-weight: bold;
      }
    }
  }

  .main {
    height: 400px;
  }
}
</style>
<template>
  <div id="app">
    <div class="topbox w100">
      <div class="contentbox w1600">福建省水电站清理整治工作平台</div>
    </div>
    <div class="center w100">
      <div class="centerbox">
        <div class="left">
          <div class="box1">
            <dv-border-box-10
              class="boxx"
              style="width: 500px; height: 150px; text-align: left"
            >
              <div class="tittle">福建省生态下泄流量2023/02/04考核情况</div>
            </dv-border-box-10>
          </div>
        </div>
         <div id="area" class="main" style="width: 500px; height: 500px;"></div>
        <div class="right">
          <div class="rightbox">
            <div class="rightbox1">
              <dv-border-box-10>dv-border-box-10</dv-border-box-10>
            </div>
            <div class="rightbox2">
              <dv-border-box-10
                class="boxx"
              
              >
                <div class="tittle">福建省生态下泄流量2023/02/04考核情况</div>
              </dv-border-box-10>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";


export default {
  mounted() {
      const myChart = echarts.init(document.getElementById('area'))
      this.$axios.get('https://geo.datav.aliyun.com/areas_v3/bound/350000_full.json').then(ret => {
//防止本地发起axios出现跨域问题,需要写成http://localhost:8999/jilin.json
        echarts.registerMap('jilin', ret.data)
        // 注册矢量地图数据
        var option = {
          visualMap: { // 视觉映射组件
            show: false,
        
            top: '70%',
            bottom: '2%',
            left: '2%',
            textStyle: {
              fontsize: 12
            },
           
          },
          tooltip: { // 悬浮框
            trigger: 'item', // 触发条件
            backgroundColor: 'RGBA(136, 123, 135, 0.8)',
            formatter: '{b}<br/>案件数{c}', // 自定义显示数据
            textStyle: {
              color: '#ffffff'
            }
          },
          series: [
            {
              type: 'map',
              map: 'jilin',
              zoom: 1,
              top: '10%',
              x: 'center',
              label: {
                show: true // 显示               
              },
              itemStyle: {
                normal: { // 静态的时候显示的默认样式
                  areaColor: '#409EFF', // 地图颜色
                  // borderColor: '#886364' // 边框颜色
                },
                emphasis: { // 鼠标移入动态的时候显示的默认样式
                  // borderWidth: 2, // 边框宽度
                  areaColor: 'blue' // 地图颜色
                }
              },
              // 数据
              data: [
                {
                  name: '长春市',
                  value: '1202'
                },
                {
                  name: '吉林市',
                  value: '396'
                },
                {
                  name: '通化市',
                  value: '1125'
                },
                {
                  name: '四平市',
                  value: '635'
                },
                {
                  name: '白山市',
                  value: '586'
                },
                {
                  name: '辽源市',
                  value: '360'
                },
                {
                  name: '白城市',
                  value: '231'
                },
                {
                  name: '延边朝鲜族自治州',
                  value: '196'
                },
                {
                  name: '松原市',
                  value: '80'
                }
              ]
            }
 
          ]
        }
        myChart.setOption(option)
      })


  }
};
</script>


<style lang="less" >
body,
html {
  width: 100%;
  height: 100%;

  #app {
    width: 100%;
    height: 100%;
  }
}
* {
  padding: 0;
  margin: 0;
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  background-image: url(./assets/大屏/bg2.png);
  background-size: 100% 100%;
}
.w100 {
  width: 100%;
  min-width: 1200px;
}
.w1600 {
  width: 90%;
  max-width: 1600px;
  min-width: 1200px;
  margin: 0 auto;
}
.w100 {
  width: 100%;
  min-width: 1200px;
}
.w1700 {
  width: 98%;
  max-width: 1600px;
  min-width: 1200px;
  margin: 0 auto;
}
.contentbox {
  padding-top: 40px;
  display: flex;
  justify-content: center;
  color: #fff;
  font-weight: bolder;
  font-size: 30px;
}

.centerbox {
  display: flex;
  justify-content: space-between;
  gap: 50px;
}
.rightbox {
  display: flex;
}
.tittle {
  color: #fff;
  padding-left: 20px;
  padding-top: 20px;
}
.cente {
  width: 500px;
  height: 500px;
  background: #fff;
}
.center {
  padding: 30px;
  box-sizing: border-box;
}
 .main {
    height: 400px;
  }
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卷起来@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值