Hightchart 实现 polar 雷达图

需要多引入一个highchart-more.js


推荐一个在线编辑的网站:http://code.hcharts.cn/demos/hhhhig

$(function () {

    $('#container').highcharts({

        chart: {
            polar: true,
            type: 'line'
        },

        title: {
            text: 'Budget vs spending',
            x: -80
        },

        pane: {
            size: '80%'
        },

        xAxis: {
            categories: ['Sales', 'Marketing', 'Development', 'Customer Support',
                    'Information Technology', 'Administration'],
            tickmarkPlacement: 'on',
            lineWidth: 0
        },

        yAxis: {
            gridLineInterpolation: 'polygon',
            lineWidth: 0,
            min: 0
        },

        tooltip: {
            shared: true,
            pointFormat: '<span style="color:{series.color}">{series.name}: <b>${point.y:,.0f}</b><br/>'
        },

        legend: {
            align: 'right',
            verticalAlign: 'top',
            y: 70,
            layout: 'vertical'
        },

        series: [{
            name: 'Allocated Budget',
            data: [43000, 19000, 60000, 35000, 17000, 10000],
            pointPlacement: 'on'
        }, {
            name: 'Actual Spending',
            data: [50000, 39000, 42000, 31000, 26000, 14000],
            pointPlacement: 'on'
        }]

    });
});


  var chart;
    $(document).ready(function () {

        chart = new Highcharts.Chart({

            chart: {
                padding:0,
                margin:0,
                renderTo: 'container',
                polar: true,
                type: 'area',
                //backgroundColor: '#F2F2F2'
                plotBackgroundImage:"http://imgd3.laoyuegou.com/mayday/img/dota-news/bg_gray.jpg",
            },
            title: {
                text: '',
                x: -80
            },
            credits:{
                enabled: false
            },
            exporting: {
                enabled: false
            },
            pane: {
                size: '85%',
                startAngle: 20,
                center: ['50%', '50%']
            },
            plotOptions: {
                area: {
                    fillOpacity: 0.30
                }
            },

            xAxis: {
                categories: ['输出', '生存', '推塔', '团战','发育'],
                tickmarkPlacement: 'on',
                lineWidth: 0,
                gridLineColor: '#D8D8D8',
                labels:{
                    style:{
                        color: '#B3B9C2',//B7F1E2
                    }
                },
                showFirstLabel:true
            },

            yAxis: {
                gridLineInterpolation: 'polygon',
                lineWidth: 0,
                min: 0,
                max: 15,
                gridLineWidth :1,
                gridLineColor: '#B3B9C2',
                plotBands: [{
                    color: '#F2F2F2',
                    borderColor:'#B3B9C2',
                    borderWidth:1,
                    from: 0,
                    to: 5
                }, {
                    color: '#F2F2F2',
                    borderColor:'#B3B9C2',
                    borderWidth:1,
                    from: 5,
                    to: 10
                }, {
                    color: '#F2F2F2',
                    borderColor:'#B3B9C2',
                    borderWidth:1,
                    from: 10,
                    to: 15
                }, {
                    color: '#F2F2F2',
                    borderColor:'#B3B9C2',
                    borderWidth:1,
                    from: 15,
                    to: 20
                }],
                labels:{
                    enabled: false
                }
            },

            tooltip: {
                useHTML: true,
                backgroundColor: '#FFFFFF',
                borderWidth: 0,
                style: {
                    color: 'gray',
                    padding: '10px'
                },
                headerFormat: '',
//                shared: true,
//                pointFormat: '<span style="color:{series.color}">{series.name}: <b>{point.y:,.0f}</b><br/>',
                // ["kdara"]=>    //输出
                // ["hdra"]=>     //团战
                // ["dra"]=>      //生存
                // ["gpmra"]=>    //发育 每分钟金钱
                // ["tdra"]=>     //推塔
                formatter: function(){
                    var s = '';
                    if(this.x == '输出')
                    {
                        return  "<p style='text-align: center;'>" + this.key + ": <span style='color:#f60'>" +  "B" + "</span></p></span>";
                    }
                    else if(this.x == '生存')
                    {
                        return "<p style='text-align: center;'>" +this.key + ": <span style='color:#f60'>" +  "A"+ "</span></p></span>";
                    }
                    else if(this.x == '推塔')
                    {
                        return "<p style='text-align: center;'>" +this.key + ": <span style='color:#f60'>" +  "B-"+ "</span></p></span>";
                    }
                    else if(this.x == '团战')
                    {
                        return "<p style='text-align: center;'>" +this.key + ": <span style='color:#f60'>" +  "B+"+ "</span></p></span>";
                    }
                    else if(this.x == '发育')
                    {
                        return "<p style='text-align: center;'>" +this.key + ": <span style='color:#f60'>" +  "A"+ "</span></p></span>";
                    }

                    return s;
                }
            },

            legend : {
              enabled: false
            },

            series: [{
                data: [{
                    name: '输出',
                    y: 6.1,
                    marker: {
                        symbol: 'url(http://imgd3.laoyuegou.com/static/img/app/dota2/icon_shuchu_dark.png)',
                        width: 13,
                        height: 13
                    }
                },{
                    name: '生存',
                    y: 9.5,
                    marker: {
                        symbol: 'url(http://imgd3.laoyuegou.com/static/img/app/dota2/icon_shengcun_dark.png)',
                        width: 13,
                        height: 13
                    }
                },{
                    name: '推塔',
                    y: 5,
                    marker: {
                        symbol: 'url(http://imgd3.laoyuegou.com/static/img/app/dota2/icon_tuita_dark.png)',
                        width: 13,
                        height: 13
                    }
                },{
                    name: '团战',
                    y: 7,
                    marker: {
                        symbol: 'url(http://imgd3.laoyuegou.com/static/img/app/dota2/icon_tuanzhan_dark.png)',
                        width: 13,
                        height: 13
                    }
                },{
                    name: '发育',
                    y: 9.5,
                    marker: {
                        symbol: 'url(http://imgd3.laoyuegou.com/static/img/app/dota2/icon_fayu_dark.png)',
                        width: 13,
                        height: 13
                    }
                }],
                pointPlacement: 'on',
                color: '#269783'
            } ]

        });

        chart.series[0].points[0].onMouseOver();
    });



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值