繁体   English   中英

有没有办法在画布上单独定位图表和 echarts 中的图例?

[英]Is there is way to position the chart on the canvas and the legend individually in echarts?

我正在尝试定位我的饼图并将其从最初呈现的位置向右移动一点。 我只想移动图表而不是图例。 有没有办法做到这一点?

我浏览了文档,找不到任何东西。 网格也不能正常工作。

考虑这个例子:

ECharts 上的 Pie Donut

我如何将图表向右移动,同时将图例保持在原处?

在选项系列中设置中心:

center: ['75%', '50%']

它的完整代码从您发布的网址转移:

app.title = '环形图';

option = {
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b}: {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'left',
        data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']
    },
    series: [
        {
            name:'访问来源',
            type:'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontSize: '30',
                        fontWeight: 'bold'
                    }
                }
            },
            labelLine: {
                normal: {
                    show: false
                }
            },
            data:[
                {value:335, name:'直接访问'},
                {value:310, name:'邮件营销'},
                {value:234, name:'联盟广告'},
                {value:135, name:'视频广告'},
                {value:1548, name:'搜索引擎'}
            ],
            center: ['60%', '50%']
        }
    ]
};

更好的是,您可以使用grid

grid: {
  width: '50%',
  height:'50%',
  left: '3%',
  right: '4%',
  bottom: '3%',
  containLabel: true
},

https://echarts.apache.org/en/option.html#grid.width

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM