私の現在のプロジェクトでは、データを生成するalgorythmがあります。このデータはLinechartで表示されますが、グラフは各ステップの後ではなく終了した時点でのみ更新されます。リアルタイムチャート更新
private void simulate(share[] shares)
{
int k = 0;
Random r = new Random(); //random values just for testing
while (k < 10)//10 steps (10 values for each share)
{
for (int i = 0; i < shares.Length; i++)
{
shares[i].value = r.Next(0, 10000);//random a new value
shares[i].history.Add(shares[i].value);//add the value to the value history
}
//now update the chart so that it first shows only one x point than two and so on
drawchart(shares);
k++;
}
}
private void drawchart(share[] shares)
{
cHshares.Series.Clear();//clear the chart
for (int i = 0; i < shares.Length; i++)//for each share
{
cHshares.Series.Add(shares[i].name);//add a new share to the chart
cHshares.Series[shares[i].name].ChartType = SeriesChartType.FastLine;
int j = 0;
//draw the lines with each value that exists for each share
foreach (double value in shares[i].history)
{
cHshares.Series[shares[i].name].Points.AddXY(j, value);
j++;
}
}
}
私はdrawchartのfunktionなぜそれがすべてのステップが終了した後、それが唯一の示すことであるすべてのステップを呼ぶので?
多分、チャートをリフレッシュすると役立ちます。 – TaW
私はrefresh()というメソッドはありません。そのようなドキュメンタリーが存在することは確かですが、requiret名前空間を追加した後でさえ、チャートにはリフレッシュの定義が含まれていないと言われています。 – Littellittel
よくc#は大文字小文字を区別しますので、メソッドは 'cHshares.Refresh();'です!すべてのSeriesを 'drawchart'メソッドで削除していることは間違いないと思います。 – TaW