简体   繁体   English

Highcharts 饼图显示图例始终为浮动

[英]Highcharts Pie chart display legend always as floating

I work with hightcharts for a while and it is amazing library.我用 hightcharts 工作了一段时间,这是一个很棒的图书馆。 But I am stuck with legend in Pie chart.但我被饼图中的传说困住了。 Legend is always displaying like floating, but i need legend under pie.图例总是像浮动一样显示,但我需要饼图下的图例。

I got this:-/我懂了:-/

传说在飘

I want this:D我想要这个:D

底部图例

My definition is:我的定义是:

Highcharts.chart('container', {
  "chart": {
    "margin": 0,
    "type": "pie",
    "height": 300,
    "backgroundColor": "#FDFDFD",
    "width": 250
  },
  "legend": {
    "floating": false,
    "align": "center",
    "verticalAlign": "bottom",

  },
  "plotOptions": {
    "pie": {
      "dataLabels": {
        "enabled": false,
      },
      "size": "100%",
      "showInLegend": true,

    }
  },
  "title": false,
  "exporting": false,
  "series": [{
    "data": [1, 2, 3, 4, 3, 2, 1]
  }],
});

The problem is in margin .问题在于margin Set margin to null, or remove this line and it will be fixed.将边距设置为 null,或者删除此行将被修复。

Highcharts.chart('container', {
  "chart": {
    "margin": null,
  },...
});

Bonus tip: floating of legend is disabled by default, you can remove this line too.额外提示:默认情况下禁用图例浮动,您也可以删除此行。

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

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