仅使用highcharts选项的Highcharts图例自定义css样式/格式

时间:2012-05-11 15:49:12

标签: javascript styles highcharts legend

我在highcharts对象的图例选项中尝试了很多组合,但是我无法成功实现设计师的精确设计。

我需要的是能够拥有一个看起来完全像这样的传奇...... Wanted legend layout

但是我用传奇选项获得的最接近的结果是...... The closest legend layout I could achieve

我在highchart对象定义中使用的属性是:

legend: {
    enabled: graphProperties.legend.enabled,
    backgroundColor: ...
    borderRadius: ...
    verticalAlign: ...
    align: ...
    borderWidth: ...
    x: ...
    y: ... }

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:6)

也许您可以将此作为起点。

http://jsfiddle.net/DqAqu/4/

$(function () {
    var chart = new Highcharts.Chart({

        chart: {
            renderTo: 'container', 
            backgroundColor: '#F5F5F5', 
            plotBackgroundColor: '#FFFFFF'
        },

        symbols: [ 'square', 'square' ], 

        legend: {
            backgroundColor: '#F5F5F5',
            layout: 'horizontal',
            floating: true,
            align: 'left',
            verticalAlign: 'top',
            x: 60,
            y: 1,
            shadow: false, 
            border: 0, 
            borderRadius: 0, 
            borderWidth: 0
        },

        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], 
            color: '#47D147'            
        }, {
            data: [95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1], 
            color: '#19A3FF'            
        }]
    });
});​