-
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.
- Loading branch information
Showing
9 changed files
with
219 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#### pattern ✨ | ||
|
||
<description>**optional** _object | Function_</description> | ||
|
||
Set the pattern style of the geometries. | ||
- PatternOption: consists of `type` and `cfg`, `type` includes: `dot`, `line`, `square`, `cfg` is optional. | ||
- Features: pattern will override the `style` of geometry (such as pieStyle, columnStyle, etc.). | ||
- Usage: You can set a uniform pattern style for all geometries of the chart by using configuration (`PatternOption`) or `CanvasPattern` object, and a `callback` is provided to set the pattern for each geometry. | ||
|
||
The type of pattern is defined as follows: | ||
```plain | ||
PatternAttr = | ||
| CanvasPattern | ||
| PatternOption | ||
| ((datum: Datum, color: string /** inherit color */) => PatternOption | CanvasPattern); | ||
``` | ||
|
||
Usage: | ||
```ts | ||
// set a uniform pattern style for all geometries | ||
{ | ||
pattern: { | ||
type: 'dot', | ||
cfg: { | ||
size: 4, | ||
padding: 4, | ||
rotation: 0, | ||
fill: '#FFF', | ||
isStagger: true, | ||
}, | ||
}, | ||
} | ||
// set the pattern for each geometry | ||
{ | ||
pattern: ({type}, color) =>{ | ||
if(type ==='分类一') { | ||
return { | ||
type: 'dot', | ||
cfg: { | ||
backgroundColor: color, // inherit color | ||
} | ||
} | ||
} else if(type ==='分类二') { | ||
return { | ||
type: 'square', | ||
cfg: { | ||
backgroundColor: 'pink', // custom color | ||
} | ||
} | ||
} else if(type ==='分类三') { | ||
return { | ||
type: 'line' | ||
} | ||
} | ||
}, | ||
} | ||
``` | ||
<!--Configuration items for each pattern--> | ||
|
||
Common configuration(cfg) for all types of pattern: | ||
|
||
| Attribute | Type | Description | | ||
| ------------- | --------------- | ---------------- | | ||
| backgroundColor | _string_ | Background color of the pattern | | ||
| fill | _string_ | Fill color of the symbol in pattern | | ||
| fillOpacity | _number_ | Transparency of the symbol in pattern | | ||
| stroke | _string_ | Stroke color of the symbol in pattern | | ||
| strokeOpacity | _number_ | Stroke opacity of the symbol in pattern | | ||
| lineWidth | _number_ | The thickness of the symbol's stroke | | ||
| opacity | _number_ | Overall transparency of the pattern | | ||
| rotation | _number_ | Rotation angle of the pattern | | ||
|
||
Additional configuration for dotPattern | ||
|
||
| Attribute | Type | Description | | ||
| ------------- | --------------- | ---------------- | | ||
| size | _number_ | The size of the dot, default: `4` | | ||
| padding | _number_ | The distance between dots, default: `2` | | ||
| isStagger | _boolean_ | Staggered dots. default: `true` | | ||
|
||
Additional configuration for linePattern | ||
|
||
| Attribute | Type | Description | | ||
| ------------- | --------------- | ---------------- | | ||
| spacing | _number_ | The distance between the two lines, default: `5` | | ||
|
||
Additional configuration for squarePattern | ||
|
||
| Attribute | Type | Description | | ||
| ------------- | --------------- | ---------------- | | ||
| size | _number_ | The size of the square, default: `4` | | ||
| padding | _number_ | The distance between squares, default:`0` | | ||
| isStagger | _boolean_ | Staggered squares. default:`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,93 @@ | ||
#### pattern ✨ | ||
|
||
<description>**optional** _object | Function_</description> | ||
|
||
设置图形的贴图样式。 | ||
- 配置项:由`type`和`cfg`组成,`type`目前包括三种类型:`dot`、`line`、`square`,`cfg`为可选项。 | ||
- 特点:`pattern`会覆盖当前图形设置的`style`样式(如 pieStyle、columnStyle 等)。 | ||
- 使用方式:可通过 配置项(PatternOption) 或传入 CanvasPattern 对象 的方式给图表的所有图形设置统一的贴图样式,还提供了 callback 的方式给对应的图形设置样式。 | ||
|
||
pattern 的类型定义如下: | ||
```plain | ||
PatternAttr = | ||
| CanvasPattern | ||
| PatternOption | ||
| ((datum: Datum, color: string /** inherit color */) => PatternOption | CanvasPattern); | ||
``` | ||
|
||
具体用法: | ||
```ts | ||
// 给图形设置统一贴图 | ||
{ | ||
pattern: { | ||
type: 'dot', | ||
cfg: { | ||
size: 4, | ||
padding: 4, | ||
rotation: 0, | ||
fill: '#FFF', | ||
isStagger: true, | ||
}, | ||
}, | ||
} | ||
// 给图形分别设置贴图 | ||
{ | ||
pattern: ({type}, color) =>{ | ||
if(type ==='分类一') { | ||
return { | ||
type: 'dot', | ||
cfg: { | ||
backgroundColor: color, // 继承主题颜色 | ||
} | ||
} | ||
} else if(type ==='分类二') { | ||
return { | ||
type: 'square', | ||
cfg: { | ||
backgroundColor: 'pink', // 自定义颜色 | ||
} | ||
} | ||
} else if(type ==='分类三') { | ||
return { | ||
type: 'line' | ||
} | ||
} | ||
}, | ||
} | ||
``` | ||
<!--各个 pattern 的配置项--> | ||
|
||
pattern 共有的 cfg 配置项 | ||
|
||
| 属性名 | 类型 | 介绍 | | ||
| ------------- | --------------- | ---------------- | | ||
| backgroundColor | _string_ | 贴图的背景色 | | ||
| fill | _string_ | 贴图元素的填充色 | | ||
| fillOpacity | _number_ | 贴图元素填充的透明度 | | ||
| stroke | _string_ | 贴图元素的描边色 | | ||
| strokeOpacity | _number_ | 贴图元素的描边透明度色 | | ||
| lineWidth | _number_ | 贴图元素的描边粗细 | | ||
| opacity | _number_ | 贴图整体的透明度 | | ||
| rotation | _number_ | 贴图整体的旋转角度 | | ||
|
||
dotPattern 额外的 cfg 配置项 | ||
|
||
| 属性名 | 类型 | 介绍 | | ||
| ------------- | --------------- | ---------------- | | ||
| size | _number_ | 圆点的大小,默认为`4` | | ||
| padding | _number_ | 圆点之间的间隔,默认为`4` | | ||
| isStagger | _boolean_ | 圆点之间是否交错,默认为`true` | | ||
|
||
linePattern 额外的 cfg 配置项 | ||
|
||
| 属性名 | 类型 | 介绍 | | ||
| ------------- | --------------- | ---------------- | | ||
| spacing | _number_ | 两条线之间的距离,默认为`5` | | ||
|
||
squarePattern 额外的 cfg 配置项 | ||
|
||
| 属性名 | 类型 | 介绍 | | ||
| ------------- | --------------- | ---------------- | | ||
| size | _number_ | 矩形的大小,默认为`4` | | ||
| padding | _number_ | 矩形之间的间隔,默认为`4` | | ||
| isStagger | _boolean_ | 矩形之间是否交错,默认为`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
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