* * *

Author Topic: Marks AtDataOnly  (Read 881 times)

kapibara

  • Sr. Member
  • ****
  • Posts: 460
Marks AtDataOnly
« on: January 28, 2017, 02:54:44 am »
If BottomAxis.Marks.AtDataOnly is True, then only the last one of the 3 added days gets a visible label. Isn't that a bit odd?
Style of Marks is set to smsLabel, and BottomAxis.Marks.Source is set to Source of the actual series as you can see in code below.

Code: Pascal  [Select]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   ylist: array[0..3] of Double;
  4. begin
  5.   Chart1.BottomAxis.Marks.Source := Chart1OpenHighLowCloseSeries1.Source;
  6.   Chart1.BottomAxis.Marks.Style := smsLabel;
  7.   Chart1.BottomAxis.Marks.AtDataOnly:=True;
  8.   ylist[0]:=20;  //Low
  9.   ylist[1]:=20;  //Open
  10.   ylist[2]:=25;  //Close
  11.   ylist[3]:=25;  //High
  12.   lcsData.AddXYList(1, ylist, 'Day 1');
  13.   lcsData.AddXYList(2, ylist, 'Day 2');
  14.   lcsData.AddXYList(3, ylist, 'Day 3');
  15. end;

Sample attached
(Latest Lazarus trunk)
Lazarus trunk / fpc 3.0 / Debian Stretch 64-bit

wp

  • Hero Member
  • *****
  • Posts: 3743
Re: Marks AtDataOnly
« Reply #1 on: January 28, 2017, 01:56:39 pm »
Thanks for the example - this helps a lot!

Basically your problem is due to a "misuse" of the Marks.AtDataOnly: This feature is intended for "paned" charts where several axes are overlayed at the same side of the chart, and where an AutoscaleAxisTransformation shifts the related axis ranges such that the corresponding series do not overlap. Setting Marks.AtDataOnly to true here makes sure that labels are drawn only within the range of the related series. -- See attached demo for "correct" usage (it is available in the folder demo/panes-3 of TAChart now as well).

In your particular case, setting Marks.AtDataOnly in the normal case of a non-paned chart leads to the described issue because you did not assign an AxisIndexY to the series. This way the axis cannot determine the range of the data assigned to it.

Fortunately I found an easy fix, and this is in r54023 now. Since it is more or less a bug it will be backported to Laz 1.6.4. Please test and tell me if if fixes your issue.
Lazarus trunk / fpc 3.0.0 / Win32

kapibara

  • Sr. Member
  • ****
  • Posts: 460
Re: Marks AtDataOnly
« Reply #2 on: January 29, 2017, 06:21:01 am »
It works fine now, thanks wp!
« Last Edit: January 29, 2017, 06:23:30 am by kapibara »
Lazarus trunk / fpc 3.0 / Debian Stretch 64-bit

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus