-
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 #9182 Graph label.rotate is invalid #9210
Conversation
Duplicate of #9182 |
src/chart/graph/GraphView.js
Outdated
@@ -200,6 +200,7 @@ export default echarts.extendChartView({ | |||
&& seriesModel.get('circular.rotateLabel'); | |||
var cx = data.getLayout('cx'); | |||
var cy = data.getLayout('cy'); | |||
var labelRotate = seriesModel.get('label.rotate') === undefined ? 0 : seriesModel.get('label.rotate'); |
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 use == undefined
to check undefined
so that null
will also match the comparing.
Here, you'd better use var labelRotate = seriesModel.get('label.rotate') || 0
for simplification.
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.
@Ovilia ok, the code has been optimized.
var option = {
title: {
text: 'Graph 简单示例'
},
tooltip: {},
animationDurationUpdate: 1500,
animationEasingUpdate: 'quinticInOut',
series : [
{
type: 'graph',
layout: 'none',
symbolSize: 50,
roam: true,
label: {
show: true,
rotate: 30,
fontWeight:5,
fontSize: 26,
color: "#000",
distance: 15,
position: 'inside',
verticalAlign: 'middle'
},
edgeSymbol: ['circle', 'arrow'],
edgeSymbolSize: [4, 10],
edgeLabel: {
normal: {
textStyle: {
fontSize: 20
}
}
},
data: [{
name: 'rotate 30',
x: 300,
y: 300
}, {
name: 'rotate -30',
x: 500,
y: 600,
label: {
rotate: -30
}
}],
emphasis: {
label: {
rotate: 45
}
}
}
]
} |
@Ovilia I have a question.If you exist at the same time, do you take |
@Ovilia ,It's already commit. You can try it. |
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.
Very close now!
src/chart/graph/GraphView.js
Outdated
@@ -202,6 +202,8 @@ export default echarts.extendChartView({ | |||
var cy = data.getLayout('cy'); | |||
var labelRotate = seriesModel.get('label.rotate') || 0; | |||
data.eachItemGraphicEl(function (el, idx) { | |||
var itemModel = data.getItemModel(idx); | |||
labelRotate = itemModel.get('label.rotate') || labelRotate; |
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.
If itemModel.get('label.rotate')
is set to be 0
, it will use labelRotate
. But in fact, we wish it to be 0
.
It should be something like
var itemRotate = itemModel.get('label.rotate');
if (itemRotate != undefined) {
labelRotate = itemRotate;
}
@Ovilia Already commit again.😄 |
@100pah please review this PR. |
src/chart/graph/GraphView.js
Outdated
data.eachItemGraphicEl(function (el, idx) { | ||
var itemRotate = itemModel.get('label.rotate'); | ||
if (itemRotate != 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.
By convention, some != null
is recommended. (not a big deal, just probably because that null can not be redefined)
@100pah you can check it again.thanks |
Checked, thanks @cuijian-dexter ! |
@100pah Thanks |
when
series[i].type
isgraph
, series[i].label.rotate is invalid