Giter VIP home page Giter VIP logo

vue-echarts-v3's Introduction

vue-echarts-v3 npm vue2 echarts3

Vue.js v2.x+ component wrap for Apache ECharts (incubating) v3.x+

Feature

  1. Lightweight, efficient, on-demand binding events;
  2. Support for importing ECharts.js charts and components on demand;
  3. Support component resize event auto update view;

Installation

$ npm install --save echarts vue-echarts-v3

Usage

  1. Change webpack config

    For webpack 1.x:

          {
            test: /\.js$/,
            loader: 'babel',
            include: [
    -          path.join(prjRoot, 'src')
    +          path.join(prjRoot, 'src'),
    +          path.join(prjRoot, 'node_modules/vue-echarts-v3/src')
            ],
    -        exclude: /node_modules/
    +        exclude: /node_modules(?![\\/]vue-echarts-v3[\\/]src[\\/])/
          },

    For webpack 2.x+:

          {
            test: /\.js$/,
            loader: 'babel-loader',
    -       include: [resolve('src'), resolve('test')]
    +       include: [resolve('src'), resolve('test'), resolve('node_modules/vue-echarts-v3/src')]
          }
  2. Import all charts and components

    import IEcharts from 'vue-echarts-v3/src/full.js';
  3. Import ECharts.js modules manually to reduce bundle size

    import IEcharts from 'vue-echarts-v3/src/lite.js';
    
    // 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';

Using the component

<template>
  <div class="echarts">
    <IEcharts
      :option="bar"
      :loading="loading"
      @ready="onReady"
      @click="onClick"
    />
    <button @click="doRandom">Random</button>
  </div>
</template>

<script type="text/babel">
  import IEcharts from 'vue-echarts-v3/src/full.js';
  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, ECharts) {
        console.log(instance, ECharts);
      },
      onClick(event, instance, ECharts) {
        console.log(arguments);
      }
    }
  };
</script>

<style scoped>
  .echarts {
    width: 400px;
    height: 400px;
  }
</style>

Properties

  • styles

    Optional; CSS style is { width: 100%; height: 100%; } by default.

  • initOpts & theme

    Optional; Used to initialize ECharts instance.

  • option [reactive]

    Used to update data for ECharts instance. Modifying this property will trigger ECharts' setOptions method.

  • group [reactive]

    Optional; This property is automatically bound to the same property of the ECharts instance.

  • notMerge

    Optional; false by default. Detail

  • lazyUpdate

    Optional; false by default. Detail

  • loading [reactive]

    Optional; false by default. Modifying this property will trigger ECharts' showLoading or hideLoading method.

  • loadingOpts

    Optional; Detail

  • resizable

    Optional; false by default.

See more ECharts' Option

Instance Methods

  • resize
  • update
  • mergeOption
  • dispatchAction
  • convertToPixel
  • convertFromPixel
  • containPixel
  • showLoading
  • hideLoading
  • getDataURL
  • getConnectedDataURL
  • clear

Static Methods

  • connect
  • disConnect
  • dispose
  • getInstanceByDom
  • registerMap
  • getMap
  • registerTheme

Learn more ECharts' API

Demo

vue-echarts-v3-demo

License

MIT

vue-echarts-v3's People

Contributors

hansz00 avatar morkro avatar xlsdg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-echarts-v3's Issues

违反 MIT 协议

很明显,这个项目是基于老版本的 Vue Echarts 修改的,README 中只字不提也就算了,毕竟 License 没有强制要求。不过最低的要求至少应该满足吧,需要在 LICENSE 中附上原项目 LICENSE 全文(当然也包括原作者的名字),而不是把我的名字改成你自己就 OK 了。

协议要求

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

firefox无法正常画图

当在firefox中打开时,无法正常画图,需要手动点一下echarts上面的还原按钮才能正常绘制图像,是什么原因呢?我没有想到什么合理的解释。

warning

当我使用vue-echarts-v3时,vue总会提示[Vue warn]: "style" is a reserved attribute and cannot be used as component prop。 能不能把IEcharts的props换一个名字呢?

