Page 1 of 1

Loading a template file creates problems for a tower series.

Posted: Mon Jan 23, 2006 5:22 pm
by 8125470
1.1.2179.21092

This article relates to
http://www.teechart.net/support/viewtopic.php?t=2961
and
http://www.teechart.net/support/viewtopic.php?t=3376

To recreate...

In designer...

Add a teechart to a form.
Add a commander bar and set the chart property.

Run...

Add a tower series
Add a random data source (just select random and apply)

Click a button which does the following operation...

private void button1_Click(object sender, System.EventArgs e)
{

string path = string.Format("{0}\\Charts", Application.StartupPath);

// Determine whether the directory exists.
if(!System.IO.Directory.Exists(path))
{
// Try to create the directory.
System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(path);
}


string strChartTemplatePath = Application.StartupPath + @"\Charts\01.Ten";

// Store the existing chart.
System.IO.FileStream fsCreate = null;

if(strChartTemplatePath != null)
{
// Overwrite the existing file
fsCreate = new System.IO.FileStream(strChartTemplatePath,System.IO.FileMode.Create);

this.tChart1.Export.Template.Save(fsCreate);
}

if(fsCreate != null)
{
fsCreate.Close();
}

FileStream fsOpen = null;

if(strChartTemplatePath != null)
{
fsOpen = new System.IO.FileStream(strChartTemplatePath, System.IO.FileMode.Open);

this.tChart1.Import.Template.Load(fsOpen);
}

if(fsOpen != null)
{
fsOpen.Close();
}


this.commander1.Chart = this.tChart1;
}




Conclusion....

A red bar appears as the first XYZ value oon the chart.

Regards,

Vaughan