X Coordinate from Bar

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 21, 2007 4:01 pm

Hi AchatSolutions,
I have uploaded your code in a sample project by using version 5.02 with filename 'AchatSolutions_LineNotCentered_Sample.zip'.


I haven't found this project. Where did you send it?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

AchatSolutions
Newbie
Newbie
Posts: 20
Joined: Wed Jul 11, 2001 4:00 am
Location: Bavaria
Contact:

Post by AchatSolutions » Wed Dec 05, 2007 8:07 am

I m so sorry.. i have not seen this post..

I have uploaded it one more time.. result:
Received AchatSolutions_LineNotCentered_Sample.rar Content Type application/octet-stream Length 243664
So i have tried to write your sample code in my application..

I add my bars with 'BarSeries1.AddXY'

And i am using this code to find out the x value for the efficiency line:

Code: Select all

      lPosValue := Chart.Series[lSeriesIx].CalcXPos(aLineIx);
      lXValue := Chart.BottomAxis.CalcPosPoint(lPosValue);
But lPosValue has always the same value.. so 'CalcPosPoint' too.

lSeriesIx is the BarSeries.
aLineIx is the actual "numpoint'

So the function 'CalcXPos' dont care whats lSeriesIx contains. If there is 0 or 1 its always the same value for lPosValue.

Are there any special properties or codes to make this work?

In the sample application it works very fine. But not in my main application. And i cannot make a demo thats reproduce this problem.

Hope you can help me.

Thanks!

Edit (5. December, 10.30 am):
I am creating all bar series (for every year one) and the efficiency line dynamcly at runtime! Only the chart is build up at design time.


Edit (6 December, 10:25 am):
OK now im using 'Marks.Position' instead of CalcXPos:

Code: Select all

lPosValue := aMasterSeries.Marks.Positions.Position[0].ArrowFrom.X;
This works. The result is correct but after this function i must call

Code: Select all

Chart.BottomAxis.CalcPosPoint(lPosValue)
But this function always returns 1.

Are there any Ideas?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Dec 13, 2007 9:57 am

Hi AchatSolutions,

Using OnAfterDraw event to calculate the BarWidth you can use it to repopulate the efficiency line according to the actual Bottom Axis scale. So, you'll be able to have a good efficiency line even zooming and unzooming.

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
const aboveValue = 100;
var i:integer;
    BarWidth: double;
begin
  BarWidth := Chart1.BottomAxis.CalcPosPoint(Series1.BarBounds.Right) -
                  Chart1.BottomAxis.CalcPosPoint(Series1.BarBounds.Left);
  Series6.clear;
  for i:= 0 to numpoints-1 do
  begin
    Series6.AddXY(i+1-(BarWidth*2), Series1.YValue[i]+aboveValue);
    Series6.AddXY(i+1-BarWidth, Series2.YValue[i]+aboveValue);
    Series6.AddXY(i+1, Series3.YValue[i]+aboveValue);
    Series6.AddXY(i+1+BarWidth, Series4.YValue[i]+aboveValue);
    Series6.AddXY(i+1+(BarWidth*2), Series5.YValue[i]+aboveValue);
    Series6.AddNullXY(i+1+(BarWidth*3), aboveValue ,'');
  end;
end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  Chart1.Refresh;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply