Page 1 of 1

series allignment

Posted: Tue Dec 28, 2004 11:03 pm
by 9340187
we are trying to generate a series showing the derivative of a plot. The
original seris is called lineseries, and the derivative series is called deriv series. we are apporximating the deirvative at each point as one-half the difference of point[n+1] and point[n-1] which is good enough for what we need. we have to add a point at start and end with y=0 because derivative is not calculated at end points. Now, all is well except that the direvative plot is displaced relative to the line plot by 10 units to
the left. We gernerated a data set which is a "square wave", which is
a run of DN=125 followed by a run of DN=0 and then repeat. Clearly,
the two series are not in sync. Could use your advice here.

************************************************************
derivseries.addXY(lineseries.xvalues[0],0,'',clTeeColor);
N:=lineseries.count-1;
For kk:=1 To Pred(N) Do
derivseries.addXY(lineseries .xvalues[kk],
(lineseries.yvalues[kk+1]-lineseries.yvalues[kk-1]/2),
'',clTeeColor);
derivseries.addXY(lineseries.xvalues[N],0,'',clTeeColor);
**********************************************************
Thanks,

Jennifer

Re: series allignment

Posted: Thu Dec 30, 2004 2:26 pm
by 9234468
9340187 wrote: (lineseries.yvalues[kk+1]-lineseries.yvalues[kk-1]/2),
it should be

(lineseries.yvalues[kk+1]-lineseries.yvalues[kk-1])/2,

otherwise your code seems to work properly

Posted: Thu Dec 30, 2004 5:53 pm
by 9340187
I miust have mistyped the code to you-Sorry. In any event, we took the "2" out and the result is the same. The deriv plot ios about ao 10
units left of series 1. Here is the code:
*******************************************************
Procedure Tform1.drawderiv_2;
var
Indx,N:Integer;
valx:Double;
BEGIN
derivseries.addXY(lineseries.xvalues[0],50,'',clTeeColor);
For N:=1 To pred(lineseries.count-1) Do Begin
valx:=(lineseries.YValues[N+1]-lineseries.yValues[N-1]);
derivseries.addXY(lineseries.xvalues[N],valx,'',clTeeColor);
end;
derivseries.addxy(lineseries.xvalues[pred(lineseries.count)],0,'',clTeeColor);
END;
************************************************

What we did was go into the line where it says:

addxy(lineseries.xvalues[N],.......

qnd change that to: lineseries.xvalues[n]+10 the two series ligned
up perfectlly. So, we went back to the IDE and the two series are not
line up together in the IDE. The derriv series is about 10 units to the left of linseries, just like when it runs. Looking further, in the chart there is
a vertical yellow area on the left[wall-0]; and the lineseries starts at the right of the yellow bar, and deriv series starts near the left, so we are doing something in the design mode that we cannot find.

I have some screen shots showing this in both IDE and runnibg that I would be happy to send to an email address. They are JPEG and only about 20K apiece.

Thanks,
Jennirfer