echarts icon indicating copy to clipboard operation
echarts copied to clipboard

关系图label显示错误

Open nighthun opened this issue 10 years ago • 1 comments

问题简述 (One-line summary)

关系图设置显示label时,如果设置了字体样式,则显示2个标签

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version):3.1.7
  • 浏览器类型和版本 (Browser version):chrome50
  • 操作系统类型和版本 (OS Version):window 10

重现步骤 (Steps to reproduce)

1.设置显示标签,不设置标签字体样式,效果如图1 2.设置标签的字体样式,标签显示为2个。

期望结果 (Expected behaviour)

设置标签的字体样式,标签显示正常

可能哪里有问题 (What went wrong)

ECharts配置项 (ECharts option)

http://echarts.baidu.com/demo.html#graph 里面的内容,稍微修改了下,更容易看懂

//显示正常的options如下:
myChart.showLoading();
$.get('data/asset/data/les-miserables.gexf', function (xml) {
    myChart.hideLoading();

    var graph = echarts.dataTool.gexf.parse(xml);
    var categories = [];
    for (var i = 0; i < 9; i++) {
        categories[i] = {
            name: '类目' + i
        };
    }

    option = {
        title: {
            text: 'Les Miserables',
            subtext: 'Default layout',
            top: 'bottom',
            left: 'right'
        },
        tooltip: {},
        legend: [{
            // selectedMode: 'single',
            data: categories.map(function (a) {
                return a.name;
            })
        }],
        animationDuration: 1500,
        animationEasingUpdate: 'quinticInOut',
        series : [
            {
                name: 'Les Miserables',
                type: 'graph',
                layout: 'none',
                data: graph.nodes.splice(0,3),
                links: graph.links.splice(0,3),
                categories: categories.splice(0,3),
                roam: true,
                label: {
                    normal: {
                        position: 'right',
                        formatter: '{b}',
                        show:true
                    }
                },
                lineStyle: {
                    normal: {
                        curveness: 0.3
                    }
                }
            }
        ]
    };
    myChart.setOption(option);
}, 'xml');


//显示有错误时options如下:
myChart.showLoading();
$.get('data/asset/data/les-miserables.gexf', function (xml) {
    myChart.hideLoading();

    var graph = echarts.dataTool.gexf.parse(xml);
    var categories = [];
    for (var i = 0; i < 9; i++) {
        categories[i] = {
            name: '类目' + i
        };
    }

    option = {
        title: {
            text: 'Les Miserables',
            subtext: 'Default layout',
            top: 'bottom',
            left: 'right'
        },
        tooltip: {},
        legend: [{
            // selectedMode: 'single',
            data: categories.map(function (a) {
                return a.name;
            })
        }],
        animationDuration: 1500,
        animationEasingUpdate: 'quinticInOut',
        series : [
            {
                name: 'Les Miserables',
                type: 'graph',
                layout: 'none',
                data: graph.nodes.splice(0,3),
                links: graph.links.splice(0,3),
                categories: categories.splice(0,3),
                roam: true,
                label: {
                    normal: {
                        position: 'right',
                        formatter: '{b}',
                        show:true,
                        textStyle: {
                            "color": "#ff0000",
                            "fontSize": "12px",
                            "fontWeight": "normal"
                        }
                    }
                },
                lineStyle: {
                    normal: {
                        curveness: 0.3
                    }
                }
            }
        ]
    };
debugger;
    myChart.setOption(option);
}, 'xml');

其他信息 (Other comments)

正确的 image

错误的: image

nighthun avatar May 06 '16 06:05 nighthun

谢谢反馈,下周发布的 3.1.8 对 graph 会有诸多的优化,包括节点标签和边的标签,也不存在这个问题了:)

pissang avatar May 06 '16 07:05 pissang