5

I am trying to position my pie chart and move it a bit to the right from where it has originally rendered. I only want to move the chart and not the legend. Is there a way I can do that?

I went through the documentation and couldn't find anything. The grid doesn't work as well.

Considering this example:

Pie Doughnut on ECharts

How would I move the chart to the right while keeping the legend where it is?

Trevor Reid
  • 3,310
  • 4
  • 27
  • 46
Vinil Vasani
  • 123
  • 3
  • 9

3 Answers3

2

Even better, you can use grid

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

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

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
1

In the options series set the center:

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

The full code with it shifted from the url you posted:

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%']
        }
    ]
};
TaylorSanchez
  • 463
  • 1
  • 5
  • 8
0

center: ['40','70'] the first property will be horizontal and second will be vertical