Page 1 of 1

Highlighting Results

Posted: Wed Sep 13, 2006 4:04 pm
by 9337074
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?

Posted: Thu Sep 14, 2006 10:34 am
by narcis
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;

Posted: Thu Sep 14, 2006 8:26 pm
by 9337074
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?

Posted: Fri Sep 15, 2006 7:20 am
by narcis
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;