Determine the relative width (in %) of the Y-Axis?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
swong
Newbie
Newbie
Posts: 24
Joined: Thu Jan 15, 2004 5:00 am

Determine the relative width (in %) of the Y-Axis?

Post by swong » Thu Jan 22, 2004 8:37 pm

Is there a way to determine the relative width (in %) of a custom Y-Axis. I am creating custom y-axis, and want them to display next to each other, without overlapping (or drawing off the edge of the control).


Is this possible?

Thanks!

swong
Newbie
Newbie
Posts: 24
Joined: Thu Jan 15, 2004 5:00 am

Post by swong » Thu Jan 22, 2004 9:53 pm

I have two examples that show the problem I'm encountering. The smaller jpeg (Chart1.jpg) has a relative position of 6% between each axis. You'll notice that the text seems to overwrite each other. Chart2.jpg is the same chart, but the chart size it bigger.

http://www.head-west.ca/Chart1.jpg
http://www.head-west.ca/Chart2.jpg

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jan 23, 2004 9:03 am

Hi,

this can be solved increasing the size (width and height) of the Axis.Labels.

swong
Newbie
Newbie
Posts: 24
Joined: Thu Jan 15, 2004 5:00 am

Post by swong » Sat Jan 24, 2004 1:01 am

Is there a way to determine what I need for a height and width value? The main form can be sized dynamically..


Thanks!

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Jan 27, 2004 11:41 am

Hi --

You can use code similar to the following to calculate axis width:

Code: Select all

Steema.TeeChart.Axis custom1 = new Steema.TeeChart.Axis(false, false, tChart1.Chart);
      
      tChart1.Aspect.View3D = false;
      tChart1.Axes.Custom.Add(custom1);
      custom1.RelativePosition = 50;
      line1.CustomVertAxis = custom1;
      line1.FillSampleValues(150);

      Bitmap bmp = tChart1.Bitmap;

      int axisWidth = custom1.AxisPen.Width + custom1.Ticks.Length + custom1.MaxLabelsWidth();
      tChart1.Header.Text = axisWidth.ToString();
Best regards,

Christopher Ireland
http://support.steema.com

swong
Newbie
Newbie
Posts: 24
Joined: Thu Jan 15, 2004 5:00 am

Post by swong » Tue Jan 27, 2004 8:02 pm

Thanks for the sample, although I still do not know how to move the axis so that it is inside the graph region. The property "custom1.Position" is read-only so I cannot set it directly.

Since I can't use the "Position" property, how can I programmatically shift the axis the required pixels? I guess I could calculate the RelativePosition I need based on:

(width of axis) / (width of graph) * 100

Although, don't think the chart.width property is returning the proper values.


Also, I've just discovered the "Printer.Resolution" which makes my printout different than the display.

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Fri Jan 30, 2004 11:10 am

Hi --
Since I can't use the "Position" property, how can I programmatically shift the axis the required pixels?
Well, you could try using the Steema.TeeChart.Axis.PositionUnits Property, e.g.

Code: Select all

    
private void Form1_Load(object sender, System.EventArgs e) {
      Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
      Steema.TeeChart.Styles.Line line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

      Steema.TeeChart.Axis axis1 = new Steema.TeeChart.Axis(false, false, tChart1.Chart);
      tChart1.Axes.Custom.Add(axis1);

      line1.FillSampleValues(20);
      line2.FillSampleValues(20);

      tChart1.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
      tChart1.Axes.Left.RelativePosition = 60;

      line2.CustomVertAxis = axis1;
      axis1.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
      axis1.RelativePosition = 60;
    }
Also, I've just discovered the "Printer.Resolution" which makes my printout different than the display.
OK, I'll look into this and get back to you.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply