Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Adding a Trendline

 Post Reply Post Reply
Author
Labuschagne Marius View Drop Down
New Member
New Member
Avatar

Joined: 01 Dec 2010
Posts: 27
Post Options Post Options   Quote Labuschagne Marius Quote  Post ReplyReply Direct Link To This Post Topic: Adding a Trendline
    Posted: 11 Feb 2011 at 1:40am
Hi,

I am trying to create a chart with one serie that shows the Sales per Month for a particular Customer for the last 24 months.  There is not problem with this and my chart works correctly.  Now I want to add a trend line to this chart, and this is where I dont seem to be able to get it right.  I have searched for a practical example but could not find one.

I am using the following piece of code, but nothing is displayed on my chart.

SalesChart.PaneByName['ChartPane 0'].AddTrendLine(0,0,24,True);

Can someone please guide me in getting this to work?  I also do not understand the startx and endx parameters that you need to pass to the trend line, where would I get these values, or am I correct in assuming that it would be from 0 to 24?

Regards
Marius
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3392
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 2011 at 2:33am
The code you are using is correct, did you wrap it with BeginUpdate and EndUpdate?
For each action you do that needs recalculation you need to wrap your statements with BeginUpdate and EndUpdate.
Back to Top
Labuschagne Marius View Drop Down
New Member
New Member
Avatar

Joined: 01 Dec 2010
Posts: 27
Post Options Post Options   Quote Labuschagne Marius Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 2011 at 2:42am
Hello Pieter,

Fantstic, now it works. I did not have the Begin and End Updates.

Just one more question, how can I get the maximum number of x, if my graph is not limited to a certain period of time?

Regards
Marius
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3392
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 2011 at 2:53am
Can you explain more in detail?
Is it the X-Axis range you are talking about?
Back to Top
Labuschagne Marius View Drop Down
New Member
New Member
Avatar

Joined: 01 Dec 2010
Posts: 27
Post Options Post Options   Quote Labuschagne Marius Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 2011 at 5:22am
Hi,

Yes, I think it must be the x-axis.

Its specifically the endx integer prameter in the TrendChannel/Line and Moving Avg procedures. Like the 24 I inserted in the example below.

SalesChart.PaneByName['ChartPane 0'].AddTrendLine(0,0,24,True);

Regards
Marius
Back to Top
Pieter Scheldeman View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 3392
Post Options Post Options   Quote Pieter Scheldeman Quote  Post ReplyReply Direct Link To This Post Posted: 11 Feb 2011 at 5:28am
Each chart has a RangeFrom and RangeTo property.
The trendline is only based on the numbers indexes of the points, if you add 100 points but only display 24 you can add 100 instead of the 24. The trendline will automatically calculated the line and only display the part between 0 and 24.

Changes in data will cause the trendline to be invalid. The trendline then needs to be readded. If you have only one serie the trendline will be the second serie. You can remove the trendline with:

Series[1].Free;

Regards, 
Scheldeman Pieter

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down