X Coordinate from Bar

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
AchatSolutions
Newbie
Newbie
Posts: 20
Joined: Wed Jul 11, 2001 4:00 am
Location: Bavaria
Contact:

X Coordinate from Bar

Post by AchatSolutions » Thu Oct 04, 2007 8:11 am

Hi there,

attached there is a screenshot. This picture shows my aim.
Image
This Chart shows production lines with its allocation per year (bars) and the efficiency (line) for each year in percent. The other horizontal lines shows the allocation with an other time calculation.

So each bar is one year that is grouped to one line (the range of years is dynamic, so there are user defined quantity of years). And the line thats shows the efficiency shows this for each year too.

My problem is, that i am not able to center one point of the efficiency line to one bar.

How can i get the X value of the bar?

This will not work because it shows the X value of the grouped bars not for one bar:

Code: Select all

Series2.XValues.Value[0] 
Hope its clear! Looking forward to your reply.

Thanks :)

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Oct 04, 2007 8:29 am

Hi AchatSolutions,

You could try doing something like this:

Code: Select all

  PosValue:=Series1.CalcXPos(0);
  XValue:=Chart1.Axes.Bottom.CalcPosPoint(PosValue);
Where PosValue is an Integer and XValue a Double.

Hope this helps!
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 » Thu Oct 04, 2007 11:35 am

Thanks for your answer!

I am using the prof Version in a other application. Here im using the TeeChart Standard Edition 4.04 for Delphi 6.

Is there a possibility to realize your code?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Oct 04, 2007 11:58 am

Hi AchatSolutions,

I don't have a v4.04 available at the moment but I guess equivalent or same methods should exist. You could try something like this:

Code: Select all

  PosValue:=Series1.CalcXPos(0);
  XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
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 » Thu Oct 04, 2007 2:34 pm

Thanks for your fast reply.

This solutions does not work.. i am sorry. Are there any alternative?

I can build up a little demo to specific my problem?!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Oct 04, 2007 2:44 pm

Hi AchatSolutions,

Yes please, would be helpful if you sent us a simple example project we can run "as-is" to reproduce the problem here. You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

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 » Fri Oct 05, 2007 6:18 am

I am using your Upload Page.

Heres the report:
Received TeeChartSample.zip Content Type application/zip Length 293258

Thanks for helping me!

Stefan Henkenjohann

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Oct 05, 2007 10:07 am

Hi Stefan,

Thanks for the example project.

Why don't you use the last series for the efficiency line and try populating it doing something like the code below instead of the code you use now?

Code: Select all

  Chart1.Draw;
  for i:=0 to Chart1.SeriesCount-2 do
  begin
    PosValue:=Chart1[i].CalcXPos(0);
    XValue:=Chart1.Axes.Bottom.CalcPosPoint(PosValue);
    Series5.AddXY(XValue, 180 + (i*20));
  end;
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 » Fri Oct 05, 2007 11:00 am

Can you please add this code to my demo project?

I am trying to keep that code running but there are different exceptions.. (Chart1.Draw needs more parameters, undeclard identifier Axes, etc.)

Thank you for your patience :)

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

Post by Yeray » Mon Oct 08, 2007 8:04 am

Hi Stefan,

I'm sorry but the function CalcPosPoint is not available at TeeChart 4 Standard. So, the easiest solution should be using your pro version.
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

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

Post by AchatSolutions » Tue Nov 06, 2007 8:08 am

Hello support team,

now i am using teechartpro v5.02.

I am trying to use this code:

Code: Select all

  PosValue:=Series1.CalcXPos(0);
  XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
But nothing happens. The efficiency line is always in the middle of the grouped bars.

So i am trying this code:

Code: Select all

  PosValue:=Series1.CalcXPos(0);
  XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
But in my version "BottomAxis" is not available.

Please can you send my a sample code or a sample project to show me how this works correctly?

Thanks!

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

Post by Yeray » Wed Nov 07, 2007 9:28 am

Hi Stefan,

Could you please, try commenting the population part of code for your efficiency line (Series5) and add this code at the end of your FormCreate?
This works here in a clean Delphi 5 (with TeeChart Std 4.02).

Code: Select all

  Chart1.Draw(Canvas,Chart1.ChartRect);
  for i:=0 to Chart1.SeriesCount-2 do
  begin
    PosValue:=Chart1[i].CalcXPos(0);
    XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
    Series5.AddXY(XValue, 180 + (i*20));
  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

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

Post by AchatSolutions » Wed Nov 07, 2007 3:04 pm

Thanks.

Here is my code. The first for loop should create the efficiency points centered on every bar of line 18. But nothing happens. For line 19 and 20 it works.

Code: Select all

