2

折れ線グラフを動的に更新する必要がある Web サイトを構築しています。このために、Web サイトで入手できるこの例に完全に基づいて、これを達成するために必要なチャート作成機能を提供する dojo ライブラリを使用しています。

http://dojotoolkit.org/documentation/tutorials/1.6/charting_advanced/
http://dojotoolkit.org/documentation/tutorials/1.6/charting_advanced/demo/store-series.html

この例では、y の新しい値でグラフを更新し、x の値を 1 ずつ増やす方法を示します。必要なのは、(x,y) のカスタム値でグラフを更新してプロットすることですが、これを行う方法が見つかりません。x と y の値をデータ ストアに直接強制しようとしましたが、結果がなく、グラフが読み込まれません。

            // Initial data
            var data = [
                // This information, presumably, would come from a database or web service
                { id: 1, x:0, y:20, site: 1 },
                { id: 2, value: 16, site: 1 },
                { id: 3, value: 11, site: 1 },
                { id: 4, value: 18, site: 1 },
                { id: 5, value: 26, site: 1 },
                { id: 6, value: 19, site: 2 },
                { id: 7, value: 20, site: 2 },
                { id: 8, value: 28, site: 2 },
                { id: 9, value: 12, site: 2 },
                { id: 10, value: 4, site: 2 }
            ];


            // Create the data store
            // Store information in a data store on the client side
            var store = dojo.store.Observable(new dojo.store.Memory({
                data: {
                    identifier: "id",
                    label: "Users Online",
                    items: data
                }
            }));

Google はそれ以上役に立ちませんでした。このデータ ストアをカスタム (x,y) 値ペアで動的に更新するにはどうすればよいですか? これを行う他の方法はありますか?

よろしくお願いします

4

2 に答える 2

0

テキスト入力を使用して (x,y) 値の一部を変更するとします。解決策は非常に簡単です(あなたの質問を理解していれば):

dojo.connect(dijit.byId("someInputElement"), "onChange", 
                 function(){
                            chart.updateSeries("bla bla", new_data).render();
                            //new data is the data store with custom(x,y)
                          });

それが役に立てば幸い!

于 2011-08-27T20:19:22.030 に答える