客户端,我们正在使用 xsl。我想从 xlst 填充饼图。我从服务器端获取 xml 文件,如:
var services="<xsl:value-of disable-output-escaping="yes" select="/doc/serviceHistory/usageList"/>";
我如何动态填充饼图的数据。我尝试过下面的代码,但它不起作用。$(document).ready(function() {
var options = {
chart: {renderTo: 'container',type: 'pie',width: 334,height: 230},
title: {text: ''},
tooltip: {pointFormat: '{series.name}: <b>{point.percentage}%</b>',percentageDecimals: 0},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b> ';
}
}
}
},
series: [{name: 'Allowed',
data:[]
}]
};
$.get('doc.xml', function(xml) {
var $xml = $(xml);
$xml.find('doc serviceHistory usageList').each(function(i, series) {
var seriesOptions = {
name: $(series).find('name').text(),
data: []
},
name = [];
$xml.find('doc serviceHistory usageList usage usageType').each(function(i, category) {
name[i] = $(category).text();
});
$(series).find('doc serviceHistory usageList usage percentage').each(function(i, point) {
seriesOptions.data.push([name[i],parseInt($(point).text())]);
});
options.series.push(seriesOptions);
});
var chart = new Highcharts.Chart(options);
});