Vue 에서 echarts 시각 화 구성 요 소 를 사용 하 는 방법

echarts 구성 요소 홈 페이지 주소:https://echarts.apache.org/examples/zh/index.html
1.비계 항목 이 있 는 주 소 를 찾 아 cnpm install echarts 를 실행 하고 echarts 구성 요 소 를 설치 합 니 다.(비계 의 주 소 는 vue 프로젝트 의 주소 입 니 다)

(E:\demo\vuepro)이것 은 제 프로젝트 주소 입 니 다.vuepro 는 프로젝트 이름 입 니 다.
2.필요 에 따라 가 져 오기,열기 속도 가속 화

//  echarts  
    import echarts from "echarts"
    //       
    let echart = require('echarts/lib/echarts')
    //        
    require('echarts/lib/chart/bar')
    //       title  
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')
3.보고서 그래 픽 을 포함 하 는 div 태그 준비
div 의 id 는 echarts 플러그 인 을 연결 하 는 데 사 용 됩 니 다.

 <div id="chart" style="width: 50%; height: 400px;">
 </div>
4.script 태그 의 내용

//  echarts  
    import echarts from "echarts"
    //       
    let echart = require('echarts/lib/echarts')
    //        
    require('echarts/lib/chart/bar')
    //       title  
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')
            export default{
                name: 'App',
                data(){
                  return{
                     chartColumn:null
                  }
                },
                methods:{
                  initData(){
                    let dt=document.querySelector("#boss")

                    this.chartColumn=echart.init(dt)
                    this.chartColumn.setOption(
                       //Examples    
                    )

                  }
                },
                mounted(){
                    this.initData()
                }
             }
여러분 의 사용 을 편리 하 게 하기 위해 서 저 는 Vue 에 echarts 시각 화 구성 요 소 를 도입 한 전체 템 플 릿 을 놓 았 습 니 다.여러분 이 직접 복사 해서 사용 하면 됩 니 다.

<template>
    <div id="boss" style="width: 500px;height: 500px;">
        
    </div>
</template>

<script>
    //  echarts  
    import echarts from "echarts"
    //       
    let echart = require('echarts/lib/echarts')
    //        
    require('echarts/lib/chart/bar')
    //       title  
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')
            export default{
                name: 'App',
                data(){
                  return{
                     chartColumn:null
                  }
                },
                methods:{
                  initData(){
                    let dt=document.querySelector("#boss")
            
                    this.chartColumn=echart.init(dt)
                    this.chartColumn.setOption(
                       //Examples   
                    )
            
                  }
                },
                mounted(){
                    this.initData()
                }
             }
</script>

<style>
</style>
사례:

<template>
    <div id="boss" style="width: 500px;height: 500px;">

    </div>
</template>

<script>
    import echarts from "echarts"
    //       
    let echart = require('echarts/lib/echarts')
    //        
    require('echarts/lib/chart/bar')
    //       title  
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/title')
            export default{
                name: 'App',
                data(){
                  return{
                     chartColumn:null
                  }
                },
                methods:{
                  initData(){
                    let dt=document.querySelector("#boss")

                    this.chartColumn=echart.init(dt)
                    this.chartColumn.setOption(
                    //   echarts     
                      {
                          tooltip: {
                              trigger: 'axis',
                              axisPointer: {            // Use axis to trigger tooltip
                                  type: 'shadow'        // 'shadow' as default; can also be 'line' or 'shadow'
                              }
                          },
                          legend: {
                              data: ['Direct', 'Mail Ad', 'Affiliate Ad', 'Video Ad', 'Search Engine']
                          },
                          grid: {
                              left: '3%',
                              right: '4%',
                              bottom: '3%',
                              containLabel: true
                          },
                          xAxis: {
                              type: 'value'
                          },
                          yAxis: {
                              type: 'category',
                              data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                          },
                          series: [
                              {
                                  name: 'Direct',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [320, 302, 301, 334, 390, 330, 320]
                              },
                              {
                                  name: 'Mail Ad',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [120, 132, 101, 134, 90, 230, 210]
                              },
                              {
                                  name: 'Affiliate Ad',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [220, 182, 191, 234, 290, 330, 310]
                              },
                              {
                                  name: 'Video Ad',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [150, 212, 201, 154, 190, 330, 410]
                              },
                              {
                                  name: 'Search Engine',
                                  type: 'bar',
                                  stack: 'total',
                                  label: {
                                      show: true
                                  },
                                  emphasis: {
                                      focus: 'series'
                                  },
                                  data: [820, 832, 901, 934, 1290, 1330, 1320]
                              }
                          ]
                      }
                      //      
                    )

                  }
                },
                mounted(){
                    this.initData()
                }
             }
</script>

<style>
</style>
효과 보이 기:

Vue 가 echarts 시각 화 구성 요 소 를 사용 하 는 방법 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 Vue echarts 시각 화 구성 요소 내용 은 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 많은 응원 부탁드립니다!

좋은 웹페이지 즐겨찾기