Highcharts - 当标签文本很长时如何执行响应式饼图

时间:2017-09-17 19:00:50

标签: highcharts

我需要做一个响应式饼图,在绿色区域进行深入分析。标签的文字太长,所以在移动设备中它看起来像这样: enter image description here

正如您所看到的那样,文本已被删除。 如何使这些文本完全响应。请在下面找到代码。 TIA

Highcharts.chart('recoveryGraf', {
    chart: {
        type: 'pie'
    },
    title: {
        text: ''
    },
    plotOptions: {
        series: {
            dataLabels: {
                enabled: true,
                format: '{point.name}: {point.y:.1f}%'
            }
        }
    },

    tooltip: {
        headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
        pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
    },
    series: [{
        name: 'Brands',
        colorByPoint: true,
        colors: ['#005eb8','#56b6cc','#8bc540'],
        data: [{
            name: 'Potential for further recovery',
            y: 6,
            drilldown: null
        }, {
            name: 'Non-recoverable<br>(e.g. tissue,wallpaper,etc)',
            y: 22,
            drilldown: null
        }, {
            name: 'Recycled',
            y: 72,
            drilldown: 'Recycleds'
        }]
    }],
    drilldown: {
        series: [{
            name: 'Recycleds',
            id: 'Recycleds',
            colors: ['#57a133','#8bc540'],
            data: [
                ['Exported', 16],
                ['Used Europe', 84]
            ]
        }]
    }
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<div id="recoveryGraf"></div>

1 个答案:

答案 0 :(得分:0)

...

responsive: {
  rules: [{
   condition: {
     maxWidth: 300
    },
   chartOptions: {
    plotOptions: {
     pie: {
      dataLabels: {
       enabled: false
       // add your costume code here
       }
     }
   }
  }
}]
}