Making node appear in front of lines
lazarus / 55-TAChart
----------------------------------------------------------------------
mtanner · 2018-07-26 06:44
I have a straightforward chart. It has a few TLineSeries, drawn by
\addplot. The I have a \node, to place some text on the chart. I
cannot find a way of making the node aooear in front of (on top of)
the lines. How can I do this?
----------------------------------------------------------------------
mtanner · 2018-07-26 07:11
Just an additional piece of info. The lines have pointers, and the
node appears in front of the line between the pointers but behind the
actual pointers.
----------------------------------------------------------------------
wp · 2018-07-26 08:49
What do you mean as "Node"? - there is no word "node" within TAChart,
and a "AddPlot" does not exist either.
Please upload a little demo showing the issue? Only lpi, lpr, pas and
lfm files packed to a common zip, no compiler-generated files, please.
----------------------------------------------------------------------
mtanner · 2018-07-26 09:06
Sorry!
My question relates to Latex/PGFPlots. I'm writing a Lazarus program
that displays a chart using TAChart, then can write a file containing
the LATEX/PGFPlots code for the same file for inclusion in a Latex
document.
Actually the \node PGFPlots command can do a lot of different things,
but in this context is displays some text at given graph coordinate
points. It will be my ignorance, but doing this within TAChart seems
to involve some complexity. A nice-to-have would be a builtin facility
in TAChart to do this. Maybe someone has written such a thing already?
----------------------------------------------------------------------
wp · 2018-07-26 09:44
You can draw any user-provided text in the OnAfterDraw event of the
chart using code like this:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i uses
TAGeometry, TAChartUtils; procedure TForm1.Chart1AfterDraw(ASender:
TChart; ADrawer: IChartDrawer);// This example assumes that the extent
of the chart has been set to XMin = -1, XMax = 1, YMin = -1, YMax =
1.var imgPt: TPoint;begin imgPt :=
Chart1.GraphToImage(DoublePoint(-0.9, 0.8));
ADrawer.TextOut.Text('Left-custified at
x=-0.9/y=0.8').Pos(imgPt).Done; imgPt :=
Chart1.GraphToImage(DoublePoint(-0.8, 0.0));
ADrawer.Textout.TextFormat(tfHTML).Text('bold, italic,
underlined').Pos(imgPt).Done;end;
----------------------------------------------------------------------
wp · 2018-07-26 10:26
Quote from: mtanner on July 26, 2018, 11:06:17 amSorry!
My question relates to Latex/PGFPlots. I'm writing a Lazarus program
that displays a chart using TAChart, then can write a file containing
the LATEX/PGFPlots code for the same file for inclusion in a Latex
document.
The most general way to do this would be to add a Latex drawer to
TAChart. This means you'd have to write a class, say TALaTeXDrawer as
"class(TBasicDrawer, IChartDrawer)" and implement the methods of
IChartDrawer:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
IChartDrawer = interface
['{6D8E5591-6788-4D2D-9FE6-596D5157C3C3}'] procedure
AddToFontOrientation(ADelta: Integer); procedure
ClippingStart(const AClipRect: TRect); procedure ClippingStart;
procedure ClippingStop; procedure DrawingBegin(const ABoundingBox:
TRect); procedure DrawingEnd; procedure DrawLineDepth(AX1, AY1,
AX2, AY2, ADepth: Integer); procedure DrawLineDepth(const AP1, AP2:
TPoint; ADepth: Integer); procedure Ellipse(AX1, AY1, AX2, AY2:
Integer); procedure FillRect(AX1, AY1, AX2, AY2: Integer);
function GetBrushColor: TChartColor; function GetFontAngle: Double;
// in radians function GetFontColor: TFPColor; function
GetFontName: String; function GetFontSize: Integer; function
GetFontStyle: TChartFontStyles; procedure
SetDoChartColorToFPColorFunc(AValue: TChartColorToFPColorFunc);
procedure Line(AX1, AY1, AX2, AY2: Integer); procedure Line(const
AP1, AP2: TPoint); procedure LineTo(AX, AY: Integer); procedure
LineTo(const AP: TPoint); procedure MoveTo(AX, AY: Integer);
procedure MoveTo(const AP: TPoint); procedure Polygon( const
APoints: array of TPoint; AStartIndex, ANumPts: Integer); procedure
Polyline( const APoints: array of TPoint; AStartIndex, ANumPts:
Integer); procedure PrepareSimplePen(AColor: TChartColor);
procedure PutImage(AX, AY: Integer; AImage: TFPCustomImage);
procedure PutPixel(AX, AY: Integer; AColor: TChartColor); procedure
RadialPie( AX1, AY1, AX2, AY2: Integer; AStartAngle16Deg,
AAngleLength16Deg: Integer); procedure Rectangle(const ARect:
TRect); procedure Rectangle(AX1, AY1, AX2, AY2: Integer);
procedure ResetFont; function Scale(ADistance: Integer): Integer;
procedure SetAntialiasingMode(AValue: TChartAntialiasingMode);
procedure SetBrushColor(AColor: TChartColor); procedure
SetBrush(ABrush: TFPCustomBrush); procedure SetBrushParams(AStyle:
TFPBrushStyle; AColor: TChartColor); procedure SetFont(AValue:
TFPCustomFont); procedure SetGetFontOrientationFunc(AValue:
TGetFontOrientationFunc); procedure SetMonochromeColor(AColor:
TChartColor); procedure SetPen(APen: TFPCustomPen); procedure
SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); function
GetRightToLeft: Boolean; procedure SetRightToLeft(AValue:
Boolean); procedure SetTransparency(ATransparency:
TChartTransparency); procedure SetXor(AXor: Boolean); function
TextExtent(const AText: String; ATextFormat: TChartTextFormat =
tfNormal): TPoint; function TextExtent(AText: TStrings;
ATextFormat: TChartTextFormat = tfNormal): TPoint; function
TextOut: TChartTextOut; property Brush: TFPCustomBrush write
SetBrush; property BrushColor: TChartColor read GetBrushColor write
SetBrushColor; property Font: TFPCustomFont write SetFont;
property Pen: TFPCustomPen write SetPen; property
DoChartColorToFPColor: TChartColorToFPColorFunc write
SetDoChartColorToFPColorFunc; property DoGetFontOrientation:
TGetFontOrientationFunc write SetGetFontOrientationFunc; end;
See TSVGDrawer (in TADrawerSVG) as an example.
If you have something ready in this direction I'd be happy to add it
to the official distribution.
----------------------------------------------------------------------
mtanner · 2018-08-18 07:27
Thanks for the suggestions. I think writing a Latex drawer is rather
beyond my skills and experience with Lazarus/TAGraph.