是不是有依赖关系

你用了vue2.3.2导致我们无法升级到vue最新版本
就是你不更新到最新,我们升级到vue最新就提示出错

调用graphic.LinearGradient()方法报undefined

我想给我的柱状图表加渐变色,于是参照示例用这个方法,我看了你的文档后把new echarts换成IEcharts也会报undefined
itemStyle: { normal: { color: IEcharts.graphic.LinearGradient( 0, 0, 0, 1, [ {offset: 0, color: '#83bff6'}, {offset: 0.5, color: '#188df0'}, {offset: 1, color: '#188df0'} ] ) } }

how to use graphic.LinearGradient?

I'd like to use echarts.graphic.LinearGradient, which module should I import?

import Graphic from 'echarts/src/util/graphic'

client.js?7955:115 [HMR] bundle has errors:
.//echarts/src/util/graphic.js
Module not found: Error: Cannot resolve module 'zrender/core/util' in /opt/workspace/hpc-ui/node_modules/echarts/src/util
@ ./
/echarts/src/util/graphic.js 5:17-45
.//echarts/src/util/graphic.js
Module not found: Error: Cannot resolve module 'zrender/tool/path' in /opt/workspace/hpc-ui/node_modules/echarts/src/util
@ ./
/echarts/src/util/graphic.js 7:19-47
.//echarts/src/util/graphic.js
Module not found: Error: Cannot resolve module 'zrender/graphic/Path' in /opt/workspace/hpc-ui/node_modules/echarts/src/util
@ ./
/echarts/src/util/graphic.js 9:15-46

thanks

Is the any way to destroy echarts?

Hello. Please tell me how to remove the eharts instance inside the "destoyed()" in the component.
I think that my mistake is connected with the this element still in DOM. Can you help me, please?
image

Unknown custom element: <IEcharts>

I'm having a problem with the example code, it throws the error "Unknown custom element: - did you register the component correctly?".

In the repository's demo, the tag is named "i-echarts".
Unfortunately, I'm facing a weird problem because none of those are working for me.
I'm using webpack: ^2.2.1, vue: ^2.2.2

按需引用图表和组件会报错。

错误堆栈:

Uncaught ReferenceError: DEV is not defined
at Function.RootClass.extend (eval at (app.js:834), :69:13)
at Function.entity.extend (eval at (app.js:834), :236:56)
at eval (eval at (app.js:4202), :16:30)
at Object. (app.js:4202)
at webpack_require (app.js:556)
at fn (app.js:87)
at eval (eval at (app.js:768), :3:24)
at Object. (app.js:768)
at webpack_require (app.js:556)
at fn (app.js:87)
RootClass.extend @ clazz.js?3e66:69
entity.extend @ clazz.js?3e66:236
(anonymous) @ Ordinal.js?3a6b:16
(anonymous) @ app.js:4202
webpack_require @ app.js:556
fn @ app.js:87
(anonymous) @ axisHelper.js?4730:3
(anonymous) @ app.js:768
webpack_require @ app.js:556
fn @ app.js:87
(anonymous) @ Grid.js?f167:9
(anonymous) @ app.js:1891
webpack_require @ app.js:556
fn @ app.js:87
(anonymous) @ bar.js?931c:5
(anonymous) @ app.js:3619
webpack_require @ app.js:556
fn @ app.js:87
(anonymous) @ echarts.js?ec46:10
(anonymous) @ app.js:2899
webpack_require @ app.js:556
fn @ app.js:87
(anonymous) @ main.js?3479:6
(anonymous) @ app.js:2917
webpack_require @ app.js:556
fn @ app.js:87
(anonymous) @ app.js:587
webpack_require @ app.js:556
(anonymous) @ app.js:579
(anonymous) @ app.js:582

// 引用

import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/pie'

import 'echarts/lib/chart/lines'
import 'echarts/lib/component/grid'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/tooltip'

import 'echarts/lib/component/title'

import 'echarts/lib/component/dataZoom'
import 'echarts/lib/component/visualMap'
import 'echarts/lib/component/toolbox'

how to use dynamic-data of line

http://echarts.baidu.com/demo.html#dynamic-data2
The function formatter in tooltip does not work.
My code is fellowing:

<div class="echarts"> 
        <IEcharts :option="timeLine" @ready="onReady" @click="onClick"></IEcharts> 
      </div>

    mounted() {
            setInterval(function (){
                for (var i = 0; i < 5; i++) {
                    var now = new Date();
                    this.timeLine.series[0].data.shift();
                    this.timeLine.series[0].data.push( {
                        name: now.toString(),
                        value: [
                            [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
                            Math.random()*10000
                        ]
                    });
                }
            }.bind(this),2000);
        }

 
   timeLine:{
                    title: {
                        text: 'dynamic data'
                    },
                    tooltip: {
                        trigger: 'axis',
                        **_formatter: function (params) {
                            debugger;
                            params = params[0];
                            var date = new Date(params.name);
                            return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
                        },_**
                        axisPointer: {
                            animation: false
                        }
                    },
                    xAxis: {
                        type: 'time',
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                        type: 'value',
                        boundaryGap: [0, '100%'],
                        splitLine: {
                            show: false
                        }
                    },
                    series: [{
                        name: 'data',
                        type: 'line',
                        showSymbol: false,
                        hoverAnimation: false,
                        data: []
                    }]
                }

The Y is changing but no data is shown.

主题引用不成功

看了另一个哥们#40 提的问题《echarts主题自定义不成功》,根据您的代码来写,设置不了主题,能帮忙看看代码有什么不对吗
111
222

Theming does not work

Wanted to use built-in Echarts theme 'macarons', but it does not work in component
<IEcharts :option="line" theme="macarons"></IEcharts>

But it works if i define custom theme object and bind it
<IEcharts :option="line" :theme="theme"></IEcharts>

line类型图表

你好,和官网一样的配置,line类型图表无动画效果,而官网的有
已解决

在火狐上的显示问题

使用的使用在谷歌和safari使用折线图都没有问题,但是在火狐上,折线图的title,datazoom都能显示,唯一不显示的是具体的图形,并且datazoom里面的小图形也能显示出来

Errors appear when redirect to another page that don't have charts

the errors that appear are:
-Uncaught TypeError: Cannot read property 'getWidth' of null
-Uncaught Error: setOption should not be called during main process
I've tried to find a solution to the problem, but everything i found was in Chinese and i wasn't able to figure out what to do to fix these problems.

if else 更新视图大小的问题

页面中如果用了if else 那么当为true 的时候 显示出来的 echart 的大小变成初始化的100X100了,这个问题困扰了我好久。

我在官方找到一个解决方法就是使用“style.width和style.height” 但是没法使用100%的样式。有没有什么好的办法呢?

如何得到echarts实例 需要使用echarts.number echarts.format等帮助方法

eg:http://echarts.baidu.com/gallery/editor.html?c=calendar-effectscatter

function getVirtulData(year) {
    year = year || '2017';
    var date = +echarts.number.parseDate(year + '-01-01');
    var end = +echarts.number.parseDate((+year + 1) + '-01-01');
    var dayTime = 3600 * 24 * 1000;
    var data = [];
    for (var time = date; time < end; time += dayTime) {
        data.push([
            echarts.format.formatTime('yyyy-MM-dd', time),
            Math.floor(Math.random() * 10000)
        ]);
    }
    return data;
}

或者如何在此项目中使用echarts方法。直接IEcharts无效。

Can't get dom width or height

运行了readme.md的例子,但是报错说:Can't get dom width or height
图表也不显示。
请问是什么原因?

柱状图条数增加后无法减少

首先非常感谢您的付出,这个插件用起来很好用.
不过目前我遇到一个问题,就是当柱状图series里面只包含一个对象时(即像您的demo那样), push多一个对象进去柱状图可以正常显示两组数据, 但是此时再去掉其中一个或者清空数组重新加入一个对象之后, 此时series中只有一个对象, 但柱状图中依然显示两组数据,这是为何?有没有什么解决办法呢?

Error: `setOption` should not be called during main process

我用vue2.0和vue-echarts-v3的line模块,报错Error: setOption should not be called during main process。 相关代码

`

    <IEcharts :option="charts"></IEcharts>

     import IEcharts from 'vue-echarts-v3/src/lite.vue';
     export default{
     components: {
          IEcharts
     },

    data: function () {
        return {
            net_info: {},
            iface_status: [],
            connections: {},
            charts: {
                title : {
                    text : '网卡流量'
                },

                tooltip: {
                    trigger: 'axis',
                    formatter: function (params) {
                        params = params[0];
                        var date = new Date(params.name);
                        return date.getHours()+ ':' + date.getMinutes() + ':' + date.getSeconds() + ' : ' + params.value[1];
                    },
                    axisPointer: {
                        animation: false
                    }
                },

                xAis: {
                    type: 'time',
                    splitLine: {
                        show: false
                    }
                },

                yAxis: {
                    type: 'value',
                    boundaryGap: [0, '100%'],
                    splitLine: {
                        show: false
                    }
                },

                series: [{
                    name: '网卡流量',
                    type: 'line',
                    showSymbol: false,
                    hoverAnimation: false,
                    data: []
                }]

            }
        };
    },

    methods: {
        getNetworkInfo: function () {
            api.network.get().then((response)=>{
                this.net_info = response.data.data;
                //console.log(this.net_info);
                this.iface_status = this.net_info.iface_status;
                this.connections = this.net_info.connections;
                const data_point = this.generateEchartsData(this.iface_status);
                this.charts.series[0].data.push(data_point);

            }, (error)=>{
                // console.log(error);
            });
        },

        generateEchartsData: function (iface_info) {
            let  now = new Date();
            return {
                name: now.toString(),
                value: [
                    [now.getHours(), now.getMinutes() , now.getSeconds()].join(':'),
                    Math.round(iface_info[1].receive_bytes)
                ]
            }
        },

        getIfaceStatus: function () {
            api.iface_status.get().then((response)=>{
                this.iface_status = response.data.data;
                const data_point = this.generateEchartsData(this.iface_status);
                this.charts.series[0].data.push(data_point);
            }, (error)=>{

            });
        },
    },

    mounted: function () {
        this.$log.log('mounted');
        this.getNetworkInfo();

        // set interval
        const interval = 6000; // 1minutes
        setInterval(this.getIfaceStatus, interval);
    }
}

`

Resize

hello,

is it possible to get an example on how to resize the chart, i.e how to use the instance method resize??

Thanks in advance !

怎么按需引入没有用

import IEcharts from 'vue-echarts-v3/src/full.vue'
import 'echarts/lib/chart/pie'

引入组件的页面 该加载那么大的还是那么大 页面加载的大小没有变化

总之 无论是
import IEcharts from 'vue-echarts-v3/src/full.vue'
import 'echarts/lib/chart/pie'
上面这样引入
还是直接
import IEcharts from 'vue-echarts-v3/src/full.vue'
这样引入 都是可以用pie这个图表控件的
不知道两种方式有什么区别 总要的是 上面两种引入方式页面加载的大小是一样的

echarts主题自定义不成功

Hi,您好!
请问下能不能给个自定义主题的demo,我这边使用自定义主题不成功,谢谢!

自定义主题导入代码

import 'echarts/theme/xtheme.js'
import IEcharts from 'vue-echarts-v3/src/full.vue'

<IEcharts
          theme="xtheme"
          :option="bar"
          :resizable="true"
></IEcharts>

这边测试没有成功!

封装vue版本的echarts只是为了使用上的便捷么?

你好!如题,你这个项目除了在vue中使用echarts方便一些之外,还有解决其他问题或者基于什么原因封装的?我之前在vue中使用echarts,在IE中init初始化时会出现奇怪报错,chrome正常,查不到原因,接下来想用你这个试试

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.