Page 1 of 1

TSeriesPointer Questions

Posted: Mon Jun 07, 2010 2:39 pm
by 16555616
Hello,

I am using TeeeChart v8.06 Pro and Delphi 2010. I'm about to start a new chart project, and I have a few questions about TSeriesPointer. They are:

1. Can the size of the pointer symbol be set per datapoint, or does the size of a TSeriesPointer apply to the whole series?
2. Can custom symbols be used instead of the TSeriesPointerStyle symbols provided?
3. Should the size, pointer style and color be set when adding data points to the series or is there a better way to set those properties?

Thanks!!

-erzsebet

Re: TSeriesPointer Questions

Posted: Tue Jun 08, 2010 9:25 am
by yeray
Hi erzsebet,
erzsebet wrote:1. Can the size of the pointer symbol be set per datapoint, or does the size of a TSeriesPointer apply to the whole series?
It applies to the whole series, but you can use OnGetPointerStyle to modify this the pointer properties before each them are drawn. For example:

Code: Select all

uses series;

var point1: TPointSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  point1:=Chart1.AddSeries(TPointSeries) as TPointSeries;
  point1.FillSampleValues();

  point1.OnGetPointerStyle:=Series1GetPointerStyle;
end;

function TForm1.Series1GetPointerStyle(Sender: TChartSeries; ValueIndex: Integer): TSeriesPointerStyle;
begin
  with Sender as TPointSeries do
  begin
    Pointer.Size:=(ValueIndex mod 5) + 3;
    Result:=psRectangle;
  end;
end;
erzsebet wrote:2. Can custom symbols be used instead of the TSeriesPointerStyle symbols provided?
A. If you are a source code customer, you can add a TSeriesPointerStyle in TeEngine.pas, for example a psCustom:

Code: Select all

  TSeriesPointerStyle=( psRectangle,psCircle,psTriangle,psDownTriangle,
                        psCross,psDiagCross,psStar,psDiamond,psSmallDot,
                        psNothing,psLeftTriangle,psRightTriangle,
                        psHexagon,psVisual, psCustom );
Then, you could modify the method TSeriesPointer.DrawPointer, also in TeEngine.pas and add cour custom drawing there:

Code: Select all

Procedure TSeriesPointer.DrawPointer( ACanvas:TCanvas3D; Is3D:Boolean; px,py,tmpHoriz,tmpVert:Integer; ColorValue:TColor; AStyle:TSeriesPointerStyle);
//...
case AStyle of
//...
psCustom: Line(px-5,py,px+5,py);
B. If you are not a source customer, you could set the pointer style to psNothing and draw your pointers directly at

Code: Select all

uses series, TeCanvas;

var point1: TPointSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  point1:=Chart1.AddSeries(TPointSeries) as TPointSeries;
  point1.FillSampleValues();

  point1.Pointer.Style:=psNothing;

  point1.OnGetPointerStyle:=Series1GetPointerStyle;
end;

function TForm1.Series1GetPointerStyle(Sender: TChartSeries; ValueIndex: Integer): TSeriesPointerStyle;
var px, py: Integer;
    tmpRect: TRect;
begin
  with Chart1.Axes do
    tmpRect:=Rect(Left.PosAxis, Left.IStartPos, Bottom.IEndPos, Bottom.PosAxis);

  with Sender as TPointSeries do
  begin
    px:=CalcXPos(ValueIndex);
    py:=CalcYPos(ValueIndex);
  end;

  if PointInRect(tmpRect, px, py) then
    Chart1.Canvas.Line(px-5, py, px+5, py);
end;
erzsebet wrote:3. Should the size, pointer style and color be set when adding data points to the series or is there a better way to set those properties?
The same as 1. The pointer properties are properties from the whole series, but you can change them at OnGetPointerStyle.
Furthermore, note that the color is stored in an array of colors, ValueColor. You can change a point color through it at any moment (and also at OnGetPointerStyle).

Re: TSeriesPointer Questions

Posted: Tue Jun 08, 2010 2:48 pm
by 16555616
Yeray, hi!

Thank you very much for answering my questions. I am a source code customer, so thanks for including the source code change options, too! Have a great day!

-erzsebet

Re: TSeriesPointer Questions

Posted: Tue Jun 08, 2010 3:43 pm
by yeray
Hi erzsebet,

You're welcome! And have a nice one you too! :D