Highlighting Results

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Highlighting Results

Post by McMClark » Wed Sep 13, 2006 4:04 pm

I am using Delphi 2006 to create charts with TeeChart 7.07. I have a simple line chart that plots numbers on the Y axis and dates on the X axis. The numbers on the Y axis represents the mode of a list of values collected on a particular date. I want to add to the chart some indication when the number of values reviewed for the particular date fall below a certain threshold. For example, if I have 5 dates and all the dates but one have a set of values above 10 items. I want the chart to give some indication of the Y value that came from the set of values with fewer then 10 items. Can someone suggest a solution?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Sep 14, 2006 10:34 am

Hi McMClark,

You have several options here. In the code snippet below I show how to change the series pointer color and adding an annotation tool for points that fall into a certain rule.

Code: Select all

uses TeeTools;

function TForm1.Series1GetPointerStyle(Sender: TChartSeries;
  ValueIndex: Integer): TSeriesPointerStyle;
begin

  if Series1.YValues[ValueIndex+1] > 100 then
  begin
    Series1.Pointer.Color:=clRed;

    Chart1.Tools.Add(TAnnotationTool.Create(self));
    With (Chart1.Tools.Items[Chart1.Tools.Count-1] as TAnnotationTool) do
    begin
      Text:='Special point';
      Shape.CustomPosition:=true;
      Shape.Left:=Chart1.Axes.Bottom.CalcXPosValue(Series1.XValue[ValueIndex+1]);
      Shape.Top:=Chart1.Axes.Left.CalcYPosValue(Series1.YValue[ValueIndex+1]);
    end;

    end;
  end
  else
    Series1.Pointer.Color:=clBlue;

  result:=psRectangle;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Post by McMClark » Thu Sep 14, 2006 8:26 pm

Thanks.

I am using the following code to call the event because I am adding series at runtime.

procedure TForm1.UpdateChart();
Var
intList: integer;
tmpLineSeries: TLineSeries;

begin
tmpLineSeries := TLineSeries.Create(self);
DBChart1.AddSeries(tmpLineSeries);
DBChart1.Legend.Visible := True;
DBChart1.Legend.CheckBoxes := True;
With tmpLineSeries do
Begin
DataSource:= TempResults_Query1;
YValues.ValueSource := 'Score';
XLabelsSource := 'PublicationDate';
XValues.ValueSource := 'PublicationDate';
XValues.DateTime := True;
Pointer.Visible := True;
Title := strSubject;
tmpLineSeries.ColorEachPoint := False;
DBChart1.AutoRefresh := True;
OnGetPointerStyle:=Series1GetPointerStyle;
end;
DBChart1.Draw;
end;

I tried to make one change to the code you provided. I replaced the Series1 with Sender. But in the Series1GetPointerStyle event it does not recognize the Sender as having the Pointer property. Can you tell me what I am doing wrong?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Sep 15, 2006 7:20 am

Hi McMClark,

This is because Sender is a variable of type TChartSeries, the generic series type. For the Pointer property to be recognise you'll have to type cast the parameter, for example:

Code: Select all

(Sender as TLineSeries).Pointer.Color:=clTeeColor;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply