Template.Save/Load and GetSeriesMark

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave Fowler
Newbie
Newbie
Posts: 5
Joined: Wed Jun 28, 2006 12:00 am

Template.Save/Load and GetSeriesMark

Post by Dave Fowler » Mon Sep 03, 2007 3:13 pm

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())

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Sep 03, 2007 3:25 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Dave Fowler
Newbie
Newbie
Posts: 5
Joined: Wed Jun 28, 2006 12:00 am

Post by Dave Fowler » Mon Sep 03, 2007 3:55 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Sep 04, 2007 6:40 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Dave Fowler
Newbie
Newbie
Posts: 5
Joined: Wed Jun 28, 2006 12:00 am

Post by Dave Fowler » Tue Sep 04, 2007 9:36 am

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)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Sep 04, 2007 9:44 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Dave Fowler
Newbie
Newbie
Posts: 5
Joined: Wed Jun 28, 2006 12:00 am

Post by Dave Fowler » Tue Sep 04, 2007 9:57 am

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]

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Sep 04, 2007 2:30 pm

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"]));
  } 
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply