home *** CD-ROM | disk | FTP | other *** search
/ PC Expert 29 / Pce29cd.iso / RUNIMAGE / DELPHI40 / DEMOS / TEECHART / UCOLOR.PAS < prev    next >
Pascal/Delphi Source File  |  1998-06-16  |  2KB  |  65 lines

  1. {****************************************}
  2. { TeeChart                               }
  3. { TColoredForm Example                   }
  4. { Copyright (c) 1995,96 by David Berneda }
  5. {    All Rights Reserved                 }
  6. {****************************************}
  7. unit ucolor;
  8.  
  9. interface
  10.  
  11. uses
  12.   Wintypes,WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13.   Teengine, Series, ExtCtrls, Chart, StdCtrls, Buttons, teeprocs;
  14.  
  15. type
  16.   TColoredForm = class(TForm)
  17.     Chart1: TChart;
  18.     Panel1: TPanel;
  19.     CheckBox1: TCheckBox;
  20.     BitBtn2: TBitBtn;
  21.     LineSeries1: TLineSeries;
  22.     PointSeries1: TPointSeries;
  23.     Memo1: TMemo;
  24.     procedure FormCreate(Sender: TObject);
  25.     procedure CheckBox1Click(Sender: TObject);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. implementation
  33.  
  34. {$R *.DFM}
  35.  
  36. procedure TColoredForm.FormCreate(Sender: TObject);
  37.  
  38.   Procedure AddColors(Series:TChartSeries);
  39.   var step:Double;
  40.       t:Longint;
  41.   begin
  42.     With Series,GetVertAxis do
  43.     begin
  44.       step:=(Maximum-Minimum)/10.0;
  45.       for t:=0 to Count-1 do
  46.           ValueColor[t]:=GetDefaultColor( Trunc((YValue[t]-Minimum)/step) );
  47.     end;
  48.   end;
  49.  
  50. begin
  51.   LineSeries1.FillSampleValues(100);
  52.   PointSeries1.FillSampleValues(100);
  53.   Chart1.LeftAxis.AdjustMaxMin;
  54.   AddColors(LineSeries1);
  55.   AddColors(PointSeries1);
  56. end;
  57.  
  58. procedure TColoredForm.CheckBox1Click(Sender: TObject);
  59. begin
  60.   Chart1.LeftAxis.Inverted:=CheckBox1.Checked;
  61. end;
  62.  
  63.  
  64. end.
  65.