BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I create charts?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Reporting-Charting
View previous topic :: View next topic  
Author Message
El
Guest





PostPosted: Thu Dec 14, 2006 12:07 am    Post subject: How do I create charts? Reply with quote



I would like to create charts in real time like the one shown on the
performance tab of Windows Task Manager.
I would be feeding it things like transaction per second numbers every
second and it would chart it as a line chart.

Thanks.
Back to top
Horst Reichert
Guest





PostPosted: Thu Dec 14, 2006 9:13 am    Post subject: Re: How do I create charts? Reply with quote



If you are not fixed on using TChart you might have a look at:
http://www.rt-science.com/toolsexample.html

It is just as assigning values to an array.



Regards Horst
Back to top
Narcís Calvet
Guest





PostPosted: Thu Dec 14, 2006 4:32 pm    Post subject: Re: How do I create charts? Reply with quote



Hello,

At the URL below you'll find an article on how to create real-time charts
with TeeChart and optimize its performance.

http://www.teechart.net/reference/modules.php?name=News&file=article&sid=6


--
Best Regards,

Narcis Calvet
Steema Support Central
http://support.steema.com

"Important note: If you are a TeeChart registered customer, please post your
support questions at Steema's Support monitored Forums for customers:
http://support.steema.com for a prompter reply."

El wrote:
Quote:
I would like to create charts in real time like the one shown on the
performance tab of Windows Task Manager.
I would be feeding it things like transaction per second numbers every
second and it would chart it as a line chart.

Thanks.
Back to top
David Berneda
Guest





PostPosted: Thu Dec 14, 2006 5:41 pm    Post subject: Re: How do I create charts? Reply with quote

Hi El
If your data comes every second then you don't need lots of speed,
so you can use simple code like the one below to setup a chart, a line series,
and then at every second delete one point at the beggining of the line and
add a new point at the end to simulate automatic scroll like Task Manager does.

Download this example here:
http://www.steema.com/support/teechart/7/tutorials/simple_realtime/TeeChart_Simple_RealTime.zip

regards
david
www.teechart.com


uses
Chart, Series, ExtCtrls;

Const
MaxPoints = 20;

var
Chart1 : TChart;
Line1 : TLineSeries;
Timer1 : TTimer;

procedure TForm1.FormCreate(Sender: TObject);
begin
// Create the Chart
Chart1:=TChart.Create(Self);
Chart1.Parent:=Self;
Chart1.Align:=alClient;

// Create the Line
Line1:=TLineSeries.Create(Self);
Chart1.AddSeries(Line1);

// Add some random data
Line1.GetHorizAxis.SetMinMax(0,MaxPoints-1);
Line1.FillSampleValues(MaxPoints);

// Cosmetic changes
Chart1.Color:=clBlack;
Line1.Color:=clLime;
Line1.GetHorizAxis.LabelsFont.Color:=clWhite;
Line1.GetHorizAxis.Grid.Color:=clGreen;
Line1.GetVertAxis.LabelsFont.Color:=clWhite;
Line1.GetVertAxis.Grid.Color:=clGreen;
Chart1.Walls.Left.Color:=clSilver;

// Add a one-second Timer
Timer1:=TTimer.Create(Self);
Timer1.Interval:=1000;
Timer1.OnTimer:=Timer1Timer;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
// Remove first point
if Line1.Count>=MaxPoints then Line1.Delete(0);

// Add new point
Line1.Add(Line1.YValues.Last+Random(50)-25);

// Reset "X" to start at zero
Line1.XValues.FillSequence;
end;


"El" <elias.berelian (AT) snet (DOT) net> wrote in message news:45804132$1 (AT) newsgroups (DOT) borland.com...
Quote:
I would like to create charts in real time like the one shown on the performance tab of Windows Task Manager.
I would be feeding it things like transaction per second numbers every second and it would chart it as a line chart.

Thanks.
Back to top
El
Guest





PostPosted: Thu Dec 14, 2006 10:34 pm    Post subject: Re: How do I create charts? Reply with quote

Thanks David.
That helped a lot. I am not using Delphi, so I had to convert to C. Some
TChart methods I coul not find equivalents of.
For example:
Line1.GetHorizAxis.SetMinMax(0,MaxPoints-1);
Line1.YValues.Last
// Reset "X" to start at zero
Line1.XValues.FillSequence;


Thanks again,
Elias
"David Berneda" <david (AT) steema (DOT) com> wrote in message
news:4581373e (AT) newsgroups (DOT) borland.com...
Quote:
Hi El
If your data comes every second then you don't need lots of speed,
so you can use simple code like the one below to setup a chart, a line
series,
and then at every second delete one point at the beggining of the line and
add a new point at the end to simulate automatic scroll like Task Manager
does.

Download this example here:
http://www.steema.com/support/teechart/7/tutorials/simple_realtime/TeeChart_Simple_RealTime.zip

regards
david
www.teechart.com


uses
Chart, Series, ExtCtrls;

Const
MaxPoints = 20;

var
Chart1 : TChart;
Line1 : TLineSeries;
Timer1 : TTimer;

procedure TForm1.FormCreate(Sender: TObject);
begin
// Create the Chart
Chart1:=TChart.Create(Self);
Chart1.Parent:=Self;
Chart1.Align:=alClient;

// Create the Line
Line1:=TLineSeries.Create(Self);
Chart1.AddSeries(Line1);

// Add some random data
Line1.GetHorizAxis.SetMinMax(0,MaxPoints-1);
Line1.FillSampleValues(MaxPoints);

// Cosmetic changes
Chart1.Color:=clBlack;
Line1.Color:=clLime;
Line1.GetHorizAxis.LabelsFont.Color:=clWhite;
Line1.GetHorizAxis.Grid.Color:=clGreen;
Line1.GetVertAxis.LabelsFont.Color:=clWhite;
Line1.GetVertAxis.Grid.Color:=clGreen;
Chart1.Walls.Left.Color:=clSilver;

// Add a one-second Timer
Timer1:=TTimer.Create(Self);
Timer1.Interval:=1000;
Timer1.OnTimer:=Timer1Timer;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
// Remove first point
if Line1.Count>=MaxPoints then Line1.Delete(0);

// Add new point
Line1.Add(Line1.YValues.Last+Random(50)-25);

// Reset "X" to start at zero
Line1.XValues.FillSequence;
end;


"El" <elias.berelian (AT) snet (DOT) net> wrote in message
news:45804132$1 (AT) newsgroups (DOT) borland.com...
I would like to create charts in real time like the one shown on the
performance tab of Windows Task Manager.
I would be feeding it things like transaction per second numbers every
second and it would chart it as a line chart.

Thanks.



Back to top
David Berneda
Guest





PostPosted: Fri Dec 15, 2006 1:56 am    Post subject: Re: How do I create charts? Reply with quote

Hi Elias
I've ported the example to C++, using TeeChart Standard v4 (the free one included with C++ Builder)
instead of latest TeeChart Pro v8.
See code below. Works fine in my machine.

If you need more help try also posting your questions at our public newsgroups:
news://www.steema.net

regards
david
www.teechart.com


#include "Unit1.h"
#include <Chart.hpp>
#include <Series.hpp>
#include <ExtCtrls.hpp>

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

const
MaxPoints = 20;

TChart *Chart1;
TLineSeries *Line1;
TTimer *Timer1;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Create the Chart
Chart1=new TChart(this);
Chart1->Parent=this;
Chart1->Align=alClient;

// Create the Line
Line1=new TLineSeries(this);
Line1->ParentChart=Chart1;

// Add some random data
Line1->GetHorizAxis->SetMinMax(0,MaxPoints-1);
Line1->FillSampleValues(MaxPoints);

