home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / EXTENDED / UMARKS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  1.8 KB  |  75 lines

  1. unit Umarks;
  2. {$P-}  { <-- Delphi 1.0 compatibility when using OnGetMarkText }
  3.  
  4. interface
  5.  
  6. { This example shows how to customize Series Marks.
  7.   The OnGetMarkText event is used to supply custom text for Marks.
  8. }
  9. uses
  10.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  11.   Forms, Dialogs, TeEngine, Series, StdCtrls, ExtCtrls, Buttons, TeeProcs,
  12.   Chart;
  13.  
  14. type
  15.   TCustomMarksForm = class(TForm)
  16.     Chart1: TChart;
  17.     BitBtn1: TBitBtn;
  18.     RadioGroup1: TRadioGroup;
  19.     Series1: TPieSeries;
  20.     procedure BitBtn1Click(Sender: TObject);
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure Series1GetMarkText(Sender: TChartSeries; ValueIndex: Integer;
  23.       var MarkText: String);
  24.     procedure RadioGroup1Click(Sender: TObject);
  25.   private
  26.     { Private declarations }
  27.   public
  28.     { Public declarations }
  29.   end;
  30.  
  31. var
  32.   CustomMarksForm: TCustomMarksForm;
  33.  
  34. implementation
  35.  
  36. {$R *.DFM}
  37.  
  38. procedure TCustomMarksForm.BitBtn1Click(Sender: TObject);
  39. begin
  40.   Close;
  41. end;
  42.  
  43. procedure TCustomMarksForm.FormCreate(Sender: TObject);
  44. begin
  45.   Series1.FillSampleValues(8);
  46. end;
  47.  
  48. { This event does the conversion... }
  49. procedure TCustomMarksForm.Series1GetMarkText(Sender: TChartSeries;
  50.   ValueIndex: Integer; var MarkText: String);
  51. begin
  52.   if RadioGroup1.ItemIndex=0 then
  53.   begin
  54.     { example: change the mark text }
  55.     MarkText:='This is: '+Sender.XLabel[ValueIndex];
  56.  
  57.     { example: hide specific marks }
  58.     if ValueIndex<3 then MarkText:='';
  59.  
  60.     { example: change Marks Font style for specific marks }
  61.     if ValueIndex>5 then
  62.        Sender.Marks.Font.Style:=[fsBold]
  63.     else
  64.        Sender.Marks.Font.Style:=[];
  65.   end;
  66. end;
  67.  
  68. procedure TCustomMarksForm.RadioGroup1Click(Sender: TObject);
  69. begin
  70.   Series1.Marks.Font.Style:=[];
  71.   Chart1.Repaint;  { <-- force repaint }
  72. end;
  73.  
  74. end.
  75.