Offset between data and axis in TColorGridSeries with CenteredPoints

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MDL
Newbie
Newbie
Posts: 2
Joined: Wed May 26, 2021 12:00 am

Offset between data and axis in TColorGridSeries with CenteredPoints

Post by MDL » Thu Jan 13, 2022 10:28 am

Hi,

I am using TColorGridSeries with IrregularGrid:=True. We use CenteredPoints:=True. When the X axis steps are less than 1, there is an offset between the axis plotted and the data. I think this is related to http://www.teechart.net/support/viewtop ... 06&p=30478 and http://bugs.teechart.net/show_bug.cgi?id=841, but does not appear to be fixed in TeeChart VCL 2020.31. We have TeeChart Pro with source code.

The example below shows the expected behaviour when CenteredPoints:=False, but the data plotted is offset to the left compared to the axis when CenteredPoints:=True. From a brief test, it appears that 0.5 is subtracted from the data internally to implement the CenteredPoints plotting, which is incorrect if the X data step isn't 1.

Illustration:

Code: Select all

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VCLTee.TeeSurfa, VclTee.TeeGDIPlus,
  VCLTee.TeEngine, Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.TeeConst;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Chart2: TChart;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
    x, z, plotVal: Integer;
    Series1: TColorGridSeries;
    Series2: TColorGridSeries;
begin
  Series1:=TColorGridSeries.Create(Self);
  Series1.IrregularGrid:=True;
  Series1.CenteredPoints:=True;
  // With CenteredPoints enabled, the resulting plot is offset compared to the
  // axis. It seems as if internally, 0.5 is subtracted from the X value for
  // CenteredPoints:=True, which is fine if the X spacing is 1, but not otherwise
  // See http://www.teechart.net/support/viewtopic.php?f=4&t=7706&p=30478
  Chart1.Title.Clear;
  Chart1.Title.Text.Add('CenteredPoints:=True, X from 0 to 10 in 0.25 steps');
  Chart1.Title.Text.Add('Version: ' + TeeChartVersion + TeeVCLMinorVersion);
  Chart1.Title.Text.Add('Build: ' + TeeVCLBuildVersion);
  Chart1.View3D := False;
  Chart1.AddSeries(Series1);

  Series2:=TColorGridSeries.Create(Self);
  Series2.IrregularGrid:=True;
  Series2.CenteredPoints:=False;
  // With CenteredPoints disabled, the plot is as expected
  Chart2.Title.Clear;
  Chart2.Title.Text.Add('CenteredPoints:=False, X from 0 to 10 in 0.25 steps');
  Chart2.View3D := False;
  Chart2.AddSeries(Series2);

  for x:=0 to 40 do
    begin
    for z:=-10 to 10 do
      begin
      plotVal := x+z; //Any data to plot
      Series1.AddXYZ(x*0.25, plotVal, z);
      Series2.AddXYZ(x*0.25, plotVal, z);
      end;
    end;
end;

end.
Attachments
AxisOffset.png
AxisOffset.png (26.81 KiB) Viewed 1099 times

Yeray
Site Admin
Site Admin
Posts: 9138
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Offset between data and axis in TColorGridSeries with CenteredPoints

Post by Yeray » Thu Jan 20, 2022 10:22 am

Hello,

I'm sorry for the late reply here.
For now I can confirm the issues you refer seem to be related.
We'll revise it in more depth as soon as possible.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9138
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Offset between data and axis in TColorGridSeries with CenteredPoints

Post by Yeray » Fri Jan 21, 2022 4:03 pm

Hello,

I've just fixed #841 for the next maintenance release which we'll be releasing soon.
This is how your example looks with it:
Project3_2022-01-21_17-01-13.png
Project3_2022-01-21_17-01-13.png (28.59 KiB) Viewed 1015 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

MDL
Newbie
Newbie
Posts: 2
Joined: Wed May 26, 2021 12:00 am

Re: Offset between data and axis in TColorGridSeries with CenteredPoints

Post by MDL » Fri Jan 21, 2022 7:12 pm

Many thanks.

Post Reply