// Cosmetic changes
Chart1->Color=clBlack;
Line1->SeriesColor=clLime;
Line1->GetHorizAxis->LabelsFont->Color=clWhite;
Line1->GetHorizAxis->Grid->Color=clGreen;
Line1->GetVertAxis->LabelsFont->Color=clWhite;
Line1->GetVertAxis->Grid->Color=clGreen;
Chart1->LeftWall->Brush->Color=clSilver;

// Add a one-second Timer
Timer1=new TTimer(this);
Timer1->Interval=1000;
Timer1->OnTimer=Timer1Timer;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
// Remove first point
if (Line1->Count() >= MaxPoints)
{
Line1->Delete(0);
}

// Add new point
Line1->Add(Line1->YValues->Last()+random(50)-25);

// Reset "X" to start at zero
Line1->XValues->FillSequence();

}
//---------------------------------------------------------------------------


"El" <elias.berelian (AT) snet (DOT) net> wrote in message news:45817ce8$1 (AT) newsgroups (DOT) borland.com...
Quote:
Thanks David.
That helped a lot. I am not using Delphi, so I had to convert to C. Some TChart methods I coul not find equivalents of.
For example:
Line1.GetHorizAxis.SetMinMax(0,MaxPoints-1);
Line1.YValues.Last
// Reset "X" to start at zero
Line1.XValues.FillSequence;
Back to top
El
Guest





PostPosted: Fri Dec 15, 2006 4:04 am    Post subject: Re: How do I create charts? Reply with quote

Thanks again David. Works fine.

Regards, Elias

"David Berneda" <david (AT) steema (DOT) com> wrote in message
news:4581ab1f$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hi Elias
I've ported the example to C++, using TeeChart Standard v4 (the free one
included with C++ Builder)
instead of latest TeeChart Pro v8.
See code below. Works fine in my machine.

If you need more help try also posting your questions at our public
newsgroups:
news://www.steema.net

regards
david
www.teechart.com


#include "Unit1.h"
#include <Chart.hpp
#include <Series.hpp
#include <ExtCtrls.hpp

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

const
MaxPoints = 20;

TChart *Chart1;
TLineSeries *Line1;
TTimer *Timer1;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// Create the Chart
Chart1=new TChart(this);
Chart1->Parent=this;
Chart1->Align=alClient;

// Create the Line
Line1=new TLineSeries(this);
Line1->ParentChart=Chart1;

// Add some random data
Line1->GetHorizAxis->SetMinMax(0,MaxPoints-1);
Line1->FillSampleValues(MaxPoints);

// Cosmetic changes
Chart1->Color=clBlack;
Line1->SeriesColor=clLime;
Line1->GetHorizAxis->LabelsFont->Color=clWhite;
Line1->GetHorizAxis->Grid->Color=clGreen;
Line1->GetVertAxis->LabelsFont->Color=clWhite;
Line1->GetVertAxis->Grid->Color=clGreen;
Chart1->LeftWall->Brush->Color=clSilver;

// Add a one-second Timer
Timer1=new TTimer(this);
Timer1->Interval=1000;
Timer1->OnTimer=Timer1Timer;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
// Remove first point
if (Line1->Count() >= MaxPoints)
{
Line1->Delete(0);
}

// Add new point
Line1->Add(Line1->YValues->Last()+random(50)-25);

// Reset "X" to start at zero
Line1->XValues->FillSequence();

}
//---------------------------------------------------------------------------


"El" <elias.berelian (AT) snet (DOT) net> wrote in message
news:45817ce8$1 (AT) newsgroups (DOT) borland.com...
Thanks David.
That helped a lot. I am not using Delphi, so I had to convert to C. Some
TChart methods I coul not find equivalents of.
For example:
Line1.GetHorizAxis.SetMinMax(0,MaxPoints-1);
Line1.YValues.Last
// Reset "X" to start at zero
Line1.XValues.FillSequence;

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Reporting-Charting All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.