• echarts用法


    参考文档: https://github.com/xlsdg/vue-echarts-v3

    1、下载echarts插件

    $ npm install --save vue-echarts-v3

    2、引入echarts

      2.1 全部引入     

    import IEcharts from 'vue-echarts-v3/src/full.vue';

      2.2 部分引入

    import Vue from 'vue';
    import IEcharts from 'vue-echarts-v3/src/lite.vue';
    
    // import 'echarts/lib/chart/line';
    import 'echarts/lib/chart/bar';
    // import 'echarts/lib/chart/pie';
    // import 'echarts/lib/chart/scatter';
    // import 'echarts/lib/chart/radar';
    
    // import 'echarts/lib/chart/map';
    // import 'echarts/lib/chart/treemap';
    // import 'echarts/lib/chart/graph';
    // import 'echarts/lib/chart/gauge';
    // import 'echarts/lib/chart/funnel';
    // import 'echarts/lib/chart/parallel';
    // import 'echarts/lib/chart/sankey';
    // import 'echarts/lib/chart/boxplot';
    // import 'echarts/lib/chart/candlestick';
    // import 'echarts/lib/chart/effectScatter';
    // import 'echarts/lib/chart/lines';
    // import 'echarts/lib/chart/heatmap';
    
    // import 'echarts/lib/component/graphic';
    // import 'echarts/lib/component/grid';
    // import 'echarts/lib/component/legend';
    // import 'echarts/lib/component/tooltip';
    // import 'echarts/lib/component/polar';
    // import 'echarts/lib/component/geo';
    // import 'echarts/lib/component/parallel';
    // import 'echarts/lib/component/singleAxis';
    // import 'echarts/lib/component/brush';
    
    import 'echarts/lib/component/title';
    
    // import 'echarts/lib/component/dataZoom';
    // import 'echarts/lib/component/visualMap';
    
    // import 'echarts/lib/component/markPoint';
    // import 'echarts/lib/component/markLine';
    // import 'echarts/lib/component/markArea';
    
    // import 'echarts/lib/component/timeline';
    // import 'echarts/lib/component/toolbox';
    
    // import 'zrender/lib/vml/vml';

    3、使用echarts

    <template>
      <div class="echarts">
        <IEcharts :option="bar" :loading="loading" @ready="onReady" @click="onClick"></IEcharts>
        <button @click="doRandom">Random</button>
      </div>
    </template>
    
    <script type="text/babel">
      import IEcharts from 'vue-echarts-v3/src/full.vue';
      export default {
        name: 'view',
        components: {
          IEcharts
        },
        props: {
        },
        data: () => ({
          loading: true,
          bar: {
            title: {
              text: 'ECharts Hello World'
            },
            tooltip: {},
            xAxis: {
              data: ['Shirt', 'Sweater', 'Chiffon Shirt', 'Pants', 'High Heels', 'Socks']
            },
            yAxis: {},
            series: [{
              name: 'Sales',
              type: 'bar',
              data: [5, 20, 36, 10, 10, 20]
            }]
          }
        }),
        methods: {
          doRandom() {
            const that = this;
            let data = [];
            for (let i = 0, min = 5, max = 99; i < 6; i++) {
              data.push(Math.floor(Math.random() * (max + 1 - min) + min));
            }
            that.loading = !that.loading;
            that.bar.series[0].data = data;
          },
          onReady(instance) {
            console.log(instance);
          },
          onClick(event, instance, echarts) {
            console.log(arguments);
          }
        }
      };
    </script>
    
    <style scoped>
      .echarts {
         400px;
        height: 400px;
      }
    </style>

    Learn more ECharts' API   http://echarts.baidu.com/api.html

     

  • 相关阅读:
    全面分析 Spring 的编程式事务管理及声明式事务管理
    100句唤醒自己的励志名言
    100句自我激励的名言佳句
    java反射详解
    JAVA中的反射机制
    【BZOJ1015】【JSOI2008】星球大战Starwar(离线并差集)
    【HEOI2016/TJOI2016】排序(二份答案+线段树)
    【USACO06DEC】—牛奶模式Milk Patterns(后缀自动机)
    【HNOI2016】—找相同字符(后缀自动机)
    【AHOI2013】—差异(后缀自动机)
  • 原文地址:https://www.cnblogs.com/cina33blogs/p/7281067.html
Copyright © 2020-2023  润新知