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

fix(ssr): hovering legend items should not trigger tooltip #19549

Merged
merged 2 commits into from
Jan 30, 2024
Merged
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
28 changes: 16 additions & 12 deletions src/component/legend/LegendView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,14 @@ class LegendView extends ComponentView {
.on('mouseover', curry(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId))
.on('mouseout', curry(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId));

itemGroup.eachChild(child => {
const ecData = getECData(child);
ecData.seriesIndex = seriesModel.seriesIndex;
ecData.dataIndex = dataIndex;
ecData.ssrType = 'legend';
});
if (ecModel.ssr) {
plainheart marked this conversation as resolved.
Show resolved Hide resolved
itemGroup.eachChild(child => {
const ecData = getECData(child);
ecData.seriesIndex = seriesModel.seriesIndex;
ecData.dataIndex = dataIndex;
ecData.ssrType = 'legend';
});
}

legendDrawnMap.set(name, true);
}
Expand Down Expand Up @@ -277,12 +279,14 @@ class LegendView extends ComponentView {
.on('mouseover', curry(dispatchHighlightAction, null, name, api, excludeSeriesId))
.on('mouseout', curry(dispatchDownplayAction, null, name, api, excludeSeriesId));

itemGroup.eachChild(child => {
const ecData = getECData(child);
ecData.seriesIndex = seriesModel.seriesIndex;
ecData.dataIndex = dataIndex;
ecData.ssrType = 'legend';
});
if (ecModel.ssr) {
itemGroup.eachChild(child => {
const ecData = getECData(child);
ecData.seriesIndex = seriesModel.seriesIndex;
ecData.dataIndex = dataIndex;
ecData.ssrType = 'legend';
});
}

legendDrawnMap.set(name, true);
}
Expand Down
5 changes: 5 additions & 0 deletions src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,11 @@ class TooltipView extends ComponentView {
this._showAxisTooltip(dataByCoordSys, e);
}
else if (el) {
const ecData = getECData(el);
if (ecData.ssrType === 'legend') {
// Don't trigger tooltip for legend tooltip item
return;
}
this._lastDataByCoordSys = null;

let seriesDispatcher: Element;
Expand Down
26 changes: 14 additions & 12 deletions src/core/echarts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,20 @@ class ECharts extends Eventful<ECEventDefinition> {

}

zrender.registerSSRDataGetter(el => {
const ecData = getECData(el);
const dataIndex = ecData.dataIndex;
if (dataIndex == null) {
return;
}
const hashMap = createHashMap();
hashMap.set('series_index', ecData.seriesIndex);
hashMap.set('data_index', dataIndex);
ecData.ssrType && hashMap.set('ssr_type', ecData.ssrType);
return hashMap;
});
if (opts.ssr) {
zrender.registerSSRDataGetter(el => {
const ecData = getECData(el);
const dataIndex = ecData.dataIndex;
if (dataIndex == null) {
return;
}
const hashMap = createHashMap();
hashMap.set('series_index', ecData.seriesIndex);
hashMap.set('data_index', dataIndex);
ecData.ssrType && hashMap.set('ssr_type', ecData.ssrType);
return hashMap;
});
}

const zr = this._zr = zrender.init(dom, {
renderer: opts.renderer || defaultRenderer,
Expand Down
Loading