Area Graph Question

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
mh
Newbie
Newbie
Posts: 2
Joined: Wed Jun 23, 2004 4:00 am

Area Graph Question

Post by mh » Wed Mar 07, 2007 9:42 pm

When I'm graphing a single point, the area graph only shows a single dashed verticle line up the the value of the point.

Is there any way to change the display of the graph so it draws the single point from the bottom-left of the chart window to the point to the bottom-right of the chart window? This would then show a single point essentially as a pyramid. As it is, viewing a single data point sometimes confuses the customer because it looks like nothing was graphed.

Thanks

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

Post by Yeray » Thu Mar 08, 2007 9:53 am

Hello mh,

To plot an area series you should have, at least, two points to define a valid area to be plotted. Anyway, if you wish to achieve what you request you could use something like the AddValue method and OnGetPointerStyle event (to show the points you need) as in the example we implemented below.

Code: Select all

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Chart1: TChart;
    Series1: TAreaSeries;
    Button1: TButton;
    TeeCommander1: TTeeCommander;
    procedure FormCreate(Sender: TObject);
    function Series1GetPointerStyle(Sender: TChartSeries;
      ValueIndex: Integer): TSeriesPointerStyle;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    OnePoint: boolean;
    procedure AddValue(y: double);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AddValue(y: double);
begin
     if Series1.Count = 0 then
     begin
          OnePoint:=true;
          Series1.Add(y-1);
          Series1.Add(y);
          Series1.Add(y-1);
     end
     else
         begin
           if OnePoint then
           begin
                Series1.Delete(0);
                Series1.Delete(Series1.Count-1);
                Series1.XValues.FillSequence;

                OnePoint:=false;
           end;

           Series1.Add(y);
         end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.Clear;
  Series1.Pointer.Visible:=true;

  OnePoint:=false;
  AddValue(random);
end;

function TForm1.Series1GetPointerStyle(Sender: TChartSeries;
  ValueIndex: Integer): TSeriesPointerStyle;
begin
  if OnePoint then
  begin
    if (ValueIndex = 1) then
       result := psRectangle
    else
        result := psNothing;
  end
  else
    result := psRectangle;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
     AddValue(random);
end;

end.
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

mh
Newbie
Newbie
Posts: 2
Joined: Wed Jun 23, 2004 4:00 am

Post by mh » Thu Mar 08, 2007 3:57 pm

Thanks for the tip. However we are utilizing the graph inside of a Report Builder report, so we don't have programmatic access to it. I guess we'll have to adjust the data or select another report style.

Thanks again

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Mar 08, 2007 4:06 pm

Hi mh,

If you don't have access to all those events and properties in Report Builder you could use an invisible TChart, export it to an image and then load the image into Report Builder. For more information on how to export TeeChart to images please read Tutorial 12 - Exporting and Importing Charts. You'll find the tutorials at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply