Skip to content

Commit

Permalink
Merge pull request #16187 from apache/fix-15798
Browse files Browse the repository at this point in the history
feat(event): provide label index in axis events
  • Loading branch information
Ovilia authored Feb 28, 2022
2 parents 95ad522 + 66c5c22 commit fdf5490
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/component/axis/AxisBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type AxisEventData = {
targetType: 'axisName' | 'axisLabel'
name?: string
value?: string | number
dataIndex?: number
tickIndex?: number
} & {
[key in AxisIndexKey]?: number
};
Expand Down Expand Up @@ -814,6 +816,10 @@ function buildAxisLabel(
const eventData = AxisBuilder.makeAxisEventDataBase(axisModel);
eventData.targetType = 'axisLabel';
eventData.value = rawLabel;
eventData.tickIndex = index;
if (axis.type === 'category') {
eventData.dataIndex = tickValue;
}

getECData(textEl).eventData = eventData;
}
Expand Down
13 changes: 7 additions & 6 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 fdf5490

Please sign in to comment.