-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symbol
and symbolSize
is supported, but not symbolRotate
, symbolKeepAspect
, symbolOffset
.
Very close now. Keep trying! 😃
src/chart/graph/categoryVisual.js
Outdated
var color = itemModel.get('itemStyle.color') | ||
|| seriesModel.getColorFromPalette(name, paletteScope); | ||
categoriesData.setItemVisual(idx, 'color', color); | ||
var opacity = itemModel.get('itemStyle.opacity') | ||
|| 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line is no need here. ECharts project uses new line at 120 characters.
src/chart/graph/categoryVisual.js
Outdated
categoriesData.setItemVisual(idx, 'opacity', opacity); | ||
var itemSymbolType = itemModel.getShallow('symbol', true); | ||
var itemSymbolSize = itemModel.getShallow('symbolSize', | ||
true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line is no need here.
src/chart/graph/categoryVisual.js
Outdated
categoriesData.setItemVisual(idx, 'symbol', itemSymbolType); | ||
} | ||
if (itemSymbolSize != null) { | ||
// PENDING Transform symbolSize ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment.
I added a test case for this issue: 9ebb31a |
Completed, please check it again : ) |
src/chart/graph/categoryVisual.js
Outdated
@@ -88,6 +100,27 @@ export default function (ecModel) { | |||
); | |||
} | |||
|
|||
if (!data.getItemVisual(idx, 'symbolKeepAspect', true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a for-loop here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ummm, loop for what…?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
['symbol', 'symbolSize', ''symbolKeepAspect', ...]
, all similar logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done :-)
src/chart/graph/categoryVisual.js
Outdated
if (itemSymbolSize != null) { | ||
categoriesData.setItemVisual(idx, 'symbolSize', itemSymbolSize); | ||
} | ||
var symbolStyleList = ['symbol','symbolSize','symbolKeepAspect','symbolOffset','symbolRotate'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention your code style. Space after ,
and ;
at the end.
src/chart/graph/categoryVisual.js
Outdated
var itemSymbolOffset = itemModel.getShallow('symbolOffset',true); | ||
if (itemSymbolOffset != null) { | ||
categoriesData.setItemVisual(idx, 'symbolOffset', itemSymbolOffset); | ||
for(var i = 0;i < symbolStyleList.length;i++){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after ;
, for
, and )
. Please also check other places.
src/chart/graph/categoryVisual.js
Outdated
if (itemSymbolOffset != null) { | ||
categoriesData.setItemVisual(idx, 'symbolOffset', itemSymbolOffset); | ||
for(var i = 0;i < symbolStyleList.length;i++){ | ||
var symbolStyleItem = itemModel.getShallow(symbolStyleList[i], true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test graph-symbol.html
? It seems itemModel.getShallow('symbolOffset', true)
always return undefined, so that symbolOffset: ['30%', 0]
is config is not used. This doesn't seem right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both symbolOffset and other items return undefined, but somehow it works. I have checked that it can be consoled during the upper section.
for (var i = 0; i < symbolStyleList.length; i++) {
var symbolStyleItem = itemModel.getShallow(symbolStyleList[i], true);
if (symbolStyleItem != null) {
categoriesData.setItemVisual(idx, symbolStyleList[i], symbolStyleItem);
}
}
In my local server, changing the symbolOffset do bring some effects to the symbol. You could put the percentage larger to see that.
But I am not sure whether the position is right since it is not computed by my code...
Really really sorry for those mistakes I have made...
Here is a new version with formatted code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduct the latter symbolStyleList with symbolOffset and symbolRotate, it also works. Others need both two functions to do that.
In fact I don't know why...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we have to make sure we understand our changes. 🤣
I'll check it later. Thanks!
@100pah please verify this PR. |
It is a little complicated about this issue. Tow cases: (A)
(B) The "contract" is a little complicated and a little fuzzy. Why not just In this case, we have these properties to be considered: Probably we have to trade them in different way: (1) Follow to the contract (B) above: (2) Follow to the contract (A) above: (3) |
I have submited a new one, but still a little confused about the relationship between model and data. |
src/chart/graph/categoryVisual.js
Outdated
}); | ||
|
||
// Assign category color to visual | ||
if (categoriesData.count()) { | ||
data.each(function (idx) { | ||
var itemModel = categoriesData.getItemModel(idx); | ||
var symbol = itemModel.getShallow('symbol', true); | ||
if (symbol) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer do not support customizing symbol
in this case.
Because it's a little complicated.
Set symbol to "data item visual" does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it is what the issue for...
So I just leave it there...? o.o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault. setItemVisual('symbol', ...)
works...
idx, itemStyleList[i], | ||
categoriesData.getItemVisual(category, itemStyleList[i]) | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Both of them contains user settings in echarts option, for example: let option = {
series: {
name: 'asdf',
type: 'line',
itemStyle: { ... },
data: [ ... ]
}
}; The data properties is saved into a let data = model.getData(); |
src/chart/graph/categoryVisual.js
Outdated
var opacity = itemModel.get('itemStyle.opacity') || 1; | ||
categoriesData.setItemVisual(idx, 'opacity', opacity); | ||
var opacity = itemModel.get('opacity'); | ||
if (opacity != undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tiny issue, in most cases, xxx != null
is a little better than xxx != undefined
, although they have the same meaning. Probably because undefined
can be redefined in some environments but null
can not.
@Vvvickie Thanks for your contribution! 🌟🌟🌟🌟🌟 And are you interested in being an ECharts committer? This has more restrict rules than contributors. Committers are those who contribute more frequently and play more important roles on ECharts project. After being a committer: You can have write access to the ECharts code Subscribe our mailing list by send an email to dev-subscribe@echarts.apache.org And you will be invited to be a committer when we think your contribution and knowledge of ECharts project is enough. We are looking forward to this! 😃 |
Finished :)It seems you forget to attach the pdf. Anyway I find it somewhere else. |
fix Issue #8009 & #5969