var chart;
point = null;
$(document).ready(function() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Srikakulam_mandal.aspx/MandalAnalysis",
dataType: "json",
success: function (Result) {
Result = Result.d;
Resultarr = [];
for (var i in Result) {
var data = {
LocationName: Result[i].LocationName,
Ranking: Result[i].Ranking,
LocationId: Result[i].LocationId
};
Resultarr.push(data);
}
chart = new Highcharts.Chart({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Village Development Measuring System'
},
tooltip: {
formatter: function() {
return '<b>' + this.point.LocationName + '</b>: ' + this.point.Ranking + ' %';
// return '<b>' + this.point.LocationName + '</b>: ' + this.point.Ranking + ' %'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
// format: '<b>{point.LocationName}</b>: {point.Ranking:.1f} %',
format: '<b>{point.LocationName}</b>: {point.Ranking:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
},
connectorColor: 'silver',
}
}
},
series: [{
"data": Resultarr,
type: 'pie',
point: {
events: {
click: function (event) {
alert(this.LocationId);
}
}
}
}],
"chart": {
"renderTo": "container"
},
});
}
});
});
你好我试图用highchart插件,所以我传递一个JSON对象数据。所以我想创建一个圆环图jQuery的JSON对象创建一个圆环图解决我不能够applend图表,我想我的图表可以点击每个切片,并在代码生成slice.look的ID,请说明在何处我做错了
var chart;
point = null;
$(document).ready(function() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Srikakulam_mandal.aspx/MandalAnalysis",
dataType: "json",
success: function(Result) {
Result = Result.d;
for (var i in Result) {
var data = [{
LocationName: Result[i].LocationName,
Ranking: Result[i].Ranking,
LocationId: Result[i].LocationId
}];
chart = new Highcharts.Chart({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Village Development Measuring System'
},
tooltip: {
formatter: function() {
return '<b>' + this.point.LocationName + '</b>: ' + this.point.Ranking + ' %';
// return '<b>' + this.point.LocationName + '</b>: ' + this.point.Ranking + ' %'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
// format: '<b>{point.LocationName}</b>: {point.Ranking:.1f} %',
format: '<b>{point.LocationName}</b>: {point.Ranking:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
},
connectorColor: 'silver',
}
}
},
series: [{
"data": data,
type: 'pie',
point: {
events: {
click: function(event) {
alert(this.LocationId);
}
}
}
}],
"chart": {
"renderTo": "container"
},
});
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div id="container">
1 VAR数据Y的解决这个问题 - 把它放在一边for循环,就像var data = []。 2.在for循环中创建对象数组,如data.push({....}); 3.将此数据传递给高图 –
嗨satyaki即使我做过之前发现相同的问题请参阅此链接http://stackoverflow.com/questions/35448396/unable-to-create-chart-in-highcharts-and-id- is-undefined – Lier
嗨Krishnan''still无法appen真正我能够看到一个位置它意味着一些事情在appen的循环 – Lier