将高图图例放在图表的底部并水平居中

时间:2015-06-30 10:38:11

标签: javascript jquery highcharts

我在我的网站上使用highchart需要图表并且它呈现良好(完全没问题)但是,由于冲突要求,我希望图例放在底部(图表下方,移动)它从右侧到底侧)并使其水平居中,任何人都知道如何制作它?我试过这个(参见下文)

legend: {
    enabled: true,
    floating: true,
    verticalAlign: 'bottom',
    align:'right',
    y:40
},

我的整体图表代码是

$('#chart_portfolio').highcharts({
                        chart: {
                        borderColor: '#ff0000',
                        width: null,
                        height: null
                        },
                        title: {
                            text: false,
                            x: -20 //center
                        },
                        legend: {
                            enabled: true,
                            floating: true,
                            verticalAlign: 'bottom',
                            align:'center'       
                        },
                        xAxis: {
                            categories: portfolio_creation_date //this is an array
                        },
                        yAxis: {
                            title: {
                                text: false
                            },
                            plotLines: [{
                                value: 0,
                                width: 1,
                                color: '#ff0000'
                            }]
                        },
                        tooltip: {
                                shared: true,
                                crosshairs: true
                            },

                        series: [{
                            name: 'Future',
                            data: portfolio_future, //this is an array
                            color: '#0f00ff'
                        }, {
                            name: 'In Grace Period',
                            data: portfolio_ingrace_period, //this is an array
                            color: '#fda800'
                        }, {
                            name: 'Arrears',
                            data: portfolio_in_arrears, //this is an array
                            color: '#f40404'
                        }, {
                            name: 'Good standing',
                            data: portfolio_good_standing, //this is an array
                            color: '#4da74d'
                        }]
                    }); //end of highcharts

但遗憾的是没有工作。请参考下图,了解详细信息。

refer to the image

2 个答案:

答案 0 :(得分:2)

只需删除选项,即可使用默认选项:http://jsfiddle.net/ctfcnsrL/1/

                    legend: {
                        // enabled: true,
                        // floating: true,
                        // verticalAlign: 'bottom',
                        // align:'center'       
                    },

答案 1 :(得分:0)

试试这个

legend: {
            enabled: true,
            floating: true,
            verticalAlign: 'bottom',
            align:'center',           
        },

http://jsfiddle.net/ctfcnsrL/