2017-10-05 18 views
0

我可以从右图边界不缩进传奇正确Highchart馅饼垂直传奇右对齐不固定绘制正确

我的配置

Highcharts.chart('container', { 
        chart: { 
         type: 'pie', 
         plotBackgroundColor: null, 
         plotBorderWidth: 1, 
         plotShadow: false, 

        }, 
        plotOptions: { 
         pie: { 
          dataLabels: { 
           enabled: false 
          }, 
          showInLegend: true, 
          center: [150, 150], 
         }, 
         column: { 
          stacking: 'percent' 
         } 
        }, 
        tooltip: { 
         pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.percentage:.2f}%)<br/>', 
         shared: true 
        }, 

       series: [{ 

        name: "My plot", 
        type: 'pie', 
        innerSize: '70%', 
        data: [ ['item',4],['item2',50],['item3',8]] 

       }], 
       title: { 
        text: "My chart" 
       }, 
       legend: { 
        layout: 'vertical', 
        align: 'right', 
        verticalAlign: 'middle', 
        borderWidth:1, 

       }, 
}); 

http://jsfiddle.net/69d1d22x/

我猜想我需要对齐传奇左,它右移,但余did't发现任何黑客。

回答

0

您可以使用chart.marginRight给右边距的情节。使用此代码来定位传说旁边(这里的假设是,legend.align等于'right'):

function alignLegend(chart) { 
    var group = chart.legend.group; 
    group.attr({ 
    translateX: chart.plotLeft + chart.plotWidth + chart.plotBox.x 
    }); 
} 

将这个功能loadredraw事件。

现场工作示例:http://jsfiddle.net/kkulig/cthaLrb3/

API参考:

+0

感谢ü@KamilKulig!这工作。此外,我已经尝试了这个角1.4.9和hicharts-ng。只需要在与配置相同的范围内定义函数,例如在控制器中 – hunty