Persistent Graph Settings

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
20092400
Newbie
Newbie
Posts: 3
Joined: Mon Nov 15, 2021 12:00 am

Persistent Graph Settings

Post by 20092400 » Tue Feb 22, 2022 4:08 pm

Hi
I am using the charting tool with good success and is proving quite responsive in our applications. This particular
piece of work is using the 3D chart.

I'm trying to save the graph settings between the applications use - Start the app, display some data and make some manual tweaks to axis settings, view the data and close the application.

When the application is run again I want the settings made on the previous run to applied.

My current attempt is to save out the settings to file once the user has made the edits. And similarly when the app is
started any settings are loaded from the saved file. The code I'm using is:

DialogResult res = ChartEditor.ShowModal();
if (res == DialogResult.OK)
Chart.Export.Template.Save(ChartSettingFileName);

It has some success but something isn't right. On restoring the settings the graph the axis ranges are correct but the data does not show.

Is the above code the correct way to achieve what I'm trying to do?

Any other pointers please?

DFB.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Persistent Graph Settings

Post by Christopher » Wed Feb 23, 2022 8:54 am

Hello,
Any other pointers please?
Yes, but first we need to know which version of TeeChart you are using, that is, which platform you are running on (.NET Framework 4, .NET 6.0, WinForm, WPF etc.) as serialization in each is slightly different.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

20092400
Newbie
Newbie
Posts: 3
Joined: Mon Nov 15, 2021 12:00 am

Re: Persistent Graph Settings

Post by 20092400 » Fri Feb 25, 2022 10:02 am

Hi

The application hosting the TeeChart control is:

.NET Framework 4.7.2
Windows Application (A desktop .exe)

Thanks.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Persistent Graph Settings

Post by Christopher » Fri Feb 25, 2022 11:39 am

Hello,
20092400 wrote:
Fri Feb 25, 2022 10:02 am
.NET Framework 4.7.2
Windows Application (A desktop .exe)
That's great, thank you. Attached a zip file containing a simple .NET Framework 4.x WinForm example of TeeChart. I hope it is of help.
Attachments
3DSerialization.zip
(15.15 KiB) Downloaded 491 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

20092400
Newbie
Newbie
Posts: 3
Joined: Mon Nov 15, 2021 12:00 am

Re: Persistent Graph Settings

Post by 20092400 » Thu Mar 17, 2022 9:09 am

Hi
Thanks for the code example but it does not help my situation.

The issue is still present in that the axes have no data values, they are set to 0.

1) Invoke the Teechart Editor.
2) With 'Left Axis' selectected uncheck 'Auto' and leave the values as they are.
3) Select close then close the chart which then calls the serialize code you've supplied.
4) Load the chart again and serialize the saved state from before.

The chart walls and one of the axes are present but two of the three axes show no data and are annotated with zero.

To get the chart back to its previous state each of the axes 'Auto' scale settings has to be set and values other than zero need to

be specified.

I can record all of this in a video if it makes it easier?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Persistent Graph Settings

Post by Christopher » Thu Mar 17, 2022 10:26 am

Hello,
20092400 wrote:
Thu Mar 17, 2022 9:09 am
I can record all of this in a video if it makes it easier?
No, I can see what you mean—certainly it's easier with a code example, and I can reproduce what I believe is your issue modifying the code I sent you slightly:

Code: Select all

    public Form1()
    {
      InitializeComponent();

      tChart1.Aspect.View3D = true;
      tChart1.Aspect.Zoom = 80;
      tChart1.Aspect.Orthogonal = false;
      tChart1.Aspect.Chart3DPercent = 100;
      tChart1.Tools.Add(typeof(Rotate));

      var surface = new Surface(tChart1.Chart);

      int count = 20;

      for (int x = 0; x < count; x++)
      {
        for (int z = 0; z < count; z++)
        {
          double y = Math.Cos(x) + Math.Sin(z);
          surface.Add(x, y, z);
        }
      }

      tChart1.Axes.Left.Automatic = false; //set left axis to Automatic false
    }

    private void button1_Click(object sender, EventArgs e)
    {
      using (var stream = new MemoryStream())
      {
        tChart1.Export.Template.IncludeData = true; //default setting
        tChart1.Export.Template.Save(stream);

        stream.Position = 0;
        tChart2.Import.Template.Load(stream);

       //to get the same chart back we have to set these both to true
        tChart2.Axes.Bottom.Automatic = true; 
        tChart2.Axes.Depth.Automatic = true;
      }
    }
Doing this gives me the same chart before and after the serialization, e.g.
Screenshot from 2022-03-17 11-17-31.png
Screenshot from 2022-03-17 11-17-31.png (119.45 KiB) Viewed 7100 times
I have added this issue to our issue-tracking software with id=2514, meaning that a fix to it will become available shortly.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply