Author Topic: Adding Labels to points.  (Read 2164 times)


  • New Member
  • *
  • Posts: 19
Adding Labels to points.
« on: May 31, 2013, 07:21:26 am »
The Tutorial at

procedure TForm1.ChartToolset1DataPointClickTool1PointClick(
  ATool: TChartTool; APoint: TPoint);
  x, y: Double;
  with ATool as TDatapointClickTool do
    if (Series <> nil) then
      with (Series as TLineSeries) do begin
        x := GetXValue(PointIndex);
        y := GetYValue(PointIndex);
        { --- next line removed --- }
//        Statusbar1.SimpleText := Format('%s: x = %f, y = %f', [Title, x, y]);
        { --- next line added --- }
        ListSource.SetText(PointIndex, Format('x = %f'#13#10'y = %f', [x,y]));

does not compile under 1.0.8

There is no ListSource.SetText(). Was this tutorial written with an older version of the chart package or is this something added since the release of 1.0.8?

Using the 1.0.8 release is their a way of setting the text of a point after it has been added?


  • Hero Member
  • *****
  • Posts: 7232
Re: Adding Labels to points.
« Reply #1 on: May 31, 2013, 12:44:45 pm »
I tried to write the tutorials from the release version which was about 1.0 at this time. When using new features there should be a hint in the text.

In your case, obviously a later version, probably the trunk version, was used because the SetText method of the ListSource is a recent addition. However, the functionality has already been there even in the older versions since this method is just a short-cut for writing
Code: [Select]
  ListSource.Item[PointIndex]^.Text := 'some text';

[EDIT] You have to repaint the chart afterwards to show the changes immediately.

I'll modify the tutorial such that it compiles under older Lazarus versions (but proably not under 0.xx).
« Last Edit: May 31, 2013, 01:14:22 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10


  • New Member
  • *
  • Posts: 19
Re: Adding Labels to points.
« Reply #2 on: June 02, 2013, 06:30:43 am »

 ListSource.Item[PointIndex]^.Text := 'some text'

is what I needed.


TinyPortal © 2005-2018