 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
El Guest
|
Posted: Thu Dec 14, 2006 12:07 am Post subject: How do I create charts? |
|
|
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
|
Posted: Thu Dec 14, 2006 9:13 am Post subject: Re: How do I create charts? |
|
|
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
|
Posted: Thu Dec 14, 2006 4:32 pm Post subject: Re: How do I create charts? |
|
|
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
|
Posted: Thu Dec 14, 2006 5:41 pm Post subject: Re: How do I create charts? |
|
|
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
|
Posted: Thu Dec 14, 2006 10:34 pm Post subject: Re: How do I create charts? |
|
|
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
|
Posted: Fri Dec 15, 2006 1:56 am Post subject: Re: How do I create charts? |
|
|
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
|
Posted: Fri Dec 15, 2006 4:04 am Post subject: Re: How do I create charts? |
|
|
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 |
|
 |
|
|
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
|
|