Forum > TAChart

[SOLVED] Combined pointer style

<< < (2/3) > >>

wp:

--- Quote from: CM630 on March 19, 2024, 08:49:11 am ---The pen style for the pointers is psDashDot, but as seen from the screenshot, the lines are solid...

--- End quote ---
Cannot reproduce this - see attachment. Please post a small project so that I can see what you are doing.

CM630:
Now I cannot reproduce it neither  %)
Hopefully I was mistaken and it is not a sporadic bug.

Meanwhile I noticed that the size of the pointer is equal to HorizSize ยท 2 + 1.
I suppose that this is the intended behaviour.



CM630:
Something seems wrong (a snippet is attached).
When executing the code this way everything is fine - an empty circle is drawn.
But if I uncomment //aPointer.Pen.Color := clRed; the circle is not empty anymore.
If the style is psRectangle, then the rectangle is empty in both cases, which seems to me as the expected behaviour.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Chart1LineSeries1CustomDrawPointer(ASender: TChartSeries; ADrawer: IChartDrawer; AIndex: Integer; ACenter: TPoint);var  aPointer:  TSeriesPointer;begin  aPointer := TSeriesPointer.Create(nil);//  aPointer.Pen.Color := clRed;  aPointer.Brush.Style := bsClear;  aPointer.VertSize := 20;  aPointer.HorizSize := 20;  aPointer.Style := psCircle {psRectangle};  try    aPointer.Draw(ADrawer,ACenter,aPointer.Pen.Color);  finally    aPointer.Free;  end;end;  

Some more info: While //  aPointer.Pen.Color := clRed; is still commented, I changed aPointer.Draw(ADrawer,ACenter,aPointer.Pen.Color); to aPointer.Draw(ADrawer,ACenter,clRed); And I get a filled circle again.


(Lazarus 3.2 (rev lazarus_3_2) FPC 3.2.2 x86_64-win64-win32/win64)

wp:
Although the code looks relatively simple the TSeriesPointer.Draw(Size) considers many parameters. One of them is the OverrideColor property of the pointer. This is a set with the possible elements ocBrush and ocPen and defaults to [ocBrush]. It means that the color specified in the Pointer.Draw(Size) method overrides the previously set brush or pen color when then corresponding element is contained in the OverrideColor property. (And note that it is a feature of the LCL that setting the brush's color automatically switches the brush.Style to bsSolid; colors should always be changed before setting the style)

In other words, when you call "aPointer.Draw(ADrawer,ACenter, aPointer.Pen.Color)" with in the default pointer setting, the color in the third parameter (aPointer.Pen.Color=clRed) will be used for drawing the pointer's fill (because OverrideColor is [ocBrush]); the previously set aPointer.Brush.Style=bsClear is ignored.

When you switch OverrideColor to an empty set, [], the override mechanism is deactivated, and the previously selected brush of the pointer is used (Brush.Style = bsClear).

When you switch OverrideColor to [ocPen] and call "aPointer.Draw(ADrawer,ACenter, clBlue)" you will have a blue-bordered empty circle although the pen.color has been set to clRed before.

I think that all this is as expected.

CM630:
Thanks, this code seems to work for me (the inner and the outer colours are the same, which is what I need):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Chart1LineSeries1CustomDrawPointer(ASender: TChartSeries; ADrawer: IChartDrawer; AIndex: Integer; ACenter: TPoint);var  aPointer:  TSeriesPointer;  EmptyPointer: Boolean = True; //Change value according necessitiesbegin  aPointer := TSeriesPointer.Create(nil);  aPointer.Brush.Style := bsClear;  aPointer.VertSize := 20;  aPointer.HorizSize := 20;  //Uncomment whish is necessary  aPointer.Style := psCircle;  //aPointer.Style := psRectangle;  //aPointer.Style := psDiamond;  if EmptyPointer then  begin    aPointer.OverrideColor:= [ocPen];    aPointer.Brush.Style:=bsClear;  end  else  begin    aPointer.OverrideColor:= [ocBrush,ocPen];    aPointer.Brush.Style:=bsSolid;  end;  try    aPointer.Draw(ADrawer,ACenter,clRed);  finally    aPointer.Free;  end;end;
Actually aPointer.OverrideColor:=[***]; is needed only for the circle. Diamond and rectangle do not need it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version