jeecg-boot之echarts Demo

编程入门 行业动态 更新时间:2024-10-27 08:24:19

1、在项目下terminal安装依赖 npm install echarts -S

2、在WebStorm    src/main.js中全局引入

import echarts from 'echarts'
Vue.prototype.$echarts = echarts

3、编写代码,在mounted函数中调用echart的实例

<template>
    <div id="myChart" :style="{width:'600px',height:'300px'}"></div>
</template>

<script>
  export default {
    name: 'Echartdemo',
    data(){
      return{
        msg: 'EChart demo'
      }
    },
    mounted(){
      this.drawLine()
    },
    methods: {
      drawLine(){
        let myChart = this.$echarts.init(document.getElementById('myChart'))
        myChart.setOption({
          title: { text: 'xxx高铁商品销量统计' },
          tooltip: {},
          xAxis: {
            data: ["水果","酸奶","可乐","矿泉水","瓜子花生","扑克牌"]
          },
          yAxis:{},
          series:[{
            name: '销售',
            type: 'bar',
            data: [105,40,16,100,210,80]
          }]
        });
      }
    }
  }
</script>

<style scoped>

</style>

更多推荐

jeecg-boot之echarts Demo

本文发布于:2023-06-14 00:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1416425.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:boot   jeecg   Demo   echarts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!