简体   繁体   中英

Highcharts legend custom css style / format using only highcharts options

I've tried lots of combinations in the legend options of the highcharts object, however I was not able to successfully realize the exact design that the designer made.

What I need is to be able to have a legend that looks exactly like this... Wanted legend layout

But the closest result that I achieved with the legend options available was this... The closest legend layout I could achieve

The properties I used within the highchart object definition were:

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

Thank you in advance for any help.

Maybe you can use this as a starting point.

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'            
        }]
    });
});​

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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