Page 1 of 1

TChart Editor save & restore custom themes

Posted: Mon Jul 11, 2022 7:36 pm
by 16591411
Hello,

We use the TChart editor to allow our users to change the theme as follows:

Code: Select all

Procedure TForm1.ChangeTheme;
var
  tmpClass:TChartThemeClass;
begin
  tmpClass:=TChartThemeClass(ChartThemeSelector(Chart));
  ChartThemeIndx := ChartThemes.IndexOf(tmpClass);
  //Save ChartThemeIndex
…
When The user executes the app again, we restore the theme as follows:

Code: Select all

  ApplyChartTheme(ChartThemes.Theme[ChartThemeIndx],Chart, -1);
This works well, but it does not work for Custom themes saved by the TChart Editor and the tmpClass is set to nil. (I was hoping the TChartThemeClass would include the custom themes.)

How do I record what custom setting was selected in the editor and then restore that custom setting? Is there a better way to record the selected custom and standard theme and then restore it?

Thanks,

Dave

Re: TChart Editor save & restore custom themes

Posted: Mon Jul 18, 2022 2:23 pm
by yeray

Re: TChart Editor save & restore custom themes

Posted: Wed Jul 20, 2022 12:54 pm
by 16591411
Hi Yeray,

Yes, I have read the article. Thanks.

What I am looking for is what custom theme was selected by the user in the TChart editor and then apply that theme to the chart. I could not find the answer to that question in the article you suggested, and this may be my lack of knowledge with TChart.

Thanks,

Dave

Re: TChart Editor save & restore custom themes

Posted: Tue Jul 26, 2022 6:22 am
by yeray
Hello Dave,

As described in that article, custom themes are useful to apply settings like font styles, colors and transparencies. If this is what you want to save and restore, you could save the theme as a chart (tee file) and load and apply it as a theme later.

If the settings you want to restore are more than what custom themes are able to, then I'm afraid custom themes won't be enough for you. In that case, you may want to manually import those extra properties you want to apply from your theme chart to your destination chart.