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 #9182 Graph label.rotate is invalid #9210

Merged
merged 6 commits into from
Oct 23, 2018
Merged

Conversation

cuijian-dexter
Copy link
Contributor

@cuijian-dexter cuijian-dexter commented Oct 12, 2018

when series[i].type is graph, series[i].label.rotate is invalid

@cuijian-dexter
Copy link
Contributor Author

Duplicate of #9182

@cuijian-dexter cuijian-dexter changed the title Graph label.rotate is invalid fix #9182 Graph label.rotate is invalid Oct 12, 2018
@@ -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');
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@Ovilia
Copy link
Contributor

Ovilia commented Oct 15, 2018

data.label should also be supported. Test example:

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
                }
            }
        }
    ]
}

@cuijian-dexter
Copy link
Contributor Author

@Ovilia I have a question.If you exist at the same time, do you take data.label priority?

@cuijian-dexter
Copy link
Contributor Author

@Ovilia ,It's already commit. You can try it.

Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

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

Very close now!

@@ -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;
Copy link
Contributor

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;
}

@cuijian-dexter
Copy link
Contributor Author

@Ovilia Already commit again.😄

@Ovilia Ovilia requested a review from 100pah October 16, 2018 08:13
@Ovilia
Copy link
Contributor

Ovilia commented Oct 16, 2018

@100pah please review this PR.

src/chart/graph/GraphView.js Outdated Show resolved Hide resolved
data.eachItemGraphicEl(function (el, idx) {
var itemRotate = itemModel.get('label.rotate');
if (itemRotate != undefined) {
Copy link
Member

@100pah 100pah Oct 16, 2018

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)

src/chart/graph/GraphView.js Show resolved Hide resolved
@cuijian-dexter
Copy link
Contributor Author

@100pah you can check it again.thanks

@100pah
Copy link
Member

100pah commented Oct 23, 2018

Checked, thanks @cuijian-dexter !

@100pah 100pah merged commit ab0fdde into apache:master Oct 23, 2018
@cuijian-dexter
Copy link
Contributor Author

@100pah Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants