Page 1 of 1

CUSTOM AXIS

Posted: Mon Jun 18, 2007 10:17 pm
by 9346223
Good Evening,

I have 2 series that I need to plot.

Series 1: -2049.057 -3088.949
81.702 -3755.25
1122.429 -699.469
2275.59 -3121.41

Series 2: -5596.954 963.511
-4950.713 -2748.388
-3766.508 4226.472
-1996.394 -5171.612
-188.388 5571.257
1887.489 -5154.936
3405.256 4266.641
4705.081 -2721.886
5375.547 992.806

Text: 16
8
17
14
15
19
4
13
11

The data plots fine. I need to have a 20 X 20 grid based on a SCALE number of in this instance 650.82 with 0, 0 being the center of the graph.

When I add a Custom Axis the numbers do not plot correctly.

Basically the plot horizontal axis should be plotted 0 in the center, -650.82 left and +650.82 right and so on for ten increments either side of zero. The Vertical Axis should plot the same way, zero in the middle, -650.82 down and +650.82 up for 10 increments either side of zero.

I need the grid to be 20 x 20 and the series plotted.

When the user zooms, the scale changes. and the axis should change.

Can you help?

Thanks,
Marshall [/img]

Posted: Tue Jun 19, 2007 8:16 am
by yeray
Hi Marshall,

We need some extra information to understand better what you are trying to do.

-First of all we would like to know which series type are you going to plot.
-Then, the values you called "text", what are they used for?
-What does it mean 20x20 grid? You want your axes from -650.82 to 650.82 divided in 20 parts of 65.082 each one? Or do you want axes increments being of 10 units?

In the meantime you can take a look at this FAQ where custom axes zoom is explained. However, if you use default left and bottom axes zoom shouldn't be implemented as they already support it.

And also at this thread where an activex customer wanted to move left and bottom axes to the center (0,0 coordinate).

SORRY FOR MISSING INFO

Posted: Tue Jun 19, 2007 1:53 pm
by 9346223
To answer your questions:

1. The series are plotted as a Point Chart series.
2. I have a Chart Editor instance, so when you right click the chart the editor comes up. Click on the DATA tab and listed are # TEXT X Y X Y, so the text I'm listing is from the DATA tab under TEXT.
3. 20 X 20 grid is 20 Major Grid Lines Vertical and 20 Major Grid Lines Horizontal. The Vertical Center and Horizontal Center are 0 , 0. The Major Grid Lines are are labeled 0, 650.82, then 1301.64 next, then 1952.46, etc. and 0, -650.2, -1301.64, 1952.46 etc. The same pattern is true both HORIZONTAL and VERTICAL.

Hopefully that helps. By the way, thanks for all of the great support. You guys are quick to respond and I really appreciate you and your product.

Marshall

Posted: Wed Jun 20, 2007 9:18 am
by yeray
Hi Marshall,

The following code achieves the chart you requested:

Code: Select all

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TPointSeries;
    Series2: TPointSeries;
    procedure FormCreate(Sender: TObject);
    procedure Chart1Scroll(Sender: TObject);
    procedure Chart1Zoom(Sender: TObject);
    procedure Chart1UndoZoom(Sender: TObject);
  private
    { Private declarations }
    procedure PlaceAxes();
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  const DesiredWidth = 650.82;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Chart1 do
  begin
    View3D := false;
    Legend.Visible := false;
    Title.Visible := false;
    MarginLeft := 0;
    MarginRight := 2;
    MarginBottom := 0;
    MarginTop := 2;
  end;

  with Chart1.Axes do
  begin
    Left.PositionUnits := muPixels;
    Left.AutomaticMinimum := false;
    Left.AutomaticMaximum := false;
    Left.Minimum := -DesiredWidth*10;
    Left.Maximum := DesiredWidth*10;
    Left.Increment := DesiredWidth;
    Bottom.PositionUnits := muPixels;
    Bottom.AutomaticMinimum := false;
    Bottom.AutomaticMaximum := false;
    Bottom.Minimum := -DesiredWidth*10;
    Bottom.Maximum := DesiredWidth*10;
    Bottom.Increment := DesiredWidth;
    Bottom.LabelStyle := talValue;
  end;

  with Series1 do
  begin
    AddXY(-2049.057,-3088.949);
    AddXY(81.702,-3755.25);
    AddXY(1122.429,-699.469);
    AddXY(2275.59,-3121.41);
    Marks.Visible := true;
  end;

  with Series2 do
  begin
    AddXY(-5596.954,963.511,'16');
    AddXY(-4950.713,-2748.388,'8');
    AddXY(-3766.508,4226.472,'17');
    AddXY(-1996.394,-5171.612,'14');
    AddXY(-188.388,5571.257,'15');
    AddXY(1887.489,-5154.936,'19');
    AddXY(3405.256,4266.641,'4');
    AddXY(4705.081,-2721.886,'13');
    AddXY(5375.547,992.806,'11');
    Marks.Visible := true;
  end;

  Chart1.Draw;
  PlaceAxes();
end;

procedure TForm1.PlaceAxes();
begin
  With Chart1.Axes do
  begin
    Left.PositionPercent := Bottom.CalcPosValue(0) - Chart1.ChartRect.Left;
    Bottom.PositionPercent := Chart1.ChartRect.Bottom - Left.CalcPosValue(0);
  end;
end;

procedure TForm1.Chart1Scroll(Sender: TObject);
begin
  Chart1.Draw;
  PlaceAxes();
end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  Chart1.Draw;
  PlaceAxes();
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
  Chart1.Draw;
  PlaceAxes();
end;

end.
NOTE: Only added two point series in design time. The rest is done at runtime.