Page 1 of 1
Template.Save/Load and GetSeriesMark
Posted: Mon Sep 03, 2007 3:13 pm
by 9641712
Using the WebChart component in a WebForms app:
MarkText set in a GetSeriesMark event handler is not saved by a call to Chart.Export.Template.Save() (or it is not loaded by a call to Chart.Import.Template.Load())
Posted: Mon Sep 03, 2007 3:25 pm
by narcis
Hi Dave,
Exporting TeeChart into a native file format or a stream doesn't save associated events. You'll need to assign the events again after having loaded the chart.
Posted: Mon Sep 03, 2007 3:55 pm
by 9641712
narcis wrote:Hi Dave,
Exporting TeeChart into a native file format or a stream doesn't save associated events. You'll need to assign the events again after having loaded the chart.
I tried the following code:
chart.Import.Template.Load(tmpChart);
foreach(Steema.TeeChart.Styles.Series series in chart.Series)
{
if (series.Title == "tcsCritical")
series.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(this.tcsCritical_GetSeriesMark);
}
However, the code in the foreach loop is not executed because chart.Series.Count == 0
Posted: Tue Sep 04, 2007 6:40 am
by narcis
Hi Dave,
Are you exporting the chart as in the example I posted
here or the zooming example at the ASP.NET demo?
If the problem persists please send us a simple example project we can run "as-is" to reproduce the problem here.
You can post your files at news://
www.steema.net/steema.public.attachments newsgroup or at our
upload page.
Thanks in advance.
Posted: Tue Sep 04, 2007 9:36 am
by 9641712
Hi,
Thanks for your replies. I found the problem but I'm not sure why it makes a difference.
My original code:
Steema.TeeChart.Chart chart = chtPareto.Chart;
chart.Import.Template.Load(tmpParetoChart);
foreach(Steema.TeeChart.Styles.Series series in chart.Series)
{
...
}
By changing the foreach statement to reference chtPareto.Chart instead of the local variable, "chart" I got the application to work i.e:
foreach(Steema.TeeChart.Styles.Series series in chtPareto.Chart.Series)
Posted: Tue Sep 04, 2007 9:44 am
by narcis
Hi Dave,
If chart variable is visible or declared in the same method as the foreach statement then I don't see why it shouldn't work.
Posted: Tue Sep 04, 2007 9:57 am
by 9641712
narcis wrote:Hi Dave,
If chart variable is visible or declared in the same method as the foreach statement then I don't see why it shouldn't work.
I can break your example code, too, by changing the LoadChart() method as follows:
private void LoadChart()
{
//retrieve the session stored Chart
tmpChart = (MemoryStream)Session["ch1"];
//set the Stream position to 0 as the last read/write
//will have moved the position to the end of the stream
tmpChart.Position = 0;
//import saved Chart
Steema.TeeChart.Chart chart = webChart1.Chart;
chart.Import.Template.Load(tmpChart);
Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)chart.Series[0]);
calendar1.Date = calendar1.Date.AddMonths(((int)Session["months"]));
}
This throws a System.ArgumentOutOfRangeException when trying to access chart.Series[0]
Posted: Tue Sep 04, 2007 2:30 pm
by narcis
Hi Dave,
If you are using TeeChart for .NET v3 then you should use this:
Code: Select all
private void LoadChart()
{
//retrieve the session stored Chart
tmpChart = (MemoryStream)Session["ch1"];
//set the Stream position to 0 as the last read/write
//will have moved the position to the end of the stream
tmpChart.Position = 0;
//import saved Chart
Steema.TeeChart.Chart chart = WebChart1.Chart;
chart = chart.Import.Template.Load(tmpChart);
Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)chart.Series[0]);
calendar1.Date = calendar1.Date.AddMonths(((int)Session["months"]));
}