Skip to content

Commit

Permalink
Merge pull request #17510 from caiwukun/fix_legend_name_duplicate_rem…
Browse files Browse the repository at this point in the history
…oval

fix: legend inverse bug
  • Loading branch information
Ovilia authored Sep 22, 2022
2 parents f51f1fe + 46cdb2b commit 56a989b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/component/legend/LegendModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,21 +354,27 @@ class LegendModel<Ops extends LegendOption = LegendOption> extends ComponentMode
// which is convinient for user preparing option.
const rawData = this.get('data') || potentialData;

const legendNameMap = zrUtil.createHashMap();
const legendData = zrUtil.map(rawData, function (dataItem) {
// Can be string or number
if (zrUtil.isString(dataItem) || zrUtil.isNumber(dataItem)) {
dataItem = {
name: dataItem as string
};
}
if (legendNameMap.get(dataItem.name)) {
// remove legend name duplicate
return null;
}
legendNameMap.set(dataItem.name, true);
return new Model(dataItem, this, this.ecModel);
}, this);

/**
* @type {Array.<module:echarts/model/Model>}
* @private
*/
this._data = legendData;
this._data = zrUtil.filter(legendData, item => !!item);
}

getData() {
Expand Down

0 comments on commit 56a989b

Please sign in to comment.