javascript - Highcharts 这么样设置提示里面的内容呢?

查看:85
本文介绍了javascript - Highcharts 这么样设置提示里面的内容呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

比如说我像设置这里的内容,这么样才是设置成跟他一模一样呢!

解决方案

var obj={web:'22',iphone:'30'}; //从后台取出数据,转为object对象
$(function () {

$('#container').highcharts({
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false
    },
    title: {
        text: ''
    },
    tooltip: {
        formatter: function() {
            //tooltip:设置hover时弹出内容,obj[this.point.name] 后台数据
            return '<b>'+ this.series.name +'</b>: '+'<b>'+ this.point.name +'</b><br>'+'<b>'+ '登陆次数' +'</b>: '+'<b>'+obj[this.point.name]+'</b>'
        }
    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                style: {
                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                }
            }
        }
    },
    series: [{
        type: 'pie',
        name: '用户终端类型',
        data: [
            ['iphone',   26.67],
            ['web',   73.33]
        ]
    }]
});

});

这篇关于javascript - Highcharts 这么样设置提示里面的内容呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