Page 1 of 1

More advanced Schemes

Posted: Mon Apr 19, 2004 2:07 pm
by 9336918
Hi,

Tis me again

The schemes change colours and backgrounds beautifully BUT not the title fonts. How do you edit the schemes especially the titles please?

Thanking you

Morton

Posted: Mon Apr 19, 2004 8:32 pm
by Marjan
Hi, Morton.

All you have to do is define any additional chart properties you want to change in your theme Apply method. Here is part of the TWebTheme.Apply implementation:

Code: Select all

procedure TWebTheme.Apply;
Const clDarkSilver=$C4C4C4;
      WebFont='Lucida Console';
var t : Integer;
begin
  inherited;

  Chart.BevelInner:=bvNone;
  Chart.BevelOuter:=bvNone;

  Chart.Border.Visible:=True;
  Chart.BorderRound:=0;
  Chart.Border.Width:=1;
  Chart.Border.Color:=clBlack;

  Chart.Gradient.Visible:=False;
  // ...
If you want to change chart Title properties, you derive new theme from your current theme and add the following lines in the Apply method (just an example):

Code: Select all

procedure TYourTheme.Apply;
begin
  inherited;
  with Chart.Title do
  begin
    Font.Name:='Arial';
    Font.Size:=10;
    Font.Color:=clNavy;
    Font.Style:=[fsBold];
  end;
end;
Also, check the theme examples in Teechart demo. They should give you some additional tips on how to build custom chart themes.

Posted: Wed Apr 21, 2004 9:03 am
by 9336918
Many thanks BUT... How can I apply this to an EXISTING theme.

1. Being each theme now has a changed title font each say excel has a large one, blues a small one ands so on...

2. A global font for all the titles that the themes don't override - so you set the font opnce and any theme you choose keeps the same title font.

3. The final thought is how does one do all this create a brand new theme... based on say the Excel one and call it Excel2 or from scratch...

Thanking you again

Morton

Posted: Fri Apr 23, 2004 4:49 am
by Marjan
Hi, Morton.

If you have TeeChart source code, you can add relevant parts to theme Apply method. Or alternatively (much better) derive new theme from your existing theme, inherit it's Apply method and add additional properies you want to set. The code is really simple:

Code: Select all

TMyTheme = class( TExcelTheme)
public
  procedure Apply; override;
  class function Description:String; override;
end;

procedure TMyTHeme.Apply;
begin
  inherited;
  with Chart.Title do 
  begin 
    Font.Name:='Arial'; 
    Font.Size:=10; 
    Font.Color:=clNavy; 
    Font.Style:=[fsBold]; 
  end; 
end;

function TMyTheme.Description: string;
begin
  result:='My custom theme';
end;

initialization 
RegisterChartThemes([ TMyTheme ]);
Now the TMyTheme will inherit all TExcelTheme properties + add your own. Of course, you can also derive directly from TChartTheme and fully customize everything in the Apply method implementation.
I hope this will help you in deriving and using new custom theme.