I'm attempting use the C# Chart
object to build a chart of data points. For each data point in an array, I would like to plot the point on the chart and have the bars "grow" as the points are added. So when I generate 1000 random numbers, I want to set 1,000 points on the chart all starting at zero with their values increasing by one each time. In attempting to do this, I have noticed that the chart just builds all at one time instead of adding each point and "growing" the bars. Any suggestion on how to make the bars animate? I know the chart is an image, so I don't mind if it is redrawn each time, but I can't even quite figure out a way to do that.
Here is an example of my code:
for (int i = 1; i <= numberOfRolls; i++)
{
int number = randomNumber();
myNumberDictionary[number] += 1;
foreach (var point in MyChart.Series["MySeries"].Points)
{
point.SetValueXY(Convert.ToInt32(point.XValue), myNumberDictionary[Convert.ToInt32(point.XValue)]);
}
}
Any suggestions?
For each data point added to the chart, I would like to add the point to the chart
- that sentence makes no sense. - TarecmyNumberArray
(whatever it does) and increase its value by 1. Then in internal foreach loop your setting every point'sY
position to the properrolls
list element. What do those do? - Tarecpoint.SetValueXY
is pointless, because in every iteration offor
loop it does exactly the same. AndmyNumberDictionary[number] += 1
increases by 1 some RANDOMmyNumberDictionary
element. What are those 2 collections holding? - TarecRefresh()
method of aChart
object? However in winforms bitmap-based animation are never a good idea. - Tarec