Hi Anders,
To add a trend line calculated based on the last 4 months, please simply add a trend layer using the data points from the last 4 months only.
For example, suppose you are using a label based x-axis (configured using Axis.setLabels or Axis.setLabels2). In this case, the x-coordinates of the data points are the array index of the labels, so the x-coordinates of the last 4 points are {8, 9, 10, 11}. The code is like (in VB/VBScript):
Set trendLayer = c.addTrendLayer2(Array(8, 9, 10, 11), Array(myData(8), myData(9), myData(10), myData(11)), c.xZoneColor(7.5, cd.Transparent, &H0000ff))
Call trendLayer.setLineWidth(2)
In the above code, the xZoneColor is used to cause the trend layer to be visible only for x >= 7.5 (starting from the mid-point between the 8th and 9th months).
If you need to translate the above to another programming language, please let me know.
Hope this can help.
Regards
Peter Kwan |