TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
Numinor
- Newbie
- Posts: 4
- Joined: Thu Mar 06, 2014 12:00 am
Post
by Numinor » Thu Mar 06, 2014 7:55 pm
I just purchased Pro so I could use trends in my graph. I need to configure it in design mode-
Code: Select all
procedure TfrmPsrGraph.SetupGraph(const v1,v2,v3:shortstring);
var
xBar3:TBarSeries;
xTrend:TTrendFunction;
m, b: Double;
begin
xTrend:=TTrendFunction.Create(self);
xBar3:=TBarSeries.Create(chtPSR);
xBar3.ParentChart:=chtPSR;
xBar3.SetFunction(xTrend);
xBar3.DataSource:=fPSRTable;
xBar3.CheckDataSource;
xTrend.CalculateTrend(m,b,xBar3,0,xBar3.Count);
xBar3.YValues.ValueSource:=v3;
xBar3.XValues.ValueSource:='psrdate';
xBar3.XValues.DateTime:=true;
xBar3.ShowInLegend:=false;
xBar3.Marks.Visible:=false;
xBar3.color:=clBlue;
xBar3.RefreshSeries;
xBar3.Title:='s3';
xBar3.ShowInLegend:=true;
chtPSR.BottomAxis.ExactDateTime:=true;
chtPSR.BottomAxis.DateTimeFormat:='m/d';
chtPSR.BottomAxis.Increment:= DateTimeStep[dtOneDay];
end;
Obviously this doesnt draw a trend line. I see the bar graph but that's all. Any help will be appreciated.
-
Yeray
- Site Admin
- Posts: 9612
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Fri Mar 07, 2014 9:34 am
Hello and welcome to the forums,
Note the functions need a series linked to them to be represented. In your case, a trend function is usually represented with a line series. Ie:
Code: Select all
uses Series, CurvFitt;
procedure TForm1.FormCreate(Sender: TObject);
var
xBar:TBarSeries;
xTrend:TTrendFunction;
xLine: TLineSeries;
m, b: Double;
begin
xTrend:=TTrendFunction.Create(Self);
xBar:=TBarSeries.Create(Self);
xBar.ParentChart:=Chart1;
//xBar.SetFunction(xTrend);
xBar.FillSampleValues;
//xBar.DataSource:=fPSRTable;
//xBar.CheckDataSource;
xTrend.CalculateTrend(m,b,xBar,0,xBar.Count);
//xBar.YValues.ValueSource:=v3;
//xBar.XValues.ValueSource:='psrdate';
xBar.XValues.DateTime:=true;
xBar.ShowInLegend:=false;
xBar.Marks.Visible:=false;
xBar.color:=clBlue;
xBar.RefreshSeries;
xBar.Title:='s3';
xBar.ShowInLegend:=true;
Chart1.BottomAxis.ExactDateTime:=true;
Chart1.BottomAxis.DateTimeFormat:='m/d';
Chart1.BottomAxis.Increment:= DateTimeStep[dtOneDay];
xLine:=TLineSeries.Create(Self);
xLine.ParentChart:=Chart1;
xLine.SetFunction(xTrend);
xLine.DataSource:=xBar;
//xTrend.Period:=2; //note you can change the period
end;
I'd suggest you to take a look at the tutorials and to the features demo, both shipped with the installation.
I've just replied a very similar question
here
-
Numinor
- Newbie
- Posts: 4
- Joined: Thu Mar 06, 2014 12:00 am
Post
by Numinor » Fri Mar 07, 2014 2:23 pm
Thank you! Seeing the code makes it all look obvious now. btw, I couldn't find any examples of how to do this in design mode. Everything I saw was adjusting properties in the editor. I rarely use the editor in my projects.
-
Narcís
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Tue Mar 11, 2014 2:51 pm
Hi Numinor,
Numinor wrote:I couldn't find any examples of how to do this in design mode.
You'll find some instructions in tutorial 7. Tutorials can be found at the program group created by binary package installers. If you still need some help don't hesitate to let us know.