Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import { normalizeTooltipFormatResult } from '../../model/mixin/dataFormat';
import { createTooltipMarkup, buildTooltipMarkup, TooltipMarkupStyleCreator } from './tooltipMarkup';
import { findEventDispatcher } from '../../util/event';
import { clear, createOrUpdate } from '../../util/throttle';
import { getElementState } from '../../util/states';

const proxyRect = new Rect({
shape: { x: -1, y: -1, width: 2, height: 2 }
Expand Down Expand Up @@ -582,6 +583,11 @@ class TooltipView extends ComponentView {
axisModel.axis, { value: axisValue as number }
);
cbParams.axisValueLabel = axisValueLabel;
const data = series.getData();
const el = data.getItemGraphicEl(dataIndex);
if (el) {
cbParams.status = getElementState(el);
}
// Pre-create marker style for makers. Users can assemble richText
// text in `formatter` callback and use those markers style.
cbParams.marker = markupStyleCreator.makeTooltipMarker(
Expand Down
13 changes: 13 additions & 0 deletions src/util/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ export function setStatesFlag(el: ECElement, stateName: DisplayState) {
}
}

export function getElementState(el: ECElement): DisplayState {
if (el.selected) {
return 'select';
}
else if (el.hoverState === 1) {
return 'blur';
}
else if (el.hoverState === 2) {
return 'emphasis';
}
return 'normal';
}

/**
* If we reuse elements when rerender.
* DON'T forget to clearStates before we update the style and shape.
Expand Down
40 changes: 40 additions & 0 deletions test/tooltip.html

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