Custom Axis Pixels

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
histry
Newbie
Newbie
Posts: 79
Joined: Thu Aug 10, 2006 12:00 am

Custom Axis Pixels

Post by histry » Sun Dec 24, 2006 2:02 pm

I created 2 custom axis assigned a series to each. I set the Units to Pixels and what I am finding is the start and end position is picking up pixels not percent. I assume by the labels that position should be the only property that is associate with pixels.

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 » Wed Dec 27, 2006 9:06 am

Hello!

The Steema.TeeChart.Axis.PositionUnits property will effect the units of all calculations to do with the positioning of axes on the chart. If you want to still work with percentages when you have selected pixels, you can 'manually' convert one to the other as in the example below:

Code: Select all

    private void InitializeChart()
    {
      Steema.TeeChart.Styles.Line line1;
      Steema.TeeChart.Styles.Line line2;
      Steema.TeeChart.Axis custom1;
      Steema.TeeChart.Axis custom2;

      tChart1.Aspect.View3D = false;
      tChart1.Panel.MarginLeft = 10;
      tChart1.Panel.MarginRight = 10;
      tChart1.Legend.Visible = false;

      tChart1.Series.Add(line1 = new Steema.TeeChart.Styles.Line());
      tChart1.Series.Add(line2 = new Steema.TeeChart.Styles.Line());

      tChart1.Axes.Custom.Add(custom1 = new Steema.TeeChart.Axis());
      tChart1.Axes.Custom.Add(custom2 = new Steema.TeeChart.Axis());

      custom1.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
      custom2.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;

      line1.CustomVertAxis = custom1;
      custom2.OtherSide = true;
      line2.CustomVertAxis = custom2;

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

      Bitmap bmp = tChart1.Bitmap;  //redraw chart to extract chartrect
      Rectangle rect = tChart1.Chart.ChartRect;

      custom1.StartPosition = ConvertPixelToPercent(rect.Height, 50);
      custom2.StartPosition = ConvertPixelToPercent(rect.Height, 50);

      custom1.EndPosition = ConvertPixelToPercent(rect.Height, 100);
      custom2.EndPosition = ConvertPixelToPercent(rect.Height, 100);
    }


    private int ConvertPixelToPercent(int ChartHeight, int PercentPos)
    {
      double result = ChartHeight / 100.0;
      result *= PercentPos;
      return Steema.TeeChart.Utils.Round(result);
    }
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/

histry
Newbie
Newbie
Posts: 79
Joined: Thu Aug 10, 2006 12:00 am

Post by histry » Wed Dec 27, 2006 1:53 pm

If I look at the properties and change the Units from Percent to Pixel the Start and End maintain a percentage description. The other issue is that you then should allow the person to add a pixel number in start and end that exceeds 100.

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 » Wed Dec 27, 2006 2:44 pm

Hello,

Would you be so kind as to modify my example above so that I can reproduce your issue?

Many thanks!
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/

histry
Newbie
Newbie
Posts: 79
Joined: Thu Aug 10, 2006 12:00 am

Post by histry » Wed Dec 27, 2006 11:56 pm

The code works great. It the property dialog that that is the issue. If I set the property in design mode using the dislog window the labels still display % for start and end and you cannot enter a number greater than 100.

Take care

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 » Thu Dec 28, 2006 9:37 am

Hello!

Got it! OK, I can reproduce this and have fixed it for the next maintenance release.
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