Skip to content

Commit

Permalink
Merge pull request #16315 from apache/feat/axis-label-tooltip
Browse files Browse the repository at this point in the history
feat(axis): support tooltip for axis label
  • Loading branch information
plainheart authored Nov 24, 2024
2 parents 9d8454a + 15a8f64 commit 8924cb5
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 11 deletions.
11 changes: 5 additions & 6 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"dependencies": {
"tslib": "2.3.0",
"zrender": "5.6.0"
"zrender": "github:ecomfe/zrender"
},
"devDependencies": {
"@babel/code-frame": "7.10.4",
Expand Down
12 changes: 11 additions & 1 deletion src/component/axis/AxisBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {shouldShowAllLabels} from '../../coord/axisHelper';
import { AxisBaseModel } from '../../coord/AxisBaseModel';
import { ZRTextVerticalAlign, ZRTextAlign, ECElement, ColorString } from '../../util/types';
import { AxisBaseOption } from '../../coord/axisCommonTypes';
import Element from 'zrender/src/Element';
import type Element from 'zrender/src/Element';
import { PathStyleProps } from 'zrender/src/graphic/Path';
import OrdinalScale from '../../scale/Ordinal';
import { prepareLayoutList, hideOverlap } from '../../label/labelLayoutHelper';
Expand Down Expand Up @@ -836,6 +836,16 @@ function buildAxisLabel(
});
textEl.anid = 'label_' + tickValue;

graphic.setTooltipConfig({
el: textEl,
componentModel: axisModel,
itemName: formattedLabel,
formatterParamsExtra: {
isTruncated: () => textEl.isTruncated,
value: rawLabel,
tickIndex: index
}
});

// Pack data for mouse event
if (triggerEvent) {
Expand Down
63 changes: 60 additions & 3 deletions test/axisLabel.html

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

0 comments on commit 8924cb5

Please sign in to comment.