我正在从一个由“样条线”和“饼图”组成的 ajax json 对象构建一个组合图表。
我遇到的问题只是饼图渲染,就好像饼图覆盖了样条曲线。如果我删除饼图,则样条线会正确呈现。
这是我的代码。
$(document).ready(function () {
var options = {
chart: {
renderTo: 'container'
},
title: {
text: 'The Planning Process'
},
xAxis: {
title: {
text: 'Time'
},
type: 'datetime'
},
yAxis: {
title: {
text: 'Turn Over'
}
},
plotOptions: {
series: {}
},
series: []
};
$.ajax({
type: "POST",
dataType: "json",
data: "{}",
contentType: "application/json; charset=utf-8",
url: "_services/ScriptService.asmx/getData",
success: function (items) {
var obj = jsonParse(items.d);
var series = { data: [] };
$.each(obj, function (itemNo, item) {
if (itemNo == 0) {
series.data = item.data;
series.name = item.name;
series.type = item.type;
} else if (itemNo == 1) {
series.type = item.type;
series.data = item.data;
series.name = item.name;
series.center = item.center;
series.size = item.size;
series.showInLegend = item.showInLegend;
}
});
options.series.push(series);
chart = new Highcharts.Chart(options);
console.log(options);
},
cache: false,
error: function (XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); }
});
});
还有我的json;
[{
"name": "Projection",
"type": "spline",
"data": [
[
634420512000000000,
100000
],
[
634421376000000000,
100086
],
[
634422240000000000,
100171
],
[
634423104000000000,
100257
]
]
},
{
"name": "Where you where",
"type": "pie",
"center": [
100,
80
],
"size": 100,
"showInLegend": false,
"data": [
{
"name": "Client Based Adviser Charged As Percent",
"color": "#4572A7",
"y": 8
},
{
"name": "Provider Commission Based As Percent",
"color": "#AA4643",
"y": 92
}
]
}]
谁能指出我哪里出错了?