如何设置高阶图传奇风格?

时间:2014-12-18 17:34:51

标签: highcharts

我做了一个jsfiddle示例来演示这个。
http://jsfiddle.net/daxu/ttxvpduv/

    $(function () {
    $('#container').highcharts({

        legend: {
            enabled: true
        },

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

        series: [{
            name:'a',
            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]
        },
                {
            name:'b',
                    type:'area',
            data: [129.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
        }]
    });
}); 

在我的例子中,我有两个系列(一行,一个区域)。我们可以看到折线图的图例是一条线,图例区域更大(就像一个区域)。

有没有办法让所有传说成为一条线或某种风格?

非常感谢

2 个答案:

答案 0 :(得分:1)

这有点hacky(也许我最近一直在使用d3.js),但你可以动态修改SVG:

, function(chart){
    // remove the line and rect
    $('.highcharts-legend-item path, .highcharts-legend-item rect').remove();
    // add in your own elements
    $('.highcharts-legend-item').each(function(i, obj){
        var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
        $(circle).attr({"r":10,"fill":"red", "cy": 10});
        $(obj).append(circle);
    });
});

小提琴here

答案 1 :(得分:1)

现在解决了这个问题。

请参阅http://jsfiddle.net/ttxvpduv/2/

   Highcharts.seriesTypes.line.prototype.drawLegendSymbol = 
     Highcharts.seriesTypes.column.prototype.drawLegendSymbol;