This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5f12e77
Showing
13 changed files
with
24,780 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
- let there be rc-g2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.