Page 1 of 1

Save Marks text

Posted: Wed May 13, 2015 9:58 am
by 16571512
Hello,

I use TChart and TSeries for some acquisition of data during a time.

I want to draw marks on some points I have on my series which match with a certain time.

I use the event TSeriesGetMarkText to make visible (MarkText:='Text') or not (MarkText:='') the marks depending on the time.

It works well but at the end, I save my chart in a stream file. When I open this file in an other chart, all marks are visible and the labels match with the YValues of the points.

How can I save the text and the index of the marks I put in the event TSeriesGetMarkText and open it in the right way in an other chart ?

Thanks in advance.

Benoît

Re: Save Marks text

Posted: Thu May 14, 2015 7:53 am
by yeray
Hello Benoît,

I'm afraid the exportation can store the design of the chart but not the code in the application.
Instead of using the TSeriesGetMarkText, you could populate the series' Labels array and the empty strings won't be shown. Here you have a simple example:

Code: Select all

uses Series, DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    tmpDate: TDateTime;
    str: string;
begin
  Chart1.Legend.Visible:=false;

  with Chart1.AddSeries(TPointSeries) as TPointSeries do
  begin
    XValues.DateTime:=true;

    for i:=0 to 9 do
    begin
      str:='';
      tmpDate:=Today+i;

      if (i mod 4 = 0) then
        str:='point ' + IntToStr(i);

      AddXY(tmpDate, 25+random*75, str);
    end;

    Marks.Visible:=true;
    Marks.Style:=smsLabel;
  end;

  Chart1.Axes.Bottom.LabelStyle:=talValue;
end;

Re: Save Marks text

Posted: Mon May 18, 2015 2:58 pm
by 16571512
Hello Yeray,

Thanks for your solution, it seems to work well !

Benoît