Page 1 of 1

How To 'invert' AreaSeries to have color above curve

Posted: Wed Jul 25, 2007 11:28 am
by 9242592
Hi!

After spending quite a lot of time with this topic, I try to take advantage of this forum.
What I try to do is simple: I want to have color above a Line(Series), up to the top of the Chart-Rectangle, so just what the AreaSeries does, but vertically inverse.

My best try was a Series Band Tool with a non-visible lineseries at the top of the Chart, but this dramatically slowed down refreshing.

Can anybody help me?

Thanks in advance,

iuvis

Posted: Wed Jul 25, 2007 12:14 pm
by 9047589
It's a snap :D - use AreaSeries and just invert corresponding axis.
If more series use that axis, just introduce a new one.
Regards,
Alexander

Posted: Wed Jul 25, 2007 12:38 pm
by 9242592
Thanks for your answer, but that I have also tried before.
If I have done right, the y-coordinate of the point to be added to the Series with inverted axis depends on the minimum of the non-inverted axis:

yinv = axismin+axismax-y
(inverted axismin=axismin, inverted axismax=axismax)

But axismin or axismax might be changed by auto-scaling-funcionality or other. Then the coordinate of all points added previously are wrong, they would have to be all recalculated after such changes.
That again is too time-consuming for a lot of data.

Perhaps there is a more simple solution?

Regards,
iuvis

Posted: Wed Jul 25, 2007 12:52 pm
by 9047589
From your post is unclear do you mean screen or "world" coordinates. Screen coordinates are always pixels, while "world" could be meters, volts, dollars whatsoever.
Anyhow, when you add a new point you always have to use "world" coordinates, the rest of job will be done by TChart

Posted: Wed Jul 25, 2007 1:19 pm
by 9242592
Sorry, I have express myself more precisely. With coordinates I mean x/y values I use with the AddXY-function. Im NOT talking here about any pixel coordinates.

The application I have in mind has a central f(x) line running between a 'forbidden' area above with g(x)-values and a forbidden area below with h(x) values. f(x) is a LineSeries, h(x) is an areaseries. Now I want to have the area between g(x) and the top of the chart colored just as it is the case with the areaseries h(x).
So g(x) and h(x) share the same vertical axis. If I add an inverted custom axis for g(x) to apply an areaseries, I have to transform g(x) to g'(x) depending on axis minimum and maximum as described above (all coordinates 'real world', not pixels).

Woa, this looks complicated for such a simple problem.

I should add here that with Series Band tool I run also into problems with zooming, as it does not take into account points that are outside of the visible region. So I am afraid I have to solve this without that tool.

Regards,
Martin

Posted: Thu Jul 26, 2007 9:54 am
by 9047589
Hi, Martin!
I understand your task and got your contradiction.
Hope this can help you:

Image

Code: Select all

const
  LimitHi=270;
  LimitLo=320;
procedure TForm1.FormCreate(Sender: TObject);
var
  iX: integer;
  Y :double;
begin
  for iX:=0 to 24 do begin
    Y:=200*sin(iX/4);
    MainSeries.AddY(Y);
    HiSeries.AddY(-Y-LimitHi);
    LoSeries.AddY(Y-LimitLo);
  end;
  HiSeries.VertAxis:=aRightAxis;
  HiSeries.UseYOrigin:=True;
  HiSeries.YOrigin:=-1000;
  Chart1.RightAxis.Inverted:=True;
  Chart1.RightAxis.SetMinMax(-1000,1000);
  Chart1.LeftAxis.SetMinMax(-1000,1000);
end;
I can't suggest anymore.
Regards,
Alexander

Posted: Thu Jul 26, 2007 4:12 pm
by 9047589
I do not have TeeChart Proffesional and could test my assumptions only with demos like TeeChartOffice, but it seems that with TSeriesBandTool.BoundValue property you need only 2 additional series for lower and upper limits.

Posted: Thu Jul 26, 2007 6:29 pm
by 9242592
Thanks a lot, the code above does the job!!!

I just have to make sure that when setting minimum and/or maximum of the 'leading' left axis in the code, this must be done also with the right axis:

Code: Select all

  Chart1.RightAxis.SetMinMax(ymin,ymax); 
  Chart1.LeftAxis.SetMinMax(-ymax,-ymin); 
The same is true for the Axis Start/Endposition, though here the same values must be set.

Quite simple, thanks again!

The TSeriesBandTool.BoundValue property is not available to me (I have TeeChart Pro v7.07).

Regards,
Martin

Posted: Thu Jul 26, 2007 7:13 pm
by 9047589
Seems you got an idea and is able to manage yourself.
About BoundValue - try to investigate TSeriesBandTool with Symbol Explorer of Delphi.