.NET2 Problems refreshing charts
Posted: Thu Apr 19, 2007 4:45 am
Hi,
I'm using a timer on my Windows form to refresh the chart every few minutes. This is done by having the timer to call for the following function:
The problem is when the timer invokes the function in subsequent times, it'll add a new legend to the chart. It could be adding new series into the charts as well, but I've yet to test that.
As you could see, I have tried setting AutoRepaint to false but it didn't work.
Please advise. Thanks.
I'm using a timer on my Windows form to refresh the chart every few minutes. This is done by having the timer to call for the following function:
Code: Select all
public void Reload()
{
RegionDataHelper dh = new RegionDataHelper();
DataTable dt;
tChart1.AutoRepaint = false;
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line priceLine = new Steema.TeeChart.Styles.Line(tChart1.Chart);
Steema.TeeChart.Styles.Line demandLine = new Steema.TeeChart.Styles.Line(tChart1.Chart);
priceLine.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
priceLine.Title = "RRP";
priceLine.Color = Color.Blue;
demandLine.Title = "Demand";
demandLine.Color = Color.Brown;
demandLine.LinePen.Width = 3;
tChart1.Header.Text = RegionName;
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yy HH:mm";
dt = dh.GetData(RegionName);
foreach (DataRow dr in dt.Rows)
{
priceLine.Add(Convert.ToDateTime(dr["settlementdate"].ToString()), Single.Parse(dr["rrp"].ToString()));
demandLine.Add(Convert.ToDateTime(dr["settlementdate"].ToString()), Single.Parse(dr["totaldemand"].ToString()));
}
colourLine1 = new ColorLine(tChart1.Chart);
colourLine1.Active = true;
colourLine1.Axis = tChart1.Axes.Bottom;
colourLine1.AllowDrag = true;
colourLine1.Value = DateTime.Now.ToOADate();
tChart1.AutoRepaint = true;
tChart1.Refresh();
}
As you could see, I have tried setting AutoRepaint to false but it didn't work.
Please advise. Thanks.