var
  i: integer;
  PosValue: integer;
  XValue: double;
begin
  XValue := 0;
  //****************************************************************************
  // 2010
  Series1.AddXY(1, 10000, 'Line 18');

  // 2011
  Series2.AddXY(1, 12500, 'Line 18');

  // 2012
  Series3.AddXY(1, 14000, 'Line 18');

  // 2013
  Series4.AddXY(1, 13500, 'Line 18');

  //2014
  Series6.AddXY(1, 11500, 'Line 18');

  Chart1.Draw(Canvas,Chart1.ChartRect);
  for i:=0 to Chart1.SeriesCount-2 do begin
    PosValue:=Chart1[i].CalcXPos(0);
    XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
    Series5.AddXY(XValue, 180 + (i*15));
  end;

  Series5.AddNullXY(XValue, 0);


  //****************************************************************************
  // 2010
  Series1.AddXY(2, 10000, 'Line 19');

  // 2011
  Series2.AddXY(2, 12500, 'Line 19');

  // 2012
  Series3.AddXY(2, 14000, 'Line 19');

  // 2013
  Series4.AddXY(2, 13500, 'Line 19');

  //2014
  Series6.AddXY(2, 11500, 'Line 19');

  Chart1.Draw(Canvas,Chart1.ChartRect);
  for i:=0 to Chart1.SeriesCount-2 do begin
    PosValue:=Chart1[i].CalcXPos(1);
    XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
    Series5.AddXY(XValue, 180 + (i*15));
  end;

  Series5.AddNullXY(XValue, 0);

  //****************************************************************************
  // 2010
  Series1.AddXY(3, 10000, 'Line 20');

  // 2011
  Series2.AddXY(3, 12500, 'Line 20');

  // 2012
  Series3.AddXY(3, 14000, 'Line 20');

  // 2013
  Series4.AddXY(3, 13500, 'Line 20');

  //2014
  Series6.AddXY(3, 11500, 'Line 20');

  Chart1.Draw(Canvas,Chart1.ChartRect);
  for i:=0 to Chart1.SeriesCount-2 do begin
    PosValue:=Chart1[i].CalcXPos(2);
    XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
    Series5.AddXY(XValue, 180 + (i*10));
  end;
end;
So it works partial but is there any other solution right there, because the efficiency points are not centered correctly as you can see in this screenshot (to reproduce this, use the code above, and resize the form)?

Image
Big Version: Click here


I am looking forward to your reply. Thanks!

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

Post by Yeray » Thu Nov 08, 2007 12:03 pm

Hi AchatSolutions,

I've been modifying your project and testing how to achieve your request and I haven't fount a better solution than this one:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
const numpoints=3;
var
  i,j : integer;
  PosValue: integer;
  XValue: double;
begin
  for i:=1 to numpoints do
  begin
    // 2010
    Series1.AddXY(i, 10000, 'Line ' + inttostr(18+i));
    // 2011
    Series2.AddXY(i, 12500, 'Line ' + inttostr(18+i));
    // 2012
    Series3.AddXY(i, 14000, 'Line ' + inttostr(18+i));
    // 2013
    Series4.AddXY(i, 13500, 'Line ' + inttostr(18+i));
    //2014
    Series5.AddXY(i, 11500, 'Line ' + inttostr(18+i));
  end;

  Chart1.Draw(Canvas,Chart1.ChartRect);

  for j:=0 to numpoints-1 do
  begin
    for i:=0 to Chart1.SeriesCount-2 do begin
      PosValue:=Chart1[i].CalcXPos(j);
  //    PosValue:=Chart1[i].Marks.Positions.Position[0].ArrowTo.x;
      XValue:=Chart1.BottomAxis.CalcPosPoint(PosValue);
      Series6.AddXY(XValue, 180 + (i*10));
    end;

    Series6.AddNullXY(XValue, PosValue,'');
   end;

end;
The comented line "PosValue:=Chart1.Marks.Positions.Position[0].ArrowTo.x;" is a better solution, neither perfect, that works for teechart 8. You could download an eval version to test it.
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

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

Post by AchatSolutions » Mon Nov 19, 2007 9:51 am

Thanks for the code.

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

Here you can see a screenshot of the compiled application that is attached:
Image
Big version: Click here

The Lines are not x centered in the middle of the bar.

When i uncomment the line

Code: Select all

  PosValue:=Chart1[i].Marks.Positions.Position[0].ArrowTo.x; 
delphi throws a access violation.

Sorry but either i dont understand your code or this will not work in my sample application.

Maybe you can upload a demo project that demonstrates how to fix this problem correctly (i am using delphi6 and teechart pro v5.02)?!

Thanks!

Post Reply