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 に答える