Adding multiple points after Template.Load crashes
Posted: Tue Apr 16, 2024 7:09 pm
Visual Studio 2022
Target framework .NET 6.0
Steema.TeeChart.net Version 4.2024.4.12
After a template is imported using the Load Command, it crashes after adding more the one point to the series. It crashes in 2nd LoadData. This example works if only 1 point is added.
public partial class Form1 : Form
{
Steema.TeeChart.TChart tChart1;
public Form1()
{
InitializeComponent();
tChart1 = new Steema.TeeChart.TChart();
this.Controls.Add(tChart1);
tChart1.Dock = DockStyle.Fill;
tChart1.Axes.Bottom.Visible = true;
tChart1.Axes.Left.Visible = true;
tChart1.Axes.Right.Visible = false;
tChart1.Legend.Visible = false;
Line line = new Line();
tChart1.Chart.Series.Add(line);
LoadData();
TemplateExport template = tChart1.Export.Template;
template.IncludeData = false;
tChart1.Export.Template.Save("template.json");
tChart1.Import.Template.Load("template.json");
LoadData();
}
private void LoadData()
{
var line = tChart1.Chart.Series[0];
line.Add(1, 1);
line.Add(2, 2);
line.Add(3, 3);
}
}
Target framework .NET 6.0
Steema.TeeChart.net Version 4.2024.4.12
After a template is imported using the Load Command, it crashes after adding more the one point to the series. It crashes in 2nd LoadData. This example works if only 1 point is added.
public partial class Form1 : Form
{
Steema.TeeChart.TChart tChart1;
public Form1()
{
InitializeComponent();
tChart1 = new Steema.TeeChart.TChart();
this.Controls.Add(tChart1);
tChart1.Dock = DockStyle.Fill;
tChart1.Axes.Bottom.Visible = true;
tChart1.Axes.Left.Visible = true;
tChart1.Axes.Right.Visible = false;
tChart1.Legend.Visible = false;
Line line = new Line();
tChart1.Chart.Series.Add(line);
LoadData();
TemplateExport template = tChart1.Export.Template;
template.IncludeData = false;
tChart1.Export.Template.Save("template.json");
tChart1.Import.Template.Load("template.json");
LoadData();
}
private void LoadData()
{
var line = tChart1.Chart.Series[0];
line.Add(1, 1);
line.Add(2, 2);
line.Add(3, 3);
}
}