Teechart .NET 4.2024.11.14 - Import/Export from/to .ten format doesn't work as expected

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
harithav
Newbie
Newbie
Posts: 1
Joined: Fri Jul 05, 2024 12:00 am

Teechart .NET 4.2024.11.14 - Import/Export from/to .ten format doesn't work as expected

Post by harithav » Fri Nov 22, 2024 8:52 am

Teechart .NET Pro - 4.2024.11.14

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}");
    }
}
Attachments
teechart_ten_importexport.png
teechart_ten_importexport.png (1.67 KiB) Viewed 2583 times
teechart_image_export.png
teechart_image_export.png (15.86 KiB) Viewed 2583 times

Edu
Newbie
Newbie
Posts: 40
Joined: Tue Nov 28, 2023 12:00 am

Re: Teechart .NET 4.2024.11.14 - Import/Export from/to .ten format doesn't work as expected

Post by Edu » Mon Nov 25, 2024 9:55 am

Hello:

From a console application, please use the class TChart to access Export functionality. While the class 'Chart' does the job with UI Frameworks like Winforms, it is limited when it comes to console apps.

Here's how the code would look like, following the code you provided, instead of "Chart chart1 = ...".

Code: Select all

            //suggested code
            TChart chart2 = new TChart();
            chart2.Import.Template.Load(fileName);
            chart2.Export.Image.PNG.Save("Chart2.png");
If there's anything else I can help you with, please let me know!
Regards,
Edu
Edu
Steema Support

Post Reply