Jquery 筛选要显示在饼图上的json数据

Jquery 筛选要显示在饼图上的json数据,jquery,highcharts,pie-chart,Jquery,Highcharts,Pie Chart,我的一个视图中有一个highcharts图表,我希望源数据是从返回json响应的路由加载的ajax 我的json数组如下 var data= [ { "id": 24, "title": "BCOM", "start": "2014-08-05 12:59:00 PM", "end": "2014-08-05 2:59:00 PM", "description": "mcom", "DIF

我的一个视图中有一个highcharts图表,我希望源数据是从返回json响应的路由加载的ajax

我的json数组如下

var data= [
      {
        "id": 24,
        "title": "BCOM",
        "start": "2014-08-05 12:59:00 PM",
        "end": "2014-08-05 2:59:00 PM",
        "description": "mcom",
        "DIFF": 120
      },
      {
        "id": 26,
        "title": "MCOM",
        "start": "2014-08-10 12:59:00 PM",
        "end": "2014-08-10 4:59:00 PM",
        "description": "mcom",
        "DIFF": 240
      },
      {
        "id": 29,
        "title": "MCOM",
        "start": "2014-08-11 12:59:00 PM",
        "end": "2014-08-11 8:59:00 PM",
        "description": "mcom",
        "DIFF": 480
      },
      {
        "id": 30,
        "title": "MCOM",
        "start": "2014-08-13 12:59:00 PM",
        "end": "2014-08-13 4:59:00 PM",
        "description": "mcom",
        "DIFF": 240
      }
    ];
我的饼图渲染脚本如下

$.each(data, function (i, point) {
    point.y = point.data;
});
$('#container').highcharts({
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: 1,//null,
        plotShadow: false
    },
    title: {
        text: 'Browser market shares at a specific website, 2014'
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</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: 'Browser share',
        data: data
    }]
});
$。每个(数据、函数(i、点){
点y=点数据;
});
$(“#容器”)。高图({
图表:{
plotBackgroundColor:null,
plotBorderWidth:1,//null,
plotShadow:false
},
标题:{
文字:“2014年特定网站的浏览器市场份额”
},
工具提示:{
pointFormat:“{series.name}:{point.percentage:.1f}%”
},
打印选项:{
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
启用:对,
格式:“{point.name}:{point.percentage:.1f}%”,
风格:{
颜色:(Highcharts.theme&&Highcharts.theme.ContractTextColor)| |“黑色”
}
}
}
},
系列:[{
键入“pie”,
名称:“浏览器共享”,
数据:数据
}]
});
数据没有正确地呈现在饼图上,它显示了0%的所有内容,没有显示颜色,我的结果如下


有人能帮我吗?

您提供给系列属性(作为数据属性)的数据格式错误

series: [{
            type: 'pie',
            name: 'Browser share',
            data: [
                ['Firefox',   45.0],
                ['IE',       26.8],
                {
                    name: 'Chrome',
                    y: 12.8,
                    sliced: true,
                    selected: true
                },
                ['Safari',    8.5],
                ['Opera',     6.2],
                ['Others',   0.7]
            ]
        }]
向序列提供数据的方法之一是使用以下格式

series: [{
            type: 'pie',
            name: 'Browser share',
            data: [
                ['Firefox',   45.0],
                ['IE',       26.8],
                {
                    name: 'Chrome',
                    y: 12.8,
                    sliced: true,
                    selected: true
                },
                ['Safari',    8.5],
                ['Opera',     6.2],
                ['Others',   0.7]
            ]
        }]

请点击此链接:

您需要解析数据以获得正确的形式,包括对象中的name/y参数

例如:

var数据=[],
len=dataRaw.length,
我

对于(i=0;i实际上,iam以正确的JSONFormat将数据传递给数据属性。您是在谈论数据变量吗?如果是。那么您确定您的格式。它看起来很奇怪。您能给我一个解决方案来筛选此数据以正确地匹配饼图吗