Angular2-Highcharts: Pie chart size based on the width of the panel

久未见 提交于 2019-12-02 10:50:01

问题


I have created a Pie chart and I am placing this Pie chart inside a panel. My panel width can be 600 or 400 depending on the user settings. When the size is 600 Pie and the legend is displayed properly. But when it is 400, the legend is displayed outside of the panel. Is there a way to reduce the size of the pie in that case, also the legend can be displayed at the bottom if the size is not sufficient.

My plnkr

https://plnkr.co/edit/yzXLz7AIDoWa1Pzxxl4k?p=preview

My plot options

 plotOptions: {
                pie: {

                    innerSize: 120,
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: false
                    },
                    showInLegend: true,
                    states: {
                      hover: {
                        halo: {
                          size: 0
                        }
                      }
                    }
                }
            },

Response code:

responsive: {

                    rules: [{
                            condition: {
                                maxWidth: 500
                            },
                            chartOptions: {
                                legend: {
                                    align: 'center',
                                    verticalAlign: 'top',
                                    layout: 'horizontal',
                                    labelFormatter: function () {
                                       return '<div style="width:180px"><span class="pull-left" style= "font-weight: 500; padding-bottom: 5px; font-family:Helvetica ">' + this.name +
                '</span><span class="pull-right" style= "font-weight: 500" >' + this.value +
                '</span></div> ';
                                    }
                                },
                                pie: {
                                    size: 100,
                                    innerSize: 40
                                }
                            }
                        }]
                }

来源:https://stackoverflow.com/questions/43595600/angular2-highcharts-pie-chart-size-based-on-the-width-of-the-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!