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 #8009 & #5969, symbol symbolSize and opacity setting for category itemStyle in graph #9171

Merged
merged 13 commits into from
Nov 4, 2018
27 changes: 20 additions & 7 deletions src/chart/graph/categoryVisual.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ export default function (ecModel) {
var name = categoriesData.getName(idx);
// Add prefix to avoid conflict with Object.prototype.
categoryNameIdxMap['ec-' + name] = idx;

var itemModel = categoriesData.getItemModel(idx);

var color = itemModel.get('itemStyle.color')
|| seriesModel.getColorFromPalette(name, paletteScope);
categoriesData.setItemVisual(idx, 'color', color);

var itemStyleList = ['opacity', 'symbol', 'symbolSize', 'symbolKeepAspect'];
for (var i = 0; i < itemStyleList.length; i++) {
var itemStyle = itemModel.getShallow(itemStyleList[i], true);
if (itemStyle != null) {
categoriesData.setItemVisual(idx, itemStyleList[i], itemStyle);
}
}
});

// Assign category color to visual
Expand All @@ -47,14 +55,19 @@ export default function (ecModel) {
if (typeof category === 'string') {
category = categoryNameIdxMap['ec-' + category];
}
if (!data.getItemVisual(idx, 'color', true)) {
data.setItemVisual(
idx, 'color',
categoriesData.getItemVisual(category, 'color')
);

var itemStyleList = ['color', 'opacity', 'symbol', 'symbolSize', 'symbolKeepAspect'];

for (var i = 0; i < itemStyleList.length; i++) {
if (data.getItemVisual(idx, itemStyleList[i], true) == null) {
data.setItemVisual(
idx, itemStyleList[i],
categoriesData.getItemVisual(category, itemStyleList[i])
);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

After we have done all of this, there is another work need to do:

properties like color, opacity, symbolSize have been saved to data by data.setItemVisual,
but only color is retrieved from data (by data.getItemVisual(...)) and be used to render in GraphView.js.
We need to make opacity and symbolSize follow the same way, and then the entire patch can work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ummm, I am confused about this. Where is color retrieved?
The opacity and symbolSize also work currently...What's wrong? O.O

Copy link
Member

@100pah 100pah Nov 4, 2018

Choose a reason for hiding this comment

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

color, opacity, symbolSize are retrieved in src/chart/helper/Symbol.js (search 'getItemVisual' in this file). The src/chart/helper/Symbol.js, used by GraphView.js, is a common module abstracting the drawing and other behaviors of each node of the graph.

}
});
}
});
}
}