newbie question about TAChart and TPlotPanel lazarus / 55-TAChart ---------------------------------------------------------------------- numero · 2015-10-25 05:49 I am a newbie to TAChart, and I was wondering if anyone had experiences in how it can draw circles. That is, of the mathematical kind, on a Cartesian plane. I am currently using TPlotPanel which according to what I have been reading, appears to be deprecated. While I would like to have my plotting done using more well-maintained objects, I have had some success in using TPlotPanel except that circles don't usually render well in the early and late stages of plotting. If anyone has ever tried this on TAChart, and would like to share experiences, I would like to hear back. ---------------------------------------------------------------------- wp · 2015-10-25 12:18 You should provide more information on what you want to achieve. What are these circles for? Data point symbols? Or does their radius contain a value (bubble series)? ---------------------------------------------------------------------- numero · 2015-10-25 13:04 Quote from: wp on October 25, 2015, 01:18:09 pmYou should provide more information on what you want to achieve. What are these circles for? Data point symbols? Or does their radius contain a value (bubble series)? I am trying to generate any circle of any radius given any three noncollinear points, and plot that circle on a Cartesian plane. I was just wondering if it was worth my while to port my code over to TAChart, since the circles under TPlotPanel have noticeable gaps, which appear to be due to resolution problems. This is true even when setting PlotMode to pmLine using TPlotPanel. So far, one advantage of TPlotPanel is that I don't need arrays to plot points, and TAChart appears to be more data-driven, which I don't really need. The attached screenshot illustrates the "gap" problem with TPlotPanel. The line leading to the centre of the circle is intentional. Just wondering if anyone had better luck with TAChart, and is it worth my while to port my code to it. ---------------------------------------------------------------------- wp · 2015-10-25 14:03 Do you need the axes? If not why don't you use a simple TShape control setting its "Shape" property to stCircle? Units are in pixels, though, and y is going down from the top. Or you could use a TPaintbox on which you can paint anything using its OnPaint event. You can get a circle at xc,yc and radius r (all in pixels) by 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 procedure TForm1.PaintboxPaint(Sender: TObject);var  xc, yc, r: Integer;  x0, y0: Integer;begin  r := 150;  // Radius 150 pixels  xc := Paintbox1.Width div 2;  // circle center in center of paintbox  yc := Paintbox1.Height div 2;  x0 := xc - r;  //  left-top corner of the bounding box of the circle  y0 := yc - r;   // Prepare painting parameters  Paintbox1.Canvas.Pen.Style := psSolid;  // red solid circle  Paintbox1.Canvas.Pen.Color := clRed;  Paintbox1.Canvas.Brush.Style := bsClear;  // not filled by any color   // Draw an ellipse.  // To get a circle make width and height of the bounding box equal.  Paintbox1.Canvas.Ellipse(x0, y0, x0 + 2*r, y0 + 2*r); end; ---------------------------------------------------------------------- numero · 2015-10-25 14:18 Using TShape and TPaintBox is unsatisfactory. I need the axes, because I am using points to generate a circle on the Cartesian Plane from three arbitrary points. That means: 1) I need a Cartesian plane (with a grid and axes, the kind with numbers on them), and 2) I need to draw the circle in the correct position on the Cartesian plane. I am generating the circle from an equation that was programatically derived from the three noncollinear points supplied by the user. The centre is computed from perpendicular bisectors of the three arbitrary points. I want to see the circle pass through the correct points on the cartesian plane, and I want to see the centre in the correct position on the cartesian plane. Thanks for your help so far. ---------------------------------------------------------------------- wp · 2015-10-25 14:45 OK, then use a TChart. But  set its property "Proportional" to true to get the same axis scale on both axes. Add a TLineSeries to the chart. Add the three points to the series which define your circle (see code below). To see only the points set its "ShowPoints" to true, and the "LineType" to "ltNone". Select some decent marker for the points from the "Pointer.Style" dropdown. Use the object inspector for these adjustments. Calculate center and radius of the circle runnint through these points. Let's denote them xc, yc and r. To draw the circle add a TBubbleSeries. Add a single data point to this series - again see code below. To avoid filling the circle by some color set the "BubbleBrush.Style" to "bsClear". So, in total you have this procedure to draw the points and the circle: 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  ..., TAChartUtils, TAGeometry, ...;  // for TDoublePoint and DoublePoint() procedure TForm1.DrawCircleThroughPoints(P1,P2,P3: TDoublePoint);var  xc, yc, r: Double;begin  // Define and draw the three anchor points  Chart1LineSeries1.Clear;  Chart1LineSeries1.AddXY(p1.x, p1.y);  Chart1LineSeries1.AddXY(p2.x, p2.y);  Chart1LineSeries1.AddXY(p3.x, p3.y);   // Calculate the center and radius of the circle here...  xc := ...  yc := ...  r := ...   // Define and draw circle  Chart1BubbleSeries1.Clear;  Chart1BubbleSeries1.AddXY(xc, yc, r);end; ---------------------------------------------------------------------- numero · 2015-10-25 23:18 Looks interesting. Thanks.