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).