Page 1 of 1

Axis.Automatic with a margin

Posted: Thu Oct 28, 2010 8:06 am
by 8741807
Hi,

when I have Axis.Automatic = true and there are two lines assigned to this axis and the first runs at y=1 and the second at y=3 then my axis min will be 1 and my max will be 3. The problem is when my series are just straight lines they are not visible because they are exactly at the borders of the chart. So i would need some kind of margin so that the min/max of the axis is always some pixels more than the actual min/max.

How can I do this? Is there a build-in functionality for this?

Re: Axis.Automatic with a margin

Posted: Thu Oct 28, 2010 9:01 am
by 8741807
Okay, I've found it! :) Axis.MinimumOffset & Axis.MaximumOffset do the job perfectly.

Re: Axis.Automatic with a margin

Posted: Thu Oct 28, 2010 10:26 am
by 10050769
Hello ctusch,

I am glad that you found a solution for your problem :).

Thanks,

Re: Axis.Automatic with a margin

Posted: Tue Dec 21, 2010 9:21 am
by 8741807
Hello,

seems like I was too hasty. Axis.MinimumOffset & Axis.MaximumOffset work only when Axis.Automatic is set to false. That's a big problem as one of our customers needs automatic axis scaling. What can I do about this?

Re: Axis.Automatic with a margin

Posted: Tue Dec 21, 2010 1:03 pm
by 10050769
Hello ctusch,

I couldn't reproduce your problem using last version of TeeChart.Net and next code:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private Steema.TeeChart.Styles.Line line1, line2;
        Steema.TeeChart.TChart tChart1;
        Steema.TeeChart.ChartController ChartController;
        private void InitializeChart()
        {
           this.tChart1 = new Steema.TeeChart.TChart();
           
           this.ChartController = new Steema.TeeChart.ChartController();
            this.Controls.Add(tChart1);
            this.Controls.Add(ChartController);
            this.tChart1.Left = 100;
            this.tChart1.Top = 50;
            ChartController.Chart = tChart1;
            tChart1.Aspect.View3D = false;
            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Random rnd = new Random();
            for (int i = 0; i < 10; i  )
            {
                line1.Add(i, rnd.Next(10));
                line2.Add(i, rnd.Next(10));
              
            }

            tChart1.Axes.Left.MinimumOffset = 50;
            tChart1.Axes.Left.MaximumOffset = 70;
Please, check if previous code works as you want? If it doesn't work for you could you tell us which version of TeeChart.Net are you using.

Thanks,

Re: Axis.Automatic with a margin

Posted: Tue Dec 21, 2010 1:23 pm
by 8741807
It doesn't work here, it looks like this:
tchart.png
tchart.png (16.78 KiB) Viewed 6536 times
I'm using version 3.5.3700.30575.

Re: Axis.Automatic with a margin

Posted: Tue Dec 21, 2010 2:55 pm
by 10050769
Hello ctusch,

Your problem is solved in last version of TeeChart.Net (version 4) and in it version works correctly. For version 3 there are a workaround using StartPosition and EndPosition:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        private Steema.TeeChart.Styles.Line line1, line2;
        Steema.TeeChart.ChartController ChartController;
        private void InitializeChart()
        {
            this.tChart1 = new Steema.TeeChart.TChart();
            this.ChartController = new Steema.TeeChart.ChartController();
            this.Controls.Add(tChart1);
            this.Controls.Add(ChartController);
            this.tChart1.Left = 100;
            this.tChart1.Top = 50;
            ChartController.Chart = tChart1;
            tChart1.Aspect.View3D = false;
            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Random rnd = new Random();
            for (int i = 0; i < 10; i++)
            {
                line1.Add(i, rnd.Next(10));
                line2.Add(i, rnd.Next(10));

            }
            tChart1.Axes.Left.StartPosition = 10;
            tChart1.Axes.Left.EndPosition = 95;
        }
    
Could you please, tell us if previous code is a good solution for you?

I hope will helps.

Thanks,

Re: Axis.Automatic with a margin

Posted: Tue Dec 21, 2010 3:18 pm
by 8741807
Hello Sandra,

your workaround works, thanks for your help!