我想修改这个jsfiddle代码。
我不想从json/xml获取数据,但我想手动这样放置:
this is a part of my code I didn't continued cause I lost it and it's complicated
{
name: 'Air pressure',
color: Highcharts.getOptions().colors[2],
data: [1020.5, 0, 0, 0, 0, 1009.5, 1015.5, 1010.5, 1001.5, 1001.5],
marker: {
enabled: false
},
shadow: false,
tooltip: {
valueSuffix: ' hPa'
},
dashStyle: 'shortdot',
yAxis: 2
}
对于所有事情,我只想获取所有数据的 5 个值。
Datetime, Precipitation, Temperature, Air pressure ....
这是一个example手动输入的数据,而不是从服务器或其他东西输入的数据。
最后,我想知道可以将数据放在哪里,因为我有数据,但我不知道可以将其放在哪里。
最佳答案
在 JavaScript 代码的末尾,您可以找到 function(xml)。
在其中您可以编写console.log(xml),然后在控制台(开发人员工具)中检查数据的结构是什么。
如果您确实想更改演示的代码,那么您必须以相同的格式写入数据。
您可以查看代码以了解到底需要什么,因为并非所有数据都被使用。在此基础上,您可以禁用ajax调用并手动创建数据对象。
示例:http://jsfiddle.net/qLynjzds/
数据在演示中如何发挥作用的示例(2 分):
var xml = {
credit: {
link: {
'@attributes': {
url: "http://www.yr.no/place/United_Kingdom/England/London/" //link for credits
}
}
},
location: {
country: "Country",
name: "City"
},
forecast: {
tabular: {
time: [{
'@attributes': {
from: "2015-05-28T14:00:00",
to: "2015-05-28T15:00:00"
},
symbol: {
'@attributes': {
'var': "01d",
name: "Clear sky"
},
},
temperature: {
'@attributes': {
value: "17"
},
},
precipitation: {
'@attributes': {
value: "0"
},
},
windDirection: {
'@attributes': {
deg: "252.6",
name: "West"
},
},
windSpeed: {
'@attributes': {
mps: "16.6",
name: "Strong breeze"
},
},
pressure: {
'@attributes': {
value: "1013.8"
},
}
}, {
'@attributes': {
from: "2015-05-28T15:00:00",
to: "2015-05-28T16:00:00"
},
symbol: {
'@attributes': {
'var': "01d",
name: "Clear sky"
},
},
temperature: {
'@attributes': {
value: "15"
},
},
precipitation: {
'@attributes': {
value: "1"
},
},
windDirection: {
'@attributes': {
deg: "252.6",
name: "West"
},
},
windSpeed: {
'@attributes': {
mps: "16.6",
name: "Strong breeze"
},
},
pressure: {
'@attributes': {
value: "1010.8"
},
}
}]
}
}
};
关于javascript - Highcharts : Combo-meteogram (DATA, XML/JSON),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30503169/