UNPKG

6.7 kBMarkdownView Raw
1![](https://user-images.githubusercontent.com/6628666/44565549-4ab5d480-a79b-11e8-8d75-11420845efc0.png)
2
3[![](https://img.shields.io/travis/antvis/f2.svg)](https://travis-ci.org/antvis/f2) ![](https://img.shields.io/badge/language-javascript-red.svg) ![](https://img.shields.io/badge/license-MIT-000000.svg) [![npm package](https://img.shields.io/npm/v/@antv/f2.svg)](https://www.npmjs.com/package/@antv/f2) [![NPM downloads](http://img.shields.io/npm/dm/@antv/f2.svg)](https://npmjs.org/package/@antv/f2) [![Percentage of issues still open](http://isitmaintained.com/badge/open/antvis/f2.svg)](http://isitmaintained.com/project/antvis/f2 'Percentage of issues still open')
4
5<p align="left">
6 <a href="https://twitter.com/intent/tweet?text=Introducing%20F2,%20an%20elegant,%20interactive%20and%20flexible%20charting%20library%20for%20mobile.&url=https://medium.com/@SimaZwx/https-medium-com-simazwx-introducing-f2-c44fb4e74c2d&hashtags=javascript,mobile,charts,dataviz,visualization,F2"><img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social"> </a>
7</p>
8
9[中文 README](./README.md)
10
11F2 is **born for mobile**, developed for developers as well as designers. It is Html5 Canvas-based, and is also compatible with Node.js, Weex and React Native. Based on [the grammar of graphics](https://www.cs.uic.edu/~wilkinson/TheGrammarOfGraphics/GOG.html), F2 provides all the chart types you'll need. Our mobile design guidelines enable better user experience in mobile visualzation projects.
12
13<p align="center"><a href="https://f2.antv.vision/en/examples"><img src="https://user-images.githubusercontent.com/6628666/44565498-f4e12c80-a79a-11e8-98fc-73ee58547dc9.png" /></a></p>
14
15> Special thanks to [Leland Wilkinson](https://en.wikipedia.org/wiki/Leland_Wilkinson), the author of [_The Grammar Of Graphics_](https://www.cs.uic.edu/~wilkinson/TheGrammarOfGraphics/GOG.html), whose book served as the foundation for F2 and G2.
16
17## Installation
18
19```bash
20$ npm install @antv/f2
21```
22
23## Features
24
25### Born for mobile
26
27- **Design for mobile**: make data more alive and chart interactions more natural.
28
29 <p align="left"><img src="https://user-images.githubusercontent.com/6628666/44565525-21954400-a79b-11e8-8d69-cd95fa6b9a99.gif" width="600"></p>
30 <p align="left"><img src="https://user-images.githubusercontent.com/6628666/44565524-21954400-a79b-11e8-9aea-9e38d458e37b.gif" width="600" ></p>
31
32- **Performance**: small package size(version without interaction is 44k after gzip) with great rendering performance.
33
34- **Compatibility**: multi-end, Multi-runtime support. Besides H5 env, F2 can also run in [Node.js](https://antv.gitbook.io/f2/platform), [Weex rendering](https://github.com/weex-plugins/weex-chart) and [React Native](https://github.com/chenshuai2144/f2-demo), also [支付宝小程序](https://github.com/antvis/my-f2) and [微信小程序](https://github.com/antvis/wx-f2).
35
36<p align="center"><img src="https://gw.alipayobjects.com/zos/rmsportal/cPUduuYgROeJwRJSRuFK.png"></p>
37
38### All the chart types you want
39
40With the power of grammar of graphics, F2 supports data-driven [50+ chart types](https://f2.antv.vision/zh/examples)(the amount can be even more, which is depended on you) including classical charts such as line, column/bar chart, pie chart, scatter plot, gauges, etc. Additionally, F2 also provides feature-riched chart components, such as Tooltip, Legend and Guide.
41
42### Flexible and Interactive
43
44We also provide developers with flexible extension mechanisms, including shape, animation, and interactive customization capabilities, as well as flexible styling to meet a variety of personalized charting requirements.
45
46<img src="https://user-images.githubusercontent.com/6628666/44565579-6c16c080-a79b-11e8-9494-86f3ad477341.gif" width="200"><img src="https://user-images.githubusercontent.com/6628666/44565581-6c16c080-a79b-11e8-8210-f4e797480e87.gif" width="200"><img src="https://user-images.githubusercontent.com/6628666/44565580-6c16c080-a79b-11e8-956d-4d15455468a3.gif" width="200"><img src="https://user-images.githubusercontent.com/6628666/44565583-6caf5700-a79b-11e8-8e9e-a1fa12ddcbf1.gif" width="200">
47
48## Links
49
50- [Website](https://f2.antv.vision/)
51- English documents: https://f2.antv.vision/en
52- Chart demos: https://f2.antv.vision/en/examples
53- 中文文档: https://f2.antv.vision/zh
54
55## Other libraries base on F2
56
57- [ant-design-mobile-chart](https://github.com/ant-design/ant-design-mobile-chart): Ant Design Mobile Chart based on F2. (React).
58- [BizGoblin](https://github.com/alibaba/BizGoblin):Data visualization library based F2 and React.
59- [VChart](https://doc.vux.li/zh-CN/components/v-chart.html): Mobile Chart Components based on vux and F2. (Vue).
60- [weex-chart](https://github.com/weex-plugins/weex-chart): Chart components based on Weex and F2.
61
62## Demos
63
64[Chart Demos](https://f2.antv.vision/en/examples)
65
66**Or just scan the below qrcode to see demos in mobile:**
67
68<img src="https://gw.alipayobjects.com/zos/rmsportal/nzlxIzUBlBRVGMyaZigG.png" style="width:150px;">
69
70## Getting Started
71
72<img src="https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/54ad3af8-c30d-43ca-b0e8-e21c4ea3d438.png" width="375">
73
74```html
75<canvas id="mountNode"></canvas>
76```
77
78```js
79// F2 对数据源格式的要求,仅仅是 JSON 数组,数组的每个元素是一个标准 JSON 对象。
80const data = [
81 { genre: 'Sports', sold: 275 },
82 { genre: 'Strategy', sold: 115 },
83 { genre: 'Action', sold: 120 },
84 { genre: 'Shooter', sold: 350 },
85 { genre: 'Other', sold: 150 },
86];
87
88// 获取 canvas context
89const context = document.getElementById('mountNode').getContext('2d');
90const { props } = (
91 <Canvas context={context} pixelRatio={window.devicePixelRatio}>
92 <Chart data={data}>
93 <Axis field="genre" />
94 <Axis field="sold" />
95 <Interval x="genre" y="sold" color="genre" />
96 <Tooltip />
97 </Chart>
98 </Canvas>
99);
100
101const canvas = new Canvas(props);
102await canvas.render();
103```
104
105## Development
106
107```bash
108$ npm install
109
110# setup
111$ npm run bootstrap
112
113# run test case
114$ npm run test-watch
115```
116
117## How to Contribute
118
119Please let us know how can we help. Do check out [issues](https://github.com/antvis/f2/issues) for bug reports or suggestions first.
120
121To become a contributor, please follow our [contributing guide](https://github.com/antvis/f2/blob/master/CONTRIBUTING.md).
122
123## Experience Improvement Program Description
124
125Since version 3.1.12 (released on 2018-06-20), we add `F2.track(true)` method for our user experience improvement program. But now the program has finish, so we remove the method from F2 since version 3.3.4. We are very sorry if it has caused trouble for you.
126
127## License
128
129[MIT license](./LICENSE).