A means of saving/loading chart properties?

With the AdvChartView VCL charts, there is a means of saving and loading the properties of a given chart.

Is there any way of achieving this with the FNC version - generate a stream of text that I can use to re-populate the chart again later? We'd like to allow our users access to the chart editor dialog to customise the look of the charts, but they'd want to save the chart settings so they could be applied again whenever the chart is reloaded (etc).

If not, can anyone suggest a work-around we might be able to use to let us do this? I can live with saved charts not necessarily being compatible with future versions of the component, at least for the time being. :-)

Hi, 


This feature is currently not supported, but you could use the following code to save the chart completely:

procedure TForm1.LoadChart;
var
  s: TFileStream;
begin
  s := TFileStream.Create('test.chart', fmOpenRead);
  try
    s.ReadComponent(TMSFNCChart1)
  finally
    s.Free;
  end;
end;

procedure TForm1.SaveChart;
var
  s: TFileStream;
begin
  s := TFileStream.Create('test.chart', fmCreate);
  try
    s.WriteComponent(TMSFNCChart1);
  finally
    s.Free;
  end;
end;

Thanks Pieter, really appreciate the quick reply. I have tried this, but when I try to reload the control I get an exception 'EClassNotFound' with message 'Class TTMSFNCChartEditorDialog not found.'


Do I need to decouple the relationships between chart and editor dialog before saving the chart, or before reloading the chart (etc)?  

It does seem to be repopulating at least some of the properties of the chart, it just seems to crash with this error during/at the end of the stream.read process.

Cheers
Rob

Can you perhaps send us your code that you are using to save the chart?

Oh it's me - I'm so sorry. I dropped an FNC chart and an FNC Chart Editor dialog onto a form for testing, I didn't realise the FNCChartEditorDialog had become a 'child' of the Chart on the FNC form. As soon as I made the Editor dialog a component of the form (instead of the chart), it's fine.


Sorry Pieter, my fault - thanks again for the suggestion. I had tried streaming the component out to a file but clearly my test project left something to be desired :-)
Thank you for your feedback.

Just as a side-note: The FNC version of non-visual components are actually visual components to avoid installation issues of multiple packages that share the same component name, therefore you were able to drop the component as a child of the chart.

Thanks Pieter, I understand why it did what it did now. Cheers :-)