Highchart极坐标图-4个不同系列的嵌套圆

时间:2019-06-11 10:55:59

标签: javascript highcharts

我面临极坐标图定制的问题。我想在yAxis上有4个嵌套圆(带有标签),每个嵌套圆具有不同的系列。无论值如何,标记都应位于为系列定义的圆内。

$(function () {

    var labels = ['Europe','Australia','North America','South America'];
    var series1 = [1,2,3,4];
    var series2 = [5,6,7,8];
    var series3 = [1.5,2.5,3.5,4.5];
    var series4 = [5.5,6.5,7.5,8.5];

    var pointInterval = parseInt(360 / labels.length);
    var chart;
    chart=  Highcharts.chart('div-radarChar', {
        chart: {
            polar: true,
        },
        credits: {
            enabled: false
        },
        legend: {
            enabled: true
        },
        title: {
            text: 'Radar Chart'
        },
        pane: {
            startAngle: 0,
            endAngle: 360
        },
        tooltip: {
            formatter: function (pointInterval, tooltip) {
                var header ='<span style="font-size: 10px">' + this.key + '</span><br/>';
                var point = '<span style="color:' + this.series.color + '">\u25CF</span> ' + this.series.name + ': <b>' + this.y + '</b><br/>';
                return header + point;
            }
        },
        xAxis: {
            labels: {
                style: {
                    "whiteSpace": "nowrap"
                },
            },
            categories: labels
        },
        yAxis: {
            min: 0
        },


        plotOptions: {
            series: {
                dataLabels: {
                    enabled: true
                },
                pointStart: 0,
                marker: {
                    enabled: true,
                    symbol: 'circle',
                    radius: 10,
                }
            },
            column: {
                pointPadding: 0,
                groupPadding: 0
            }
        },
        series: [{
            lineWidth: 0,
            type: 'line',
            name: 'Series 1',
            data: series1,
            fillColor:'#008000',
            color: '#008000'
        },
        {

            lineWidth: 0,
            type: 'line',
            name: 'Series 2',
            data: series2,
            fillColor:'#FFFF00',
            color: '#FFFF00'

        },
        {

            lineWidth: 0,
            type: 'line',
            name: 'Series 3',
            data: series3,
            fillColor:'#FFA500',
            color: '#FFA500'

        },
        {

            lineWidth: 0,
            type: 'line',
            name: 'Series 4',
            data: series4,
            fillColor:'#FF0000',
            color: '#FF0000'
        }
        ]
    }); 
});

这是小提琴,这是我想要得到的结果:

http://jsfiddle.net/mfwq1x7n/

https://i.imgur.com/dt47nCC.png

任何帮助/指针都会受到赞赏。

1 个答案:

答案 0 :(得分:1)

您可以为每个系列创建一个带有单独的yAxis的极坐标图:

yAxis: [{
    lineColor: 'red',
    lineWidth: 3,
    tickPositions: [0, 4, 8, 12, 16]
}, {
    tickPositions: [0, 4, 8, 12, 16],
    angle: 90,
    lineColor: 'blue',
    lineWidth: 3
}, {
    tickPositions: [-4.5, -1.5, 1.5, 4.5, 7.5],
    angle: 180,
    lineColor: 'black',
    lineWidth: 3
}, {
    tickPositions: [-3.5, -0.5, 2.5, 5.5, 8.5],
    angle: 270,
    lineColor: 'pink',
    lineWidth: 3
}]

实时演示: http://jsfiddle.net/BlackLabel/06ohs1yr/

API参考: https://api.highcharts.com/gantt/yAxis.tickPositions