`
zengshaotao
  • 浏览: 752773 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

饼图实例

 
阅读更多

$(function () {

    var chart;

var totalMoney=50000

    $(document).ready(function() {

        chart = new Highcharts.Chart({

            chart: {

                renderTo: 'pie_chart',

                plotBackgroundColor: 'white',//背景颜色

                plotBorderWidth: 0,

                plotShadow: false

            },

            title: {

                text: 'Total:$'+totalMoney,

verticalAlign:'bottom',

y:-60

            },

            tooltip: {//鼠标移动到每个饼图显示的内容

                pointFormat: '{point.name}: <b>{point.percentage}%</b>',

                percentageDecimals: 1,

formatter: function() {

                    return this.point.name+':$'+totalMoney*this.point.percentage/100;

                }

            },

            plotOptions: {

                pie: {

size:'60%',

borderWidth: 0,

                    allowPointSelect: true,

                    cursor: 'pointer',

                    dataLabels: {

enabled: true,

                    color: '#000',

distance: -50,//通过设置这个属性,将每个小饼图的显示名称和每个饼图重叠

style: {

fontSize: '10px',

lineHeight: '10px'

},

formatter: function(index) {

                            return  '<span style="color:#00008B;font-weight:bold">' + this.point.name + '</span>';

                       }

                  },

padding:20

                }

            },

            series: [{//设置每小个饼图的颜色、名称、百分比

                type: 'pie',

                name: null,

                data: [

                    {name:'Base salary',color:'#3DA9FF',y:65},

{name:'Health insurance',color:'#008FE0',y:20},

{name:'Company matched',color:'#00639B',y:10},

{name:'Others',color:'#CBECFF',y:5}

                ]

            }]

        });

    });

    

});

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics