Skip to content

Commit

Permalink
Merge pull request apache#12561 from plainheart/fix-12560
Browse files Browse the repository at this point in the history
fix(pie): pie series render incorrectly after editing its data in DataView. close apache#12560.
  • Loading branch information
pissang authored Aug 4, 2020
2 parents 23596ac + c03283e commit 0d471fa
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/component/toolbox/feature/DataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@ function parseListContents(str) {

var data = [];
for (var i = 0; i < lines.length; i++) {
var items = trim(lines[i]).split(itemSplitRegex);
// if line is empty, ignore it.
// there is a case that a user forgot to delete `\n`.
var line = trim(lines[i]);
if (!line) {
continue;
}
var items = line.split(itemSplitRegex);
var name = '';
var value;
var hasName = false;
Expand Down Expand Up @@ -427,13 +433,18 @@ function tryMergeDataOption(newData, originalData) {
return zrUtil.map(newData, function (newVal, idx) {
var original = originalData && originalData[idx];
if (zrUtil.isObject(original) && !zrUtil.isArray(original)) {
if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) {
newVal = newVal.value;
var newValIsObject = zrUtil.isObject(newVal) && !zrUtil.isArray(newVal);
if (!newValIsObject) {
newVal = {
value: newVal
};
}
// original data has name but new data has no name
var shouldDeleteName = original.name != null && newVal.name == null;
// Original data has option
return zrUtil.defaults({
value: newVal
}, original);
newVal = zrUtil.defaults(newVal, original);
shouldDeleteName && (delete newVal.name);
return newVal;
}
else {
return newVal;
Expand Down Expand Up @@ -473,4 +484,4 @@ echarts.registerAction({
}, payload.newOption));
});

export default DataView;
export default DataView;
122 changes: 122 additions & 0 deletions test/pie-dataView.html

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

0 comments on commit 0d471fa

Please sign in to comment.