将图例移出图表区域 C3.js

Move legend outside the chart area in C3.js

有没有办法将图例放在图表区域之外?我正在尝试使用 bindto 属性,但它不起作用 (plunker)

Here is the example for amcharts

C3 documentation中只允许几个位置:左上角 右上角左下角右下角

您或许可以使用以下方法解决此问题:

legend: {
   show: false
}

然后通过 C3 或 D3 添加自定义图例

有关工作示例,请参阅 http://c3js.org/samples/legend_custom.html

您总是可以自己重新设置它的父级:

setTimeout(function(){
  var legend = d3.selectAll('.c3-legend-item');
  var svg = d3.select('#legend')
    .append('svg')
    .attr('width', 640)
    .attr('height', 100);
  legend.each(function(){
    svg.node().appendChild(this);
  });
}, 100);

已更新 plunker