Offset between data and axis in TColorGridSeries with CenteredPoints
Posted: 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:
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.