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(legend): fix highlight state after inverseselect #11480 #11547

Merged
merged 1 commit into from
Nov 20, 2019
Merged
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
10 changes: 7 additions & 3 deletions src/component/legend/LegendView.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default echarts.extendComponentView({
selectMode
);

itemGroup.on('click', curry(dispatchSelectAction, name, api))
itemGroup.on('click', curry(dispatchSelectAction, name, null, api, excludeSeriesId))
.on('mouseover', curry(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId))
.on('mouseout', curry(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId));

Expand Down Expand Up @@ -238,7 +238,7 @@ export default echarts.extendComponentView({
);

// FIXME: consider different series has items with the same name.
itemGroup.on('click', curry(dispatchSelectAction, name, api))
itemGroup.on('click', curry(dispatchSelectAction, name, null, api, excludeSeriesId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name here is "item name", but in dispatchHighlightAction and dispatchDownplayAction the first parameter is seriesName.

Copy link
Contributor

@pissang pissang Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name here can be seriesName or itemName. It depends on series.

// Should not specify the series name, consider legend controls
// more than one pie series.
.on('mouseover', curry(dispatchHighlightAction, null, name, api, excludeSeriesId))
Expand Down Expand Up @@ -518,11 +518,15 @@ function setSymbolStyle(symbol, symbolType, legendModelItemStyle, borderColor, i
return symbol.setStyle(itemStyle);
}

function dispatchSelectAction(name, api) {
function dispatchSelectAction(name, dataName, api, excludeSeriesId) {
// downplay before unselect
dispatchDownplayAction(name, dataName, api, excludeSeriesId);
api.dispatchAction({
type: 'legendToggleSelect',
name: name
});
// highlight after select
dispatchHighlightAction(name, dataName, api, excludeSeriesId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This highlight action probably is not needed.
Otherwise if we call

chart.dispatchAction({
    type: 'legendToggleSelect',
    name: 'b'
});

manually, there are still unexpected highlight state.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also had concerns about this.
But after run the test case. It seems to be a resonable behaviour.

}

function dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId) {
Expand Down