-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(coordinate): 支持 coordinate 坐标转换配置 (#3172)
- Loading branch information
Showing
30 changed files
with
271 additions
and
40 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
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
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
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,20 @@ | ||
#### coordinate | ||
|
||
<description>**optional** _Transformation[] _</description> | ||
|
||
Transformations of coordinate; | ||
|
||
Types of _Transformation_ are as follows: | ||
|
||
```ts | ||
type Transformation = | ||
| { | ||
type: 'reflectX'; // send (x, y) to (-x, y) | ||
} | ||
| { | ||
type: 'reflectY'; // send (x, y) to (x, -y) | ||
} | ||
| { | ||
type: 'transpose'; // send (x, y) to (y, x) | ||
}; | ||
``` |
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,20 @@ | ||
#### coordinate | ||
|
||
<description>**optional** _Transformation[] _</description> | ||
|
||
坐标转换配置。 | ||
|
||
__Transformation_ 类型定义如下: | ||
|
||
```ts | ||
type Transformation = | ||
| { | ||
type: 'reflectX'; // send (x, y) to (-x, y) | ||
} | ||
| { | ||
type: 'reflectY'; // send (x, y) to (x, -y) | ||
} | ||
| { | ||
type: 'transpose'; // send (x, y) to (y, x) | ||
}; | ||
``` |
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,22 @@ | ||
import { Bar } from '@antv/g2plot'; | ||
|
||
const data = [ | ||
{ year: '1951 年', value: 38 }, | ||
{ year: '1952 年', value: 52 }, | ||
{ year: '1956 年', value: 61 }, | ||
{ year: '1957 年', value: 145 }, | ||
{ year: '1958 年', value: 48 }, | ||
]; | ||
|
||
const bar = new Bar('container', { | ||
data, | ||
xField: 'value', | ||
yField: 'year', | ||
seriesField: 'year', | ||
legend: { | ||
position: 'top-left', | ||
}, | ||
coordinate: [{ type: 'reflectX' }, { type: 'reflectY' }], | ||
}); | ||
|
||
bar.render(); |
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,68 @@ | ||
import { Column } from '@antv/g2plot'; | ||
|
||
const data = [ | ||
{ | ||
type: '家具家电', | ||
sales: 38, | ||
}, | ||
{ | ||
type: '粮油副食', | ||
sales: 52, | ||
}, | ||
{ | ||
type: '生鲜水果', | ||
sales: 61, | ||
}, | ||
{ | ||
type: '美容洗护', | ||
sales: 145, | ||
}, | ||
{ | ||
type: '母婴用品', | ||
sales: 48, | ||
}, | ||
{ | ||
type: '进口食品', | ||
sales: 38, | ||
}, | ||
{ | ||
type: '食品饮料', | ||
sales: 38, | ||
}, | ||
{ | ||
type: '家庭清洁', | ||
sales: 38, | ||
}, | ||
]; | ||
|
||
const columnPlot = new Column('container', { | ||
data, | ||
xField: 'type', | ||
yField: 'sales', | ||
label: { | ||
// 可手动配置 label 数据标签位置 | ||
position: 'middle', // 'top', 'bottom', 'middle', | ||
// 配置样式 | ||
style: { | ||
fill: '#FFFFFF', | ||
opacity: 0.6, | ||
}, | ||
}, | ||
xAxis: { | ||
label: { | ||
autoHide: true, | ||
autoRotate: false, | ||
}, | ||
}, | ||
meta: { | ||
type: { | ||
alias: '类别', | ||
}, | ||
sales: { | ||
alias: '销售额', | ||
}, | ||
}, | ||
coordinate: [{ type: 'reflectY' }], | ||
}); | ||
|
||
columnPlot.render(); |
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
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
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
Oops, something went wrong.