Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
[1.0.0] let there be g2-react
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredleechn committed Aug 4, 2016
0 parents commit 5f12e77
Show file tree
Hide file tree
Showing 13 changed files with 24,780 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"parser": "babel-eslint",
"extends": "eslint-config-airbnb",
"rules": {
"no-console": [0]
},
"ecmaFeatures": {
"generators": 1,
"experimentalObjectRestSpread": true
}
}
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
*.iml
*.log
.idea
.ipr
.iws
*~
~*
*.diff
*.patch
*.bak
.DS_Store
Thumbs.db
.project
.*proj
.svn
*.swp
*.swo
*.pyc
*.pyo
node_modules
.cache
*.css
build
lib
coverage
__site
dist
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js

node_js:
- "4"
- "5"

after_success:
- npm run coveralls
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- let there be rc-g2
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# g2-react

Factory wrapper for using [G2](http://g2.alipay.com) easier in a React Component with dynamic `data` and `size` props

*Note that `g2-react` is just a wrapper, if you want to make a better chart, `docs of G2` is [HERE](http://g2.alipay.com/)*

[![NPM version][npm-image]][npm-url]
[![npm download][download-image]][download-url]

[npm-image]: http://img.shields.io/npm/v/g2-react.svg?style=flat-square
[npm-url]: http://npmjs.org/package/g2-react
[download-image]: https://img.shields.io/npm/dm/g2-react.svg?style=flat-square
[download-url]: https://npmjs.org/package/g2-react

## Example

- [online example](http://react-component.github.io/g2)

- [local example](http://localhost:8989/)


## Install

```bash
$ npm install g2 --save
$ npm install g2-react --save
```

`g2-react` works with a [peerDependencies](https://nodejs.org/en/blog/npm/peer-dependencies/) of `g2`, you can specify the version of `g2` in your `package.json`

## Usage

```js
import createG2 from 'g2-react';
import { Stat } from 'g2';

const Pie = createG2(chart => {
chart.coord('theta');
chart.intervalStack().position(Stat.summary.proportion()).color('cut');
chart.render();
});

React.render(
<Pie
data={this.state.data}
width={this.state.width}
height={this.state.height}
plotCfg={this.state.plotCfg}
ref="myChart"
/>
);
```


## Props

See detail api of [g2](http://g2.alipay.com/api/)

<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 100px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>width</td>
<td>number.isRequired</td>
<td></td>
<td>width of chart</td>
</tr>
<tr>
<td>height</td>
<td>number.isRequired</td>
<td></td>
<td>height of chart</td>
</tr>
<tr>
<td>plotCfg</td>
<td>object</td>
<td></td>
<td>config of chart, margin, border, backgroud...</td>
</tr>
<tr>
<td>data</td>
<td>arrayOf(object).isRequired</td>
<td></td>
<td>data source</td>
</tr>
<tr>
<td>forceFit</td>
<td>bool</td>
<td>false</td>
<td>if the width of chart autoFit with parent</td>
</tr>
</tbody>
</table>


## Development

```bash
$ git clone [email protected]:react-component/g2.git
$ npm install
$ npm run doc
```

## License

g2-react is released under the MIT license.
Loading

0 comments on commit 5f12e77

Please sign in to comment.