0

我想修改这个jsfiddle代码。

不想json/xml获取数据,但我想像这样手动输入

这是我的代码的一部分,我没有继续,因为我丢失了它而且很复杂

{
        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 ....

这是手动输入数据的示例,而不是来自服务器或其他东西。

最后,我想知道我可以把我的数据放在哪里,因为我有它,但我不知道我可以把它放在哪里。

4

1 回答 1

1

在 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"
                        },
                    }
                }]
            }
        }
    };
于 2015-05-28T14:08:33.220 回答