forked from antvis/G2Plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connected-area): 联通区域支持样式配置 (antvis#2667)
- [x] demo & docs
- Loading branch information
Showing
5 changed files
with
91 additions
and
23 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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
Applicable to stacked bar charts and stacked bar charts, the link area component provides visual assistant identification by drawing the link area of the same field, which is convenient for data comparison. | ||
Applicable to stacked bar charts and stacked bar charts, the link area component provides visual assistant identification by drawing the link area of the same field, which is convenient for data comparison. (Attention:could not use with **columnBackground** ) | ||
|
||
<description>**optional** _object_ | _false_</description> | ||
|
||
| Properties | Type | Required | Default | Description | | ||
| ---------- | ---------------- | ------------ | ---------------------- | | ||
| trigger | 'hover'、'click' | No |'hover' | Trigger method | | ||
| style | _ConnectedAreaStyleCfg_ | | No | | StyleCfg of connectedArea | | ||
|
||
Types of **_ConnectedAreaStyleCfg_** are as follows: | ||
|
||
```sign | ||
type ConnectedAreaStyleCfg = ShapeAttrs | ((oldStyle: ShapeAttrs, element: Element) => ShapeAttrs); | ||
``` | ||
|
||
**Examples:** | ||
|
||
<playground path="column/stacked/demo/connect-area.ts" rid="connectedArea"></playground> |
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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
适用于堆叠柱状图和堆叠条形图,联通区域组件通过绘制同一字段的联通区域提供视觉上的辅助识别,方便进行数据对比。 | ||
适用于堆叠柱状图和堆叠条形图,联通区域组件通过绘制同一字段的联通区域提供视觉上的辅助识别,方便进行数据对比。(注意:不能和 **columnBackground** 同时使用) | ||
|
||
<description>**optional** _object_ | _false_</description> | ||
|
||
| 配置项 | 类型 | 是否必选 | 默认值| 功能描述 | | ||
| ------- | ---------------- | ------------ | ----------------- | | ||
| trigger | 'hover'、'click' | 否 |'hover' | 触发方式 | | ||
| trigger | _'hover'、'click'_ | 否 |'hover' | 触发方式 | | ||
| style | _ConnectedAreaStyleCfg_ | | 否 | | 联通区域的样式配置 | | ||
|
||
**_ConnectedAreaStyleCfg_** 类型定义如下: | ||
|
||
```sign | ||
type ConnectedAreaStyleCfg = ShapeAttrs | ((oldStyle: ShapeAttrs, element: Element) => ShapeAttrs); | ||
``` | ||
|
||
**图表示例:** | ||
|
||
<playground path="column/stacked/demo/connect-area.ts" rid="connectedArea"></playground> |
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,25 @@ | ||
import { Column } from '@antv/g2plot'; | ||
|
||
fetch('https://gw.alipayobjects.com/os/antfincdn/8elHX%26irfq/stack-column-data.json') | ||
.then((data) => data.json()) | ||
.then((data) => { | ||
const stackedColumnPlot = new Column('container', { | ||
data, | ||
isStack: true, | ||
xField: 'year', | ||
yField: 'value', | ||
seriesField: 'type', | ||
label: { | ||
// 可手动配置 label 数据标签位置 | ||
position: 'middle', // 'top', 'bottom', 'middle' | ||
}, | ||
interactions: [{ type: 'active-region', enable: false }], | ||
connectedArea: { | ||
style: (oldStyle, element) => { | ||
return { fill: 'rgba(0,0,0,0.25)', stroke: oldStyle.fill, lineWidth: 0.5 }; | ||
}, | ||
}, | ||
}); | ||
|
||
stackedColumnPlot.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