Page 1 of 1

PrepareCanvas should called after OnGetPointerStyle function

Posted: Mon Nov 06, 2006 4:41 pm
by 8571714
Hello,

in TCustomSeries.DrawPointer:

OnGetPointerStyle function determines pointer style. But, it is possible to do more. For example, pointer.color,..

//I want to change both color and pointer.style

function Tfrm_graph.SeriesGetPointerStyle(Sender: TChartSeries;
ValueIndex: Integer): TSeriesPointerStyle;
begin
if odd(ValueIndex) then
begin
result:=psCircle ;
sender.pointer.color:=clred;

end
else
begin
sender.pointer.color:=clblue;
result:=psCircle;
end;


end;

I changed in series.pas as below:

Procedure TCustomSeries.DrawPointer(AX,AY:Integer; AColor:TColor; ValueIndex:Integer);
var tmpStyle : TSeriesPointerStyle;
begin
if Assigned(FOnGetPointerStyle) then tmpStyle:=FOnGetPointerStyle(Self,ValueIndex)
else tmpStyle:=Pointer.Style;
Pointer.PrepareCanvas(ParentChart.Canvas,AColor);
Pointer.Draw(AX,AY,AColor,tmpStyle);
end;

Posted: Tue Nov 07, 2006 3:30 pm
by narcis
Hello fnn,

Thanks for the suggestion, we changed this for v8, which is the version we are currently working with. The change is in Series.pas:

Code: Select all

Procedure TCustomSeries.DrawPointer(AX,AY:Integer; AColor:TColor; ValueIndex:Integer); var tmpStyle : TSeriesPointerStyle; begin
  // Set canvas properties to Pointer (Brush, Color, Pen)
  Pointer.PrepareCanvas(ParentChart.Canvas,AColor);

  // Call the OnGetPointerStyle event if assigned.
  tmpStyle:=DoGetPointerStyle(ValueIndex);

  // Repeat again setting Canvas parameters, thus allowing the developer
  // to use the OnGetPointerStyle event to modify other Pointer properties
  // like Color, Pen, etc.
  if Assigned(FOnGetPointerStyle) then
     Pointer.PrepareCanvas(ParentChart.Canvas,AColor);

  Pointer.Draw(AX,AY,AColor,tmpStyle);
end;
If you are interested in beta-testing v8 please read this.