Page 1 of 1

Custom Axis Pixels

Posted: Sun Dec 24, 2006 2:02 pm
by 9642161
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

Posted: Wed Dec 27, 2006 9:06 am
by Chris
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);
    }

Posted: Wed Dec 27, 2006 1:53 pm
by 9642161
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.

Posted: Wed Dec 27, 2006 2:44 pm
by Chris
Hello,

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

Many thanks!

Posted: Wed Dec 27, 2006 11:56 pm
by 9642161
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

Posted: Thu Dec 28, 2006 9:37 am
by Chris
Hello!

Got it! OK, I can reproduce this and have fixed it for the next maintenance release.