We are exporting our chart with data to .ten format using .NET version of Teechart. Later when we import the .ten file back to chart and save it as an image, the series data is missing. But saving the image directly works fine and renders well. I've replicated this issue in a sample .NET framework 4.8 console application and here's the code for the same. Also find attachments , one for image which is directly exported to PNG and the other which is imported from ten and then saved to image. Am I missing something?
Code: Select all
using Steema.TeeChart;
using Steema.TeeChart.Styles;
using System;
using System.Drawing;
class Program
{
static void Main(string[] args)
{
Chart chart = new Chart();
chart.Header.Text = "Sample TeeChart";
chart.Header.Font.Size = 16;
chart.Header.Font.Bold = true;
Line series = new Line(chart.Chart);
series.Title = "Sample Data";
series.Color = Color.Blue;
series.LinePen.Width = 2;
for (int i = 0; i < 100; i++)
{
double x = i * 0.1;
double y = Math.Sin(x) * Math.Exp(-x * 0.1);
series.Add(x, y);
}
chart.Axes.Bottom.Title.Text = "X Axis";
chart.Axes.Bottom.Title.Font.Size = 12;
chart.Axes.Left.Title.Text = "Y Axis";
chart.Axes.Left.Title.Font.Size = 12;
chart.Panel.Brush.Color = Color.White;
chart.Walls.Back.Pen.Visible = true;
chart.Walls.Back.Pen.Width = 1;
chart.Walls.Back.Pen.Color = Color.LightGray;
chart.Width = 600;
chart.Height = 400;
string fileName = "teechart.ten";
chart.Export.Template.IncludeData = true;
chart.Export.Template.Save(fileName);
Chart chart1 = new Chart();
chart1.Import.Template.Load(fileName);
chart1.Export.Image.PNG.Save("teechart.png");
Console.WriteLine($"Chart saved as {fileName}");
}
}