Page 1 of 1

Persistent Graph Settings

Posted: Tue Feb 22, 2022 4:08 pm
by 20092400
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.

Re: Persistent Graph Settings

Posted: Wed Feb 23, 2022 8:54 am
by Christopher
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.

Re: Persistent Graph Settings

Posted: Fri Feb 25, 2022 10:02 am
by 20092400
Hi

The application hosting the TeeChart control is:

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

Thanks.

Re: Persistent Graph Settings

Posted: Fri Feb 25, 2022 11:39 am
by Christopher
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.

Re: Persistent Graph Settings

Posted: Thu Mar 17, 2022 9:09 am
by 20092400
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?

Re: Persistent Graph Settings

Posted: Thu Mar 17, 2022 10:26 am
by Christopher
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 5337 times
I have added this issue to our issue-tracking software with id=2514, meaning that a fix to it will become available shortly.