• Stars
    star
    903
  • Rank 50,580 (Top 1.0 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

vue-countup-v2

Vue.js component wrap for countUp.js
Vue
380
star
2

dva-antd-mobile-starter

Get started with Dva.js and Ant Design mobile.
JavaScript
116
star
3

vue-odometer

Vue.js(v2.x+) component wrap for Odometer.js
JavaScript
63
star
4

vue-echarts-v3-demo

Vue.js(v2.x+) component wrap for ECharts.js(v3.x+) demo
Vue
52
star
5

react-echarts-v3

React.js(v16.x+) component wrap for ECharts.js(v3.x+)
JavaScript
50
star
6

dva-antd-starter

Get started with Dva.js and Ant Design.
JavaScript
27
star
7

react-geetest

A Geetest component for React
JavaScript
23
star
8

umi-dva-antd-mobile-starter

Get started with Umi3.js and Ant Design Mobile.
JavaScript
22
star
9

umi-dva-antd-starter

Get started with Umi3.js and Ant Design.
JavaScript
19
star
10

react-simplemde-v1

React component wrap for SimpleMDE Markdown Editor(v1.x)
JavaScript
8
star
11

flowerpassword.js

Flower Password implementation for JavaScript.
TypeScript
6
star
12

react-intl-tel-input-v2

React component wrap for intl-tel-input
JavaScript
6
star
13

umi-dva-antd-typescript-starter

Get started with Umi.js and Ant Design.
TypeScript
6
star
14

next-dva-antd-starter

Get started with Next.js and Ant Design.
JavaScript
5
star
15

flower-password-desktop

Flower Password Mac Desktop App, based on Electron
JavaScript
5
star
16

dva-react-native-starter

Get started with Dva.js and React Native.
JavaScript
5
star
17

umi-mobx-antd-mobile-starter

Get started with Umi.js and Ant Design Mobile.
JavaScript
4
star
18

umi2-dva-antd-starter

Get started with Umi2.js and Ant Design.
JavaScript
3
star
19

flower-password-android

Automatically exported from code.google.com/p/flower-password-android
Java
3
star
20

flower-password-cli

The FlowerPassword.js command line utility.
JavaScript
3
star
21

flower-password-user-script

Flower Password implementation for User Script.
JavaScript
3
star
22

create-react-app-antd-typescript-starter

Get started with create-react-app and antd.
TypeScript
3
star
23

flower-password-chrome

Automatically exported from code.google.com/p/flower-password-chrome
JavaScript
3
star
24

vue-highcharts-v5

Vue.js(v2.x+) component wrap for HighCharts.js(v6.x+)
JavaScript
3
star
25

umi2-dva-antd-mobile-starter

Get started with Umi2.js and Ant Design Mobile.
JavaScript
2
star
26

node-flower-password

Flower Password implementation for Node.js
JavaScript
2
star
27

react-echarts-wrapper

React.js component wrap for ECharts.js
JavaScript
2
star
28

umi-dva-electron-starter

Get started with Umi3.js and Electron.
JavaScript
2
star
29

openwrt-builder

Shell
2
star
30

react-tencent-captcha

A TCaptcha component for React
JavaScript
2
star
31

dva-antd-typescript-starter

Get started with Dva.js and Ant Design.
TypeScript
2
star
32

react-echarts-v3-demo

JavaScript
2
star
33

create-react-app-antd-mobile-starter

Get started with create-react-app and antd-mobile.
JavaScript
1
star
34

vue-mui

A Vue.js + MUI project.
JavaScript
1
star
35

react-countup-v2

React component wrap for CountUp.js
JavaScript
1
star
36

flower-password-windows

Flower Password on Windows
Visual Basic
1
star
37

vue-echarts-wrapper

Vue.js component wrap for ECharts.js
1
star
38

umi-plugin-antd-themes

antd theme plugin
JavaScript
1
star
39

blog-comments

1
star
40

gallery

1
star
41

react-duoshuo

A DuoShuo component for React
JavaScript
1
star
42

vue-boilerplate-v2

A Vue.js(2.x+) project boilerplate
JavaScript
1
star
43

vue-duoshuo

Vue.js(v2.x+) component wrap for DuoShuo.js
JavaScript
1
star
44

pyFlowerPassword

Flower Password implementation for Python.
Python
1
star
45

toys

JavaScript
1
star
46

apisix-dashboard-demo

APISIX Dashboard
JavaScript
1
star
47

chijidun-cli

The ChiJiDun command line utility.
JavaScript
1
star
48

next-dva-antd-mobile-starter

Get started with Next.js and Ant Design Mobile.
1
star
49

iosFlowerPassword

Flower Password implementation for iOS.
Objective-C
1
star
50

create-react-app-antd-starter

Get started with create-react-app and antd.
JavaScript
1
star
51

react-aliyun-captcha

A Aliyun Captcha component for React
JavaScript
1
star
52

xlsdg.github.io

xLsDg's Blog
HTML
1
star
53

jsFlowerPassword

☠️ Flower Password implementation for JavaScript. Move to
JavaScript
1
star
54

flower-password-hybrid-app-v2

Flower Password hybrid app base on Vue.js + MUI + HTML5Plus(iOS and Android).
JavaScript
1
star
55

fpCode.js

Flower Password implementation for the browser and node.js
JavaScript
1
star
56

edit-this-cookie-to-tough-cookie

Convert EditThisCookie json format to ToughCookie json file
JavaScript
1
star
57

react-component-lifecycle

React 组件生命周期各个阶段的执行顺序
JavaScript
1
star
58

react-necaptcha

A NECaptcha component for React
JavaScript
1
star
59

umi-mobx-antd-starter

Get started with Umi.js and Ant Design.
JavaScript
1
star