質問
彼らは自分を取るようなA方式でグラフを作成するための道場
こんにちは、私の必要性 特定の入力ボックスから系列値とチャートの変更
- :私は先にこれをやって行きました。この概念にautomatically.So var showChart= function(){
var thevalue=dijit.byId('myvalue').get('value');//gets thevalue from the dijit numbertextbox
var chart1 = new dojox.charting.Chart2D("showgoals");
chart1.addPlot("default", {type: "Lines"});
chart1.addAxis("x");
chart1.addAxis("y", {vertical: true});
chart1.addSeries("Series 1", [thevalue, 2, 2, 3, 4, 5, 5, 7]);
chart1.render();};
そして、私はこの関数を呼び出して値が変わる: -
dojo.connect(dojo.byId('myvalue'), "onchange",showChart);//whenever value changes the showChart function
と呼ばれている。
このようなHTMLルックス: -
<div dojoType="dijit.layout.ContentPane" region="center">
<div id="showgoals" style="width: 250px; height:150px;" class="graph1"></div>
以下の値を変更するテキストボックスである: -
<input id="myvalue" type="text" dojoType="dijit.form.NumberTextBox" name="myvalue"value="1000000" required="true"
invalidMessage="Only Numbers allowed"/><br/><br/>
私は何を望んでいたことだったそのときには、この入力ボックスの値が変更、 関数showchartが呼び出されると現在のプロットであります 自動的に新しい値を表示するように変更しましたが、何が起こっているのです 私はかなり自然に感じ、全く新しいチャート..ウィルIを得ること そうならば、古いチャートを破棄して、新しいグラフを再作成する必要があり どのように私に教えてくださいます。
解決
showChart
機能では、新しいグラフは、関数がnew dojox.charting.Chart2D("showgoals")
を使用して呼び出されるたびに作成されます。あなたは、チャートを更新する場合は、チャートを更新するために、再びシリーズと呼びupdateSeries
の更新データにrender()
を呼び出すことができます。
のコードは以下のようになります
var chart1 = null;
var showChart = function() {
var thevalue=dijit.byId('myvalue').get('value');
if (!chart1) {
var chart1 = new dojox.charting.Chart2D("showgoals");
chart1.addPlot("default", {type: "Lines"});
chart1.addAxis("x");
chart1.addAxis("y", {vertical: true});
chart1.addSeries("Series 1", [thevalue, 2, 2, 3, 4, 5, 5, 7]);
}
else {
chart1.updateSeries("Series 1", [thevalue, 2, 2, 3, 4, 5, 5, 7]);
}
chart1.render();
}
所属していません StackOverflow