Skip to content

Commit

Permalink
docs: 增加 2 个转化分析漏斗图 demo, 带跳转 (#2807)
Browse files Browse the repository at this point in the history
* docs: 增加一个转化分析漏斗图, 带跳转

* docs: 更新dingding

* fix: 修复 lint 问题
  • Loading branch information
visiky authored Aug 18, 2021
1 parent f1a3059 commit df6a984
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ This project follows the [all-contributors](https://github.com/all-contributors/

钉钉群组号码: 30233731

<img src="https://gw.alipayobjects.com/zos/antfincdn/9sHnl5k%26u4/dingdingqun.png" width="200" height="266" />
<img src="https://gw.alipayobjects.com/zos/antfincdn/8qEHi7GiaN/G2Plot-dingding.JPG" width="200" height="266" />

## 🔗 Links
Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ bar.render();

钉钉群组号码: 30233731

<img src="https://gw.alipayobjects.com/zos/antfincdn/9sHnl5k%26u4/dingdingqun.png" width="200" height="266" />
<img src="https://gw.alipayobjects.com/zos/antfincdn/8qEHi7GiaN/G2Plot-dingding.JPG" width="200" height="266" />

## 🔗 相关链接
Expand Down
2 changes: 1 addition & 1 deletion __tests__/bugs/issue-2749-spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Line, DualAxes } from '../../src';
import { Line } from '../../src';
import { createDiv } from '../utils/dom';

describe('#2749', () => {
Expand Down
1 change: 1 addition & 0 deletions docs/manual/contact.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ If you have any questions, suggestions, feedback or willingness to communicate,
- DingTalk Group Number: 30233731

<img src="https://gw.alipayobjects.com/zos/antfincdn/9sHnl5k%26u4/dingdingqun.png" width="200" height="266" />
<img src="https://gw.alipayobjects.com/zos/antfincdn/8qEHi7GiaN/G2Plot-dingding.JPG" width="200" height="266" />
1 change: 1 addition & 0 deletions docs/manual/contact.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ order: 9
- 钉钉群组号码: 30233731

<img src="https://gw.alipayobjects.com/zos/antfincdn/9sHnl5k%26u4/dingdingqun.png" width="200" height="266" />
<img src="https://gw.alipayobjects.com/zos/antfincdn/8qEHi7GiaN/G2Plot-dingding.JPG" width="200" height="266" />
74 changes: 74 additions & 0 deletions examples/case/advanced/demo/conversion-analysis-bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { Bar, G2 } from '@antv/g2plot';

G2.registerInteraction('conversion-tag-active', {
start: [
{
isEnable: (context) => {
const element = context.event.data?.element as G2.Element;
const href = element?.data?.href;
if (href) {
return true;
}
return false;
},
trigger: 'conversion-tag-group:mouseenter',
action: (context) => {
const view = context.view;
// 设置鼠标样式
view.getCanvas().setCursor('pointer');
const tagGroup = context.event.gEvent.shape;
if (tagGroup) {
tagGroup.attr('fill', 'rgba(251,151,71,0.85)');
}
},
},
{
trigger: 'conversion-tag-group:mousedown',
action: (context) => {
const element = context.event.data?.element;
const href = element?.data?.href;
window.open(href);
},
},
],
end: [
{
trigger: 'conversion-tag-group:mouseleave',
action: (context) => {
const view = context.view;
// 设置鼠标样式
view.getCanvas().setCursor('default');
const tagGroup = context.event.gEvent.shape;
if (tagGroup) {
tagGroup.attr('fill', '#efefef');
}
},
},
],
});

const plotData = [
{ action: '浏览网站', pv: 50000, href: 'https://github.com/antvis/g2plot' },
{ action: '放入购物车', pv: 35000 },
{ action: '生成订单', pv: 25000, href: 'https://github.com/antvis/g2' },
{ action: '支付订单', pv: 15000 },
{ action: '完成交易', pv: 8500 },
];

const plot = new Bar('container', {
data: plotData,
xField: 'pv',
yField: 'action',
conversionTag: {
offset: 0,
spacing: 8,
arrow: {
style: {
fill: '#efefef',
},
},
},
interactions: [{ type: 'active-region', enable: false }, { type: 'conversion-tag-active' }],
});

plot.render();
79 changes: 79 additions & 0 deletions examples/case/advanced/demo/conversion-analysis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Bar, G2 } from '@antv/g2plot';

// TODO 需要介绍下 convetsion-tag 的组成
G2.registerInteraction('conversion-tag-active', {
start: [
{
isEnable: (context) => {
const element = context.event.data?.element as G2.Element;
const href = element?.data?.href;
if (href) {
return true;
}
return false;
},
trigger: 'conversion-tag-group:mouseenter',
action: (context) => {
const view = context.view;
// 设置鼠标样式
view.getCanvas().setCursor('pointer');
const tagArrow = context.event.gEvent.shape;
if (tagArrow.get('name') === 'conversion-tag-arrow') {
tagArrow.attr('fill', 'rgba(251,151,71,0.85)');
} else {
const siblings = tagArrow.get('parent').getChildren();
const shape = siblings[siblings.findIndex((c) => c.get('origin') === tagArrow.get('origin')) - 1];
shape?.attr('fill', 'rgba(251,151,71,0.85)');
}
},
},
{
trigger: 'conversion-tag-group:mousedown',
action: (context) => {
const element = context.event.data?.element;
const href = element?.data?.href;
window.open(href);
},
},
],
end: [
{
trigger: 'conversion-tag-group:mouseleave',
action: (context) => {
const view = context.view;
// 设置鼠标样式
view.getCanvas().setCursor('default');
const tagArrow = context.event.gEvent.shape;
if (tagArrow.get('name') === 'conversion-tag-arrow') {
tagArrow.attr('fill', '#efefef');
}
},
},
],
});

const plotData = [
{ action: '浏览网站', pv: 50000, href: 'https://github.com/antvis/g2plot' },
{ action: '放入购物车', pv: 35000 },
{ action: '生成订单', pv: 25000, href: 'https://github.com/antvis/g2' },
{ action: '支付订单', pv: 15000 },
{ action: '完成交易', pv: 8500 },
];

const plot = new Bar('container', {
data: plotData,
xField: 'pv',
yField: 'action',
conversionTag: {
offset: 0,
spacing: 8,
arrow: {
style: {
fill: '#efefef',
},
},
},
interactions: [{ type: 'active-region', enable: false }, { type: 'conversion-tag-active' }],
});

plot.render();
18 changes: 18 additions & 0 deletions examples/case/advanced/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/tHF3bgalmB/association-filter.gif"
},
{
"filename": "conversion-analysis-bar.ts",
"title": {
"zh": "带跳转转化分析图",
"en": "Conversion analysis bar"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/p8r96Xc9o0/conversion-analysis-bar.gif"
},
{
"filename": "conversion-analysis.ts",
"title": {
"zh": "带跳转转化分析图2",
"en": "Conversion analysis bar2"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/PojoRGFBN4/conversion-analysis-2.gif"
}
]
}
8 changes: 0 additions & 8 deletions examples/dynamic-plots/brush/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"zh": "散点图刷选高亮",
"en": "Brush highlight of scatter"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/BlpX0yZrRH/brush-highlight.gif"
},
{
Expand All @@ -19,7 +18,6 @@
"zh": "散点图刷选",
"en": "Brush of scatter"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/x6%24CDJpPny/brush-x.gif"
},
{
Expand All @@ -28,7 +26,6 @@
"zh": "柱状图刷选高亮",
"en": "Brush highlight of column"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/svUh77%263iZ/column-brush-highlight.gif"
},
{
Expand All @@ -37,7 +34,6 @@
"zh": "柱状图 y 方向刷选",
"en": "Brush on y position of column"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/Rf1WzUaySB/column-brush-y.gif"
},
{
Expand All @@ -46,7 +42,6 @@
"zh": "柱状图 y 方向刷选高亮",
"en": "Brush highlight on y position of column"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/cKc4Q6lOXQ/y-brush-column.gif"
},
{
Expand All @@ -55,7 +50,6 @@
"zh": "条形图刷选高亮",
"en": "Brush highlight of bar"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/hksereLMdK/bar-brush-highlight.gif"
},
{
Expand All @@ -64,7 +58,6 @@
"zh": "刷选高级用法1",
"en": "Advanced usage1 of brush"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/OLOyP6XI0e/brush-advanced-usage1.gif"
},
{
Expand All @@ -73,7 +66,6 @@
"zh": "刷选高级用法2",
"en": "Advanced usage2 of brush"
},
"new": true,
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/2wHu3BD2s%26/brush-advanced-usage.gif"
}
]
Expand Down

0 comments on commit df6a984

Please sign in to comment.