Page 1 of 1

Position (TPoint) of the top of a stacked TBarSeries

Posted: Fri Jun 28, 2013 7:26 pm
by 16565416
Given the X index of a stacked bar, I need to place the cursor at the top of bars. I have the following code:

Code: Select all

begin
  lPt.X := Chart1.BottomAxis.CalcXPosValue(spnXPos.EditingValue);
  lPt.Y := Chart1.LeftAxis.CalcYPosValue(Chart1.LeftAxis.Maximum);
  lPt := ClientToSCreen(lPt);
  SetCursorPos(lPt.X, lPt.Y);
end;
The X position is correct, my Y position is wrong. The Y is at the maximum of the axis--I want the maximum of the stacked bar position.

How can I find the maximum Y value of a stack of bars for a given index?

Ed Dressel

Re: Position (TPoint) of the top of a stacked TBarSeries

Posted: Mon Jul 01, 2013 1:42 pm
by yeray
Hi Ed,

if you know Series and the ValueIndex to retrieve the position, you can just use the series CalcXPos/CalcYPos functions:

Code: Select all

  lPt.X:=Series.CalcXPos(ValueIndex);
  lPt.Y:=Series.CalcYPos(ValueIndex);
  lPt := Chart1.ClientToSCreen(lPt);
  SetCursorPos(lPt.X, lPt.Y);