# rc-echarts

> react echarts

Latest version **0.3.1** (published 2016-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install rc-echarts
pnpm add rc-echarts
yarn add rc-echarts
bun add rc-echarts
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2016-06-24 |
| First published | 2015-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 128 |
| Author | somonus |
| Maintainers | somonus |
| Keywords | react, echarts, chart, charts |

## Links

- npm: https://www.npmjs.com/package/rc-echarts
- Repository: https://github.com/somonus/react-echarts
- Issues: https://github.com/somonus/react-echarts/issues
- npm.io page: https://npm.io/package/rc-echarts

## Dependencies (2)

- [echarts](https://npm.io/package/echarts.md) 3.1.10
- [babel-runtime](https://npm.io/package/babel-runtime.md) 5.8.25

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2016-06-24
- 0.3.0 — 2016-06-14
- 0.2.1 — 2016-06-14
- 0.2.0 — 2016-05-13
- 0.1.9 — 2016-01-22
- 0.1.7 — 2015-12-31
- 0.1.8 — 2015-12-31
- 0.1.6 — 2015-12-31
- 0.1.5 — 2015-12-29
- 0.1.4 — 2015-12-28
- 0.1.3 — 2015-12-23
- 0.1.2 — 2015-12-21
- 0.1.1 — 2015-12-15
- 0.1.0 — 2015-12-14

## README

# rc-echarts

## install

$ npm install rc-echarts

## Usage

###用法一

完全和echarts一致，将echarts的options传给组件。通过onReady能获取到echarts对象，从而进行绑定事件等一系列操作。

```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  ready(echart) {
    console.log(echart);
    echart.on('click', (params)=>{
      console.log(params);
      alert("click");
    });
  }

  render() {
    <Chart options={ options } onReady={this.ready} />
  }
})
ReactDOM.render(<myChart />, container);

```

###用法二

将options中的series抽离成单独的react组件。

注：以下示例中，options为echarts官方的options除了series的所有选项，详见[文档](http://echarts.baidu.com/options.html)。series为echarts官方series的选项，详见[文档](http://echarts.baidu.com/options.html#series)

*折线图*
```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  render() {
    <Chart {...options} >
        <Chart.Line {...series} />
        <Chart.Line {...series1} />
    </Chart>
  }
})
ReactDOM.render(<myChart />, container);

```

*柱状图*
```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  render() {
    <Chart {...options} >
        <Chart.Bar {...series} />
    </Chart>
  }
})
ReactDOM.render(<myChart />, container);
```

*饼图*
```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  render() {
    <Chart {...options} >
        <Chart.Pie {...series} />
    </Chart>
  }
})
ReactDOM.render(<myChart />, container);
```

*标签云图*
```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  render() {
    <Chart {...options} >
        <Chart.Cloud {...series} />
    </Chart>
  }
})
ReactDOM.render(<myChart />, container);
```

*地图*
```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  render() {
    <Chart {...options} >
        <Chart.Map {...series} />
    </Chart>
  }
})
ReactDOM.render(<myChart />, container);
```
*未指定类型的series*

如果想要导入非前面几种类型的图表，可使用Chart.Series。自己指定类型。

```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  render() {
    <Chart {...options} >
        <Chart.Series {...series} type="line" />
    </Chart>
  }
})
ReactDOM.render(<myChart />, container);
```

*获取echarts对象*

可使用onReady属性来获取echarts对象，对其进行官方提供的各种操作，如绑定事件等。

```js
import Chart from 'rc-echart';
import React from 'react';
import ReactDOM from 'react-dom';

const myChart = React.creatClass({
  ready(chart) {
    chart.on('click', ()=>{
      alert('click');
    });
  }

  render() {
    const options = {
      legend: {
        data: ['最高气温', '最低气温'],
      },
      xAxis: [{
        type: 'category',
        boundaryGap: false,
        data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
      }],
      yAxis: [{
        type: 'value',
        axisLabel: {
          formatter: '{value} °C'
        }
      }],
    };
    return (
      <Chart {...options} onReady={this.ready}>
        <Chart.Line
          name="最高气温"
          data={[11, 11, 15, 13, 12, 13, 10]}/>
        <Chart.Line
          name="最低气温"
          data={[1, -2, 2, 5, 3, 2, 0]}/>
      </Chart>
    );
  }
})
ReactDOM.render(<myChart />, container);
```

##Example

*run demo*

```
npm install
npm start
```
open [http://localhost:8080/](http://localhost:8080/)

## License

rc-echart is released under the MIT license.

---
_Source: https://npm.io/package/rc-echarts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
