Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tooltip for axis label #20378

Closed
Changes from all 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
11 changes: 11 additions & 0 deletions src/component/axis/AxisBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { ZRTextVerticalAlign, ZRTextAlign, ECElement, ColorString } from '../../
import { AxisBaseOption } from '../../coord/axisCommonTypes';
import Element from 'zrender/src/Element';
import { PathStyleProps } from 'zrender/src/graphic/Path';
import type TSpan from 'zrender/src/graphic/TSpan';
import OrdinalScale from '../../scale/Ordinal';
import { prepareLayoutList, hideOverlap } from '../../label/labelLayoutHelper';

Expand Down Expand Up @@ -836,6 +837,16 @@ function buildAxisLabel(
});
textEl.anid = 'label_' + tickValue;

graphic.setTooltipConfig({
el: textEl,
componentModel: axisModel,
itemName: formattedLabel,
formatterParamsExtra: {
isEllipsised: () => formattedLabel !== (textEl.childrenRef()[0] as TSpan).style.text,
tickIndex: index
}
});


// Pack data for mouse event
if (triggerEvent) {
Expand Down
Loading