I have a tChart which has a X axis as the Time. I want the X asis to auto scroll as time passed.
I found a solution to do this auto scrolling here :
http://www.teechart.net/support/viewtop ... 10&t=11426
If I leave the chart to runs for 2 hours, I observe that the memory usage keep increasing.
I though that its due to having too may data points on my chart. So I created a test application which limits the number of data points to 10.
Again, I see that memory usage keep increasing.
So, is the way of using the SetMinMax() to make the auto scrolling the recommended way?
The source codes of the test application is as follows :
Code: Select all
public partial class Form1 : Form
{
private const int MAX_DATA = 10;
public Form1()
{
InitializeComponent();
tChart1.Text = "My Chart Text";
tChart1.Aspect.View3D = false;
FastLine fl1 = new FastLine();
fl1.Title = "My Line 1";
fl1.Color = Color.Blue;
tChart1.Series.Add(fl1);
tChart1.Series[0].Clear();
tChart1.Axes.Bottom.AutomaticMinimum = false;
tChart1.Axes.Bottom.AutomaticMaximum = false;
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void OnTimerTick(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
tChart1.Series[0].Add(dt, tChart1.Series[0].XValues.Count + 1);
if (tChart1.Series[0].XValues.Count > MAX_DATA)
{
tChart1.Series[0].XValues.RemoveAt(0);
tChart1.Series[0].YValues.RemoveAt(0);
}
UpdateTimeAxis(dt);
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void UpdateTimeAxis(DateTime maxTime)
{
DateTime minScrollDateTime = maxTime.Subtract(new TimeSpan(0, 0, 10));
tChart1.Axes.Bottom.Minimum = minScrollDateTime.ToOADate();
tChart1.Axes.Bottom.Maximum = maxTime.ToOADate();
}
}