-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: 增加 2 个转化分析漏斗图 demo, 带跳转 (#2807)
* docs: 增加一个转化分析漏斗图, 带跳转 * docs: 更新dingding * fix: 修复 lint 问题
- Loading branch information
Showing
9 changed files
with
176 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
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,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(); |
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,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(); |
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