Page 1 of 1

Simple Crossplot Bugs ?

Posted: Wed Oct 01, 2008 11:32 am
by 9339158
I have a couple of what looks like bugs in some simple crossplots. I am using Tchart pro 7.11 with Delphi 2007

Bugs are

Top plot the Y axis label overwrites the scale numbers. Only occurs when bottom number is a whole number. Scales can be anything so I have left on the auto scaling.

Image

Image

The two plots are the same just X and Y scales inverted. Note the brown data points are on top of blue, top graph and underneath bottom graph. Data has been put into the graphs exactly the same way, just switched X and Y. The correct result is the top one. The bottom graph has the Bottom Axis ‘Inverted’ option on so I can invert the scales. I do not want to invert the order the data is plotted.

Frank

Posted: Wed Oct 01, 2008 12:07 pm
by narcis
Hi Frank,
Top plot the Y axis label overwrites the scale numbers. Only occurs when bottom number is a whole number. Scales can be anything so I have left on the auto scaling.
Yes, this is a known issue. The solution was discussed here.
The two plots are the same just X and Y scales inverted. Note the brown data points are on top of blue, top graph and underneath bottom graph. Data has been put into the graphs exactly the same way, just switched X and Y. The correct result is the top one. The bottom graph has the Bottom Axis ‘Inverted’ option on so I can invert the scales. I do not want to invert the order the data is plotted.
I'm not able to reproduce the issue here using code below. Could you please modify the code snippet or send us a simple project we can run "as-is" so that we can reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i               : Integer;
    x0, y0, x1, y1  : Double;
begin
  Chart1.View3D:=false;
  Chart2.View3D:=false;

  Chart1.AddSeries(TPointSeries.Create(self));
  Chart1.AddSeries(TPointSeries.Create(self));
  Chart2.AddSeries(TPointSeries.Create(self));
  Chart2.AddSeries(TPointSeries.Create(self));

  Chart1[0].XValues.Order:=loNone;
  Chart1[1].XValues.Order:=loNone;

  Chart2[0].XValues.Order:=loNone;
  Chart2[1].XValues.Order:=loNone;

  for i:=0 to 1000 do
  begin
    x0:=random;
    y0:=random*100;
    x1:=random;
    y1:=random*100;

    Chart1[0].AddXY(x0,y0);
    Chart1[1].AddXY(x1,y1);

    Chart2[0].AddXY(y0,x0);
    Chart2[1].AddXY(y1,x1);
  end;

  Chart1.Axes.Bottom.Inverted:=true;
  Chart2.Axes.Left.Inverted:=true;
end;
Thanks in advance.

Xlplot problem

Posted: Wed Oct 01, 2008 2:13 pm
by 9339158
Narcis

Thanks sorted the text position problem.

Here is the code which causes the problem. I am only using one series per plot with color points. I could potentially have many different colors so do not want to create a series per color.

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i : Integer;
x0, y0, x1, y1 : Double;
begin
Chart1.View3D:=false;
Chart2.View3D:=false;

Chart1.AddSeries(TPointSeries.Create(self));
Chart2.AddSeries(TPointSeries.Create(self));

Chart1[0].XValues.Order:=loNone;
Chart2[0].XValues.Order:=loNone;

for i:=0 to 1000 do
begin
x0:=random;
y0:=random*100;
Chart1[0].AddXY(x0,y0, '', clBlue);
Chart2[0].AddXY(y0,x0, '', clBlue);
end;

for i:=0 to 1000 do
begin
x0:=random;
y0:=random*100;
Chart1[0].AddXY(x0,y0, '', clRed);
Chart2[0].AddXY(y0,x0, '', clRed);
end;

Chart1.Axes.Bottom.Inverted:=True;
Chart2.Axes.Left.Inverted:=True;
end;

Thanks Frank

Posted: Wed Oct 01, 2008 2:37 pm
by narcis
Hi Frank,

Thanks for the information.

In that case I think it's a bug and added it (TV52013424) to the list to be enhanced for next releases.

Posted: Fri Feb 20, 2009 3:02 pm
by narcis
Hi Frank,

I've been investigating this issue now and I don't think it is a bug. By design, series are painted from left to right or right to left depending on axes Inverted property.

An easy solution is creating a custom series that inherits from TPointSeries and which overrides its DrawAllValues method, for example:

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TeeComma, ExtCtrls, TeeProcs, TeEngine, Chart, Series;

type
  MyPoint = class(TPointSeries)
  private
  protected
    procedure DrawAllValues; override;
  public
  end;

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ MyPoint }

procedure MyPoint.DrawAllValues;
var t : Integer;
Begin
  for t:=FFirstVisibleIndex to FLastVisibleIndex do DrawValue(t);
end;

procedure TForm1.FormCreate(Sender: TObject);
var i : Integer;
    x0, y0 : Double;
    color: TColor;
begin
  Chart1.View3D:=false;
  Chart2.View3D:=false;

  Chart1.AddSeries(MyPoint.Create(self));
  Chart2.AddSeries(MyPoint.Create(self));

  Chart1[0].XValues.Order:=loNone;
  Chart2[0].XValues.Order:=loNone;

  for i:=0 to 2000 do
  begin
    x0:=random;
    y0:=random*100;
    if i<1000 then color:=clBlue
              else color:=clRed;
    Chart1[0].AddXY(x0,y0, '', color);
    Chart2[0].AddXY(y0,x0, '', color);
  end;

  Chart1.Axes.Bottom.Inverted:=True;
  Chart2.Axes.Left.Inverted:=True;
end;

end.