首页 > 解决方案 > 如何在highchart中动态对齐3d饼图

问题描述

我是 highcharts 的新手,在整合我的数据时遇到问题。饼图显示准确的数据,但未设置对齐。

在这张图片中,左侧的饼图运行良好。

var user_daily=new Highcharts.chart('user_data', {
    chart: {
        type: 'pie',
        options3d: {
            enabled: true,
            alpha: 45,
            beta: 0
        }
    },
    title: {
        text: 'Employee Record'
    },
    accessibility: {

    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.y}</b>'
    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            depth: 35,
            dataLabels: {
                enabled: true,
                format: '{point.name}',

            },

        }
    },
    series: [{
        type: 'pie',
        name: 'Employee Entries',
        data: [
            ['Default', 45.0],

        ]
    }]
});
    var chart =new Highcharts.chart('container', {
            chart: {
              plotBackgroundColor: null,
              plotBorderWidth: null,
              plotShadow: false,
              type: 'pie'
            },
            title: {
              text: "User's Daily Entries  "
            },
            tooltip: {
              pointFormat: '{series.name}: <b>{point.y}</b>'
            },
            plotOptions: {
              pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                  enabled: true
                },
                showInLegend: false
              }
            },
            series: [{
                 name: 'Entries',
                 colorByPoint: true,
                 data: [{ name:'',y:22 }

                 ]
            }]
          });

关于更改功能:-

  type:'post',
  url:'user_daily_graph.jsp',
  data:{
      user_id:$('#ad_user_id').val(),
      date:$('#Daily_graph_date').val(),
  },
  success:function(msg){
      msg=msg.trim();

        list=msg.split("!!");
        user_daily.redraw();
        while(user_daily.series.length > 0)
            user_daily.series[0].remove(true);
        user_daily.addSeries({  
             type: 'pie',
            name: 'Entries'


        }, false);

        for(var i=1;i<list.length;i++){

            if(list[i].length!=0){

                temp2=list[i].split("!@")

                user_daily.series[0].addPoint({
                       name: temp2[0],
                        y: parseInt(temp2[1]),
                    },true);
            }
        }


  }

在页面加载时,图表停留在它应该在的位置。当我点击功能时,它显示数据但对齐出错。

标签: ajaxhighcharts

解决方案


推荐阅读