0

OK、Web サイト API からの JSON ファイルがあり、データを Highcharts で読み取れるように再配置する必要があります。進め方がわかりません。URL があり、highcharts Web サイトのドキュメントを読んで、正しく使用するためにデータを再フォーマットする必要があります。どうすればよいですか?

JSON ファイルをロードする php ファイルをセットアップしてから、javascript を使用して必要なものを選択する必要がありますか? もしそうなら、どうすればこれを達成できますか?

前もって感謝します!

JSON データの例を次に示します。

[
  {
    "timestamp": 1382918400,
    "localTimestamp": 1382918400,
    "issueTimestamp": 1382918400,
    "fadedRating": 4,
    "solidRating": 0,
    "swell": {
      "minBreakingHeight": 5,
      "absMinBreakingHeight": 4.508,
      "maxBreakingHeight": 7,
      "absMaxBreakingHeight": 7.049,
      "unit": "ft",
      "components": {
        "combined": {
          "height": 18,
          "period": 10,
          "direction": 37.25,
          "compassDirection": "SW"
        },
        "primary": {
          "height": 18,
          "period": 10,
          "direction": 47.09,
          "compassDirection": "SW"
        }
      }
    },
    "wind": {
      "speed": 15,
      "direction": 79,
      "compassDirection": "W",
      "chill": 54,
      "gusts": 29,
      "unit": "mph"
    },
    "condition": {
      "pressure": 986,
      "temperature": 59,
      "weather": "23",
      "unitPressure": "mb",
      "unit": "f"
    },
    "charts": {
      "swell": "http://chart-1.msw.ms/wave/750/1-1382918400-1.gif",
      "period": "http://chart-1.msw.ms/wave/750/1-1382918400-2.gif",
      "wind": "http://chart-1.msw.ms/gfs/750/1-1382918400-4.gif",
      "pressure": "http://chart-1.msw.ms/gfs/750/1-1382918400-3.gif",
      "sst": "http://chart-1.msw.ms/sst/750/1-1382918400-10.gif"
    }
  },
]
4

2 に答える 2

0

JSON ファイルの解析に PHP は使用しません。JavaScript で直接実行できます。

自分で行うか、http://underscorejs.org/のようなライブラリを使用するか、さらに良いhttp://lodash.com/を使用することができます。

Hightchart で読み取ることができる JSON 入力と出力は正確には何ですか?

于 2013-10-28T22:10:45.480 に答える