私たちはjsonレスポンスを生成する既存の残りのWebサービスを持っています。 Googleではこれらのデータを表示するためにGoogleグラフを使用したいと考えています。 Googleの視覚化APIは、独自のjson形式を期待しているようだ。通常のjsonオブジェクトをjsオブジェクトのGoogle視覚化タイプに変換するための既存のjsメソッド/ライブラリはありますか?ありがとう。通常のjsonオブジェクトをjsオブジェクトのGoogle視覚化タイプに変換するための既存のjsメソッド/ライブラリはありますか?
0
A
答えて
0
これは実際にあなたが目指しているものと、どのようなデータがどのようなものか、使用したいGoogleチャートに依存します。私は通常、RESTデータとGoogleグラフを操作するときに次のことを行います。
この例ではjQueryを使用しますが、使用するjsライブラリはそれほど関連性がありません。あなたのJSONデータで簡単に選択特定のコンテンツに助けることができるjQueryとJSONQuery(でこれを行うには
{"events":[{"event":{"timestamp":"1310926588423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926578423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926568423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926558423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926548423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926538423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926528423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926518423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926508423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}},{"event":{"timestamp":"1310926498423","service":"EsperEventProcessor.service","countAll3Sec_EsperEventProcessor":"0","server":"EsperServer"}}]}
:
を使用すると、データとどのようなareachartでそれを表示するには、次のセットを持っていると言います)あなたは次のようなことができます:
// use the getJSON jQuery operation to get the REST data
$.getJSON(restURL, function(data) {
// use jsonquery to get all the 'event's from the JSON data
var query1 = "..event";
var rootEvent = JSONQuery(query1,data);
// manually create a datatable and fill it in the required
// way for this chart
var data2 = new google.visualization.DataTable();
data2.addColumn('string', 'Number of queries/per 10 seconds');
data2.addColumn('number', '# queries');
// each row is added based on information from the json event
// by simply iterating over the array
data2.addRows(rootEvent.length);
for (i = 0; i < rootEvent.length; i++) {
var date = new Date(parseInt(rootEvent[i]['timestamp']));
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var time = '';
if (hours < 10) time=time+'0'; time=time+hours+':';
if (minutes < 10) time=time+'0'; time=time+minutes+':';
if (seconds < 10) time=time+'0'; time=time+seconds;
data2.setCell(i,0,time);
data2.setCell(i,1,parseInt(rootEvent[i]['countAll3Sec_EsperEventProcessor']));
}
chart.draw(data2, {width: 400, height: 240, title: 'Requests per 10 seconds',
hAxis: {title: 'Time', titleTextStyle: {color: '#FF0000'}}
});
});
関連する問題
- 1. 視覚化オブジェクトのプロパティ
- 2. jsonオブジェクトをJSオブジェクトに変換できません
- 3. jsの変換オブジェクトが
- 4. 既存のJSONオブジェクトから新しいJSオブジェクトを構築する最善の方法は何ですか?
- 5. 既存のJSコードを構造化するためのフレームワーク
- 6. Google視覚化タイプの不一致
- 7. JSからC#にJSONオブジェクトのリストを渡す方法はありますか?
- 8. 既存の視覚化で検索
- 9. は、私はこのJavaScriptのオブジェクトを持っている既存のオブジェクトのjs
- 10. js、オブジェクトの状態監視
- 11. JSオブジェクトをJSONに変換するEmacsコマンド
- 12. JS JSONオブジェクトを配列に変換する
- 13. Dot言語ファイルの視覚化のためのjQueryプラグインはありますか?
- 14. 変更既存のWCFの通信オブジェクト
- 15. JavaScriptを "特定のオブジェクト"を "通常のオブジェクト"に変換するには?
- 16. Python - 既存のJSONオブジェクトにJSONオブジェクトを追加する
- 17. jsオブジェクトの置換/参照の変更
- 18. JSのすべてのオブジェクトにtoString()メソッドがありますか?
- 19. Googleの視覚化:グラフの描画後にJSの実行が再開するのはどこですか?
- 20. javascriptのd3.jsによるデータの視覚化
- 21. クロスプラットフォームのデータ視覚化ソフトウェア? (好ましくはHTML/JS)
- 22. JSONオブジェクトを使ったAngular jsのグラフ
- 23. Googleの視覚化 - ChartWrapper - テーブルに列がありません
- 24. 通常のpng画像をjsonデータに変換してオブジェクトに格納する
- 25. 文字列(JSオブジェクト形式)をPHPオブジェクトに変換する
- 26. Googleの視覚化:DataTableオブジェクトのユーザー検索を提供する方法
- 27. jsonオブジェクトをjsonオブジェクトに変換する
- 28. カフカJSONにJSON配列の変換のためのストリームは、以下の...私はJSONオブジェクトにJSON配列を変換するための通常のJavaのコードを持っていると私はカフカに、この通常のJavaストリームを変換する必要があり
- 29. JS/lodash - 私は構造下からのコレクション(オブジェクトの配列)を変換するためにLodash/JSソリューションを探していたオブジェクト
- 30. カサンドラのキースペース用の視覚化ツールはありますか?
通常のjsonオブジェクトはどのように見えますか?データテーブルを作成するためのオプションがいくつかあります。たとえば、[arrayToDataTable](http://code.google.com/apis/chart/interactive/docs/reference.html#google.visualization)を使用することができます。 arraytodatatable)あなたのjsonデータが単なる配列の場合。 – oli
@oil:["key":{"columnA": "abc"、 "columuB":123}、 "key":{"columnA": "cba"、 "columuB":321} }] – Bobo