简体   繁体   English

如何减少饼图和图例之间的空间? (highcharts.js)

[英]How do you reduce the space between pie chart and legend? (highcharts.js)

Please see below example that comes from highchart official documents. 请参阅以下来自highchart官方文件的示例。 There is still some space between legend and chart. 图例和图表之间仍然存在一些空间。 I want to make the chart as large as possible, but not overlap the legend. 我想使图表尽可能大,但不要与图例重叠。

The data of my chart is dynamic. 我的图表数据是动态的。 The number of legend items is variable. 图例项目的数量是可变的。 Therefore I cannot use a fixed marginBottom/ marginTop, eg 因此,我不能使用固定的marginBottom / marginTop,例如

chart: {
   marginBottom: 50, // does not work for me, as the number of legend items is varied.
   marginTop: -10
}

http://jsfiddle.net/8z6mqd6d/ http://jsfiddle.net/8z6mqd6d/

在此处输入图片说明

You can remove the padding and margin on the legend to get back some space. 您可以删除图例上的填充和边距,以腾出一些空间。

        legend : {
            margin: 0,
          padding: 0
        },

Depending on how close you want to get it, you can make margin a negative number if you need to. 根据所需的接近程度,可以根据需要将保证金设置为负数。

http://jsfiddle.net/8z6mqd6d/1/ http://jsfiddle.net/8z6mqd6d/1/

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

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