我正在使用谷歌图表API绘制饼图。饼图是通过对我设置的API进行ajax调用动态生成的,它正在工作但是当我开始添加更多数据时,饼图突然从显示每个段到显示带有一个值的图表 - 其他。
这是从服务器回来的json
{
"cols" : [{
"id" : "",
"label" : "Team",
"type" : "string"
}, {
"id" : "",
"label" : "Steps",
"type" : "number"
}
],
"rows" : [{
"c" : [{
"v" : "Draper",
"f" : null
}, {
"v" : "626528",
"f" : null
}
]
}, {
"c" : [{
"v" : "Sterling",
"f" : null
}, {
"v" : "539165",
"f" : null
}
]
}, {
"c" : [{
"v" : "Pryce",
"f" : null
}, {
"v" : "557399",
"f" : null
}
]
}, {
"c" : [{
"v" : "London",
"f" : null
}, {
"v" : "807470",
"f" : null
}
]
}, {
"c" : [{
"v" : "Lynx Local",
"f" : null
}, {
"v" : "428814",
"f" : null
}
]
}, {
"c" : [{
"v" : "Havas Health Software",
"f" : null
}, {
"v" : "375235",
"f" : null
}
]
}
]
}
这是我加载图表的javascript
var jsonData = $.ajax({
url: "/ChartData/OverallSteps",
async: false
}).responseText;
var pieData = new google.visualization.DataTable(jsonData);
var pieOptions = {
width: 600, height: 320, 'legend': { position: 'right',alignment:'center' },is3D: true,sliceVisibilityThreshold: 1/10000, chartArea: {left:0,top:0}
};
var pieChart = new google.visualization.PieChart(document.getElementById('teamPieChart'));
pieChart.draw(pieData, pieOptions);
正如您所看到的,我已尝试按照此Google Pie Chart not Showing All Data Rows设置sliceVisibilityThreshold,但这似乎也不是问题。只有6个系列所以应该没问题。谁能看到发生了什么?
答案 0 :(得分:5)
问题是您输入的数字是字符串,这是无效的:
"v" : "626528"
应该是:
"v" : 626528