Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/chart/custom/CustomSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export interface CustomBaseElementOption extends Partial<Pick<
textContent?: CustomTextOption | false;
// `false` means remove the clipPath
clipPath?: CustomBaseZRPathOption | false;
// `false` means not show tooltip
tooltipDisabled?: boolean;
// `extra` can be set in any el option for custom prop for annimation duration.
extra?: Dictionary<unknown> & TransitionOptionMixin;
// updateDuringAnimation
Expand Down
3 changes: 3 additions & 0 deletions src/chart/custom/CustomView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ function doCreateOrUpdateEl(
else if ((el as ECElement).disableMorphing) {
(el as ECElement).disableMorphing = false;
}
if (elOption.tooltipDisabled) {
(el as ECElement).tooltipDisabled = true;
}

attachedTxInfoTmp.normal.cfg = attachedTxInfoTmp.normal.conOpt =
attachedTxInfoTmp.emphasis.cfg = attachedTxInfoTmp.emphasis.conOpt =
Expand Down
17 changes: 15 additions & 2 deletions src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ class TooltipView extends ComponentView {
) {
const el = e.target;
const tooltipModel = this._tooltipModel;

if (!tooltipModel) {
return;
}
Expand All @@ -472,7 +471,21 @@ class TooltipView extends ComponentView {

let seriesDispatcher: Element;
let cmptDispatcher: Element;
findEventDispatcher(el, (target) => {
findEventDispatcher(el, function(target) {
// Check if el has any ancestor that has tooltipDisabled: true.
Comment thread
Ovilia marked this conversation as resolved.
Outdated
let tooltipDisabled = false;
let parent = el;
while (parent) {
if (parent.tooltipDisabled) {
tooltipDisabled = true;
break;
}
parent = parent.parent;
Comment thread
Ovilia marked this conversation as resolved.
Outdated
}
if (tooltipDisabled) {
return false;
}

// Always show item tooltip if mouse is on the element with dataIndex
if (getECData(target).dataIndex != null) {
seriesDispatcher = target;
Expand Down
4 changes: 4 additions & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export interface ECElement extends Element {
* Force disable morphing
*/
disableMorphing?: boolean
/**
* Force disable triggering tooltip
*/
tooltipDisabled?: boolean
}

export interface DataHost {
Expand Down
177 changes: 176 additions & 1 deletion test/custom-feature.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.