我创建的文档与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