Highchart Legend into another Element (div)

荒凉一梦 提交于 2020-01-03 08:49:10

问题


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')

})


回答1:


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


来源:https://stackoverflow.com/questions/19000546/highchart-legend-into-another-element-div

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