如何显示像地图这样的传奇在Highcharts的线图中?

时间:2015-06-06 08:48:52

标签: highcharts

我使用的是Highcharts,

我希望有一个类似于地图的图例,而不是默认的折线图的图例,仅针对特定的行。

例如,使用此图例

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/maps/demo/color-axis/

        legend: {
            layout: 'horizontal',
            borderWidth: 0,
            backgroundColor: 'rgba(255,255,255,0.85)',
            floating: true,
            verticalAlign: 'top',
            y: 25
        },

而不是

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-basic/

    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'middle',
        borderWidth: 0
    },

在这个例子中,有东京"详细数字。

任何想法?

1 个答案:

答案 0 :(得分:0)

一般情况下,它不受支持,但您可以尝试将这些功能从地图添加到标准图表:http://jsfiddle.net/w9nuha8n/

(function (H) {
    // add colorAxis
    H.seriesTypes.line.prototype.axisTypes = ['xAxis', 'yAxis', 'colorAxis']; 
    H.seriesTypes.line.prototype.optionalAxis = 'colorAxis';

    // draw points and add setting colors
    H.wrap(H.seriesTypes.line.prototype, "translate", function (p) {
        p.call(this);
        H.seriesTypes.heatmap.prototype.translateColors.call(this);
    });

    // copy method from heatmap for color mixin
    H.seriesTypes.line.prototype.translateColors = H.seriesTypes.heatmap.prototype.translateColors; 

    // use "y" to calculate color
    H.seriesTypes.line.prototype.colorKey = 'y';
})(Highcharts);