-
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.
* fix(funnel): 漏斗图转化率文本位置获取修改 * fix(funnel): 对比漏斗图更改 Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
- Loading branch information
1 parent
bb26fd5
commit 4e28638
Showing
9 changed files
with
174 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { get, map, filter, each } from '@antv/util'; | ||
import { Action } from '@antv/g2'; | ||
import { conversionTag as basicConversionTag } from '../geometries/basic'; | ||
import { compareConversionTag } from '../geometries/compare'; | ||
import { transformData, CONVERSION_TAG_NAME } from '../geometries/common'; | ||
import { FunnelOptions } from '../types'; | ||
|
||
/** | ||
* Funnel 转化率跟随 legend 变化事件 | ||
*/ | ||
export class ConversionTagAction extends Action { | ||
private rendering = false; | ||
public change(options: FunnelOptions) { | ||
// 防止多次重复渲染 | ||
if (!this.rendering) { | ||
const { seriesField, compareField } = options; | ||
const conversionTag = compareField ? compareConversionTag : basicConversionTag; | ||
const { view } = this.context; | ||
// 兼容分面漏斗图 | ||
const views = seriesField || compareField ? view.views : [view]; | ||
map(views, (v, index) => { | ||
// 防止影响其他 annotations 被去除 | ||
const annotationController = v.getController('annotation'); | ||
|
||
const annotations = filter( | ||
get(annotationController, ['option'], []), | ||
({ name }) => name !== CONVERSION_TAG_NAME | ||
); | ||
|
||
annotationController.clear(true); | ||
|
||
each(annotations, (annotation) => { | ||
if (typeof annotation === 'object') { | ||
v.annotation()[annotation.type](annotation); | ||
} | ||
}); | ||
|
||
const data = get(v, ['filteredData'], v.getOptions().data); | ||
|
||
conversionTag({ | ||
chart: v, | ||
index, | ||
options: { | ||
...options, | ||
// @ts-ignore | ||
filteredData: transformData(data, data, options), | ||
}, | ||
}); | ||
|
||
v.filterData(data); | ||
this.rendering = true; | ||
v.render(true); | ||
}); | ||
} | ||
this.rendering = false; | ||
} | ||
} |
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,11 @@ | ||
import { registerAction, registerInteraction } from '@antv/g2'; | ||
import { ConversionTagAction } from './funnel-conversion-tag'; | ||
|
||
const FUNNEL_CONVERSION_TAG = 'funnel-conversion-tag'; | ||
export const FUNNEL_LEGEND_FILTER = 'funnel-afterrender'; | ||
export const interactionStart = { trigger: 'afterrender', action: `${FUNNEL_CONVERSION_TAG}:change` }; | ||
|
||
registerAction(FUNNEL_CONVERSION_TAG, ConversionTagAction); | ||
registerInteraction(FUNNEL_LEGEND_FILTER, { | ||
start: [interactionStart], | ||
}); |
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