我創建的文檔與highcharts散點圖Highcharts分散外部數據
Highcharts.chart('container', {
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
title: {
enabled: true,
text: 'Date of entry'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
yAxis: {
title: {
text: 'Values'
}
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: 'Dana {point.x} = {point.y}'
}
}
},
series: [{
name: 'Values',
color: 'rgba(223, 83, 83, .5)',
data: [[167.6, 64.5], [167.6, 72.3], [167.6, 61.4]]
}]
});
和工作原理。此代碼來自文檔頁面。我得到了像這個頁面上的正常分散數據Highcharts scatter jsfiddle 現在,我創建了另一個PHP文件,該文件生成了我實際需要的數據。它是在文件highcharts.php和結果是這樣的
[07.03.2017,21000],[07.03.2017,25000],[07.03.2017,33000],[07.03.2017,27000],[07.03.2017,30000],[01.01.2017,700],[11.05.2017,0],[11.05.2017,0],[11.05.2017,0],[11.05.2017,0],
如何將數據連接到這個highcharts.php文件?我找到了一些例子,但我無法實現它的工作。所以開始我需要這個,一行數據顯示在散點圖上。我失去了幾天,只是不明白我做錯了什麼。
謝謝。這非常有幫助。當我以這種方式糾正它時,我仍然遇到如何從外部文件中檢索這些數據的問題。我試着用這個:var json1 = null; \t \t \t $就({ \t \t \t \t URL: 'highcharts.php', \t \t \t \t成功:函數(輸出){ \t \t \t \t \t json1 =輸出; \t \t \t \t \t alert(json1); \t \t \t \t}, \t \t \t \t錯誤:功能(XHR,ajaxOptions,thrownError){ \t \t \t \t \t警報(xhr.status +「「+ thrownError); \t \t \t \t} \t \t \t});但值並不保存在json1變量中,所以jsfiddle中的代碼可以使用它。 – BSheep
請給我提供一個演示,試圖接收文件的內容。 –
我設法在jsfiddle中完成它,整個代碼,但它沒有工作? https://jsfiddle.net/BSheep/tznkhpsp/ – BSheep