0
我正在創建漏斗圖,它使用jquery.it從mysql表中獲取數據。它在其他所有高圖表上工作,但在漏斗圖中失敗。 這裏是我的代碼無法在高圖中從mysql獲取數據
的index.php
<script type="text/javascript" src="high-js/funnel-chart.js"></script>
<div id="topcustomer" style="height: 500px;"></div>
漏斗chart.js之
$(function() {
var curcust = new Highcharts.Chart({
chart: {
renderTo:'topcustomer',
type: 'funnel',
marginRight: 100
},
title: {
text: 'Top 5 Customer',
x: -50
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '<b>{point.name}</b> ({point.y:,.0f})',
color: 'black',
softConnector: true
},
neckWidth: '30%',
neckHeight: '25%'
//-- Other available options
// height: pixels or percent
// width: pixels or percent
}
},
legend: {
enabled: false
},
series: [{
name: 'Current Month'
}]
});
jQuery.get('data.php', null, function(tsv) {
var lines = [];
traffic = [];
try {
// split the data return into lines and parse them
tsv = tsv.split(/\n/g);
jQuery.each(tsv, function(i , line) {
line = line.split(/\t/);
cust = line[0] ;
traffic.push([
cust,
line[1]
]);
});
} catch (e) { }
curcust.series[0].data = traffic;
chart = new Highcharts.Chart(curcust);
});
});
data.php
$result = mysql_query("SELECT customer, SUM(amount) AS amo FROM `yearly_sales` GROUP BY customer LIMIT 5");
while($row = mysql_fetch_array($result)) {
echo $row['customer'] . "\t" . $row['amo']. "\n";
}
它不顯示任何錯誤並且圖表未生成。 在我的代碼中是否有任何錯誤? 請幫我出這個問題感謝名單
thanx @adamS但它也不起作用。 –
查詢的結果是什麼。運行data.php併發布結果。 – adamS
其結果如'公司1 31150.00 Company2 8480.00 Company3'3603370.50 Company4(POWER PROD.DIV)2241750.55 Company5 25657162.13 –