javascript - Highcharts : Combo-meteogram (DATA, XML/JSON)

标签 javascript json highcharts highmaps

我想修改这个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/

相关文章:

javascript - HTML 表格,当我 ctrl+click 时,单元格的边框出现了?

java - 如何在 Java 中将 YAML 转换为 JSON?

javascript - Highcharts 高亮单点在线

Highcharts:图表底部 y 轴的最小值

javascript - 如何通过 Rxjs 中的简单缓冲来缓冲可观察值?

javascript - jQuery 按钮来检查所有复选框问题

javascript - 流体模板: passing a javascript varible as the argument value?

java - jax-rs : For a same @Path method returning Json, 如何根据设备类型进行不同的序列化

json - Postgres 决策、JSON 或额外的列?

javascript - Highstock 库存工具创建指标 GUI 看不到图表系列