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
Showing
5 changed files
with
232 additions
and
9 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
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,74 @@ | ||
--- | ||
id: antv-f2 | ||
title: AntV F2 | ||
sidebar_label: AntV F2 | ||
--- | ||
|
||
## [AntV F2](https://antv.gitee.io/zh) | ||
|
||
### 需求 | ||
|
||
- 小程序基础库 >= 2.7.0 | ||
|
||
### 使用 | ||
|
||
```jsx | ||
import React from 'react' | ||
import { F2 } from '@tarojsx/library/dist/antv' | ||
|
||
const Demo = () => { | ||
return ( | ||
<F2 | ||
style={{ width: '100vw', height: '50vh' }} | ||
// F2 对数据源格式的要求,仅仅是 JSON 数组,数组的每个元素是一个标准 JSON 对象。 | ||
data={[ | ||
{ genre: 'Sports', sold: 275 }, | ||
{ genre: 'Strategy', sold: 115 }, | ||
{ genre: 'Action', sold: 120 }, | ||
{ genre: 'Shooter', sold: 350 }, | ||
{ genre: 'Other', sold: 150 }, | ||
]} | ||
> | ||
{ | ||
// Step 1: 接收 Chart 对象 | ||
({ chart, data }) => { | ||
// Step 2: 载入数据源 | ||
chart.source(data) | ||
|
||
// Step 3:创建图形语法,绘制柱状图,由 genre 和 sold 两个属性决定图形位置,genre 映射至 x 轴,sold 映射至 y 轴 | ||
chart.interval().position('genre*sold').color('genre') | ||
|
||
// Step 4: 渲染图表 | ||
chart.render() | ||
} | ||
} | ||
</F2> | ||
) | ||
} | ||
``` | ||
|
||
import { F2 } from '@tarojsx/library/dist/antv' | ||
import { UI } from '@/ui' | ||
|
||
<UI phone title="AntV F2"> | ||
{() => { | ||
return ( | ||
<F2 | ||
style={{ width: '750px', height: '750px' }} | ||
data={[ | ||
{ genre: 'Sports', sold: 275 }, | ||
{ genre: 'Strategy', sold: 115 }, | ||
{ genre: 'Action', sold: 120 }, | ||
{ genre: 'Shooter', sold: 350 }, | ||
{ genre: 'Other', sold: 150 }, | ||
]} | ||
> | ||
{({ chart, data }) => { | ||
chart.source(data) | ||
chart.interval().position('genre*sold').color('genre') | ||
chart.render() | ||
}} | ||
</F2> | ||
) | ||
}} | ||
</UI> |
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
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
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