Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highchart Legend into another Element (div)

i need another Highchart Legend which i want to style with css/html. I found a topic with this topic but I can't get it to work and the jsFiddle Link isn't working anymore...

Can someone help me to get this working? Please

Here is my jsfiddle Link http://jsfiddle.net/chogger/j3xvg

This is what I found:

$(chart.series).each(function(i, serie){
$('<li style="color: '+serie.color+'">'+serie.name+'</li>').click(function(){
    serie.visible ? serie.hide() : serie.show();
}).appendTo('#legend')

})

like image 629
chogger Avatar asked Sep 25 '13 09:09

chogger


1 Answers

What exactly doesn't work for you? Are you using load event handler for this? See: http://jsfiddle.net/j3xvg/1/

chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container',
        defaultSeriesType: 'line',
        marginRight: 50,
        marginBottom: 175,
        events: {
            load: function () {
                var chart = this;
                $(chart.series).each(function (i, serie) {
                    $('<li style="color: ' + serie.color + '">' + serie.name + '</li>').click(function () {
                        serie.visible ? serie.hide() : serie.show();
                    }).appendTo('#legend');
                });
            }
        }
    },
});
like image 106
Paweł Fus Avatar answered Nov 15 '22 02:11

Paweł Fus