Page 1 of 1

Extra value margin added to scale(s)

Posted: Wed Nov 09, 2011 3:40 pm
by 16060157
There is an extra margin added to the scale compared to the configured scale min/max values.
See the attached picture.

Is there a way to configure that the scale min/max correspond to the min/max properties?

Re: Extra value margin added to scale(s)

Posted: Thu Nov 10, 2011 10:00 am
by 10050769
Hello BeijerElectronics,

I have made a simple code that works fine for me. Can you tell if next code works as you expected?

Code: Select all

          Steema.TeeChart.Styles.Bar bar1 = new Bar (tChart1.Chart);
            tChart1.Aspect.View3D = false;
            Random rnd = new Random();
       
             for (int i = 0; i < 50; i  )
            {
                
                if (i > 0 && i < 25)
                {
                    bar1.Add(-i, rnd.Next(100));
                   
                }
                else if (i >=25)
                {
                    bar1.Add(i, rnd.Next(100));
                }
                else if (i == 0)
                {
                    bar1.Add(i, rnd.Next(100));
                }
              
            }

             bar1.SideMargins = false;
             tChart1.Axes.Left.SetMinMax(bar1.YValues.Minimum, bar1.YValues.Maximum-1);
             tChart1.Axes.Bottom.SetMinMax(bar1.XValues.Minimum-1, bar1.XValues.Maximum);

             tChart1.Axes.Bottom.Labels.Angle = 90;
         
        }
If previous code doesn't make as you want and your problem isn't appears try to arrange us a simple code so we can reproduce exactly your problem and try to give a good answer for it.

On the other hand, also may be your problem would appears, because your MinimumOffset i MaximumOffset of Axes, set differents to 0 and I recommend you change it to 0 as do in next code:

Code: Select all

    
           tChart1.Axes.Left.MaximumOffset = 0;
            tChart1.Axes.Left.MinimumOffset = 0;
            tChart1.Axes.Bottom.MaximumOffset = 0;
            tChart1.Axes.Bottom.MinimumOffset = 0;
I hope will helps.

Thanks,

Re: Extra value margin added to scale(s)

Posted: Fri Nov 11, 2011 11:25 am
by 16060157
Hello Sandra,

Thanks for your reply.

These minimum and maximum offset values on the Axes are default set to 0, so that does not help.
The problem is very easy to reproduce, simply add some Y values to a bar chart and set a maximum Y value to 100, then when running the application the chart will most often add some extra “offset” value to the maximum Y on the axis so that it states 110 for example, instead of 100 as wanted.

Re: Extra value margin added to scale(s)

Posted: Fri Nov 11, 2011 12:07 pm
by 10050769
Hello BeijerElectronics,

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

Code: Select all

 Steema.TeeChart.Styles.Bar bar1 = new Bar (tChart1.Chart);
            tChart1.Aspect.View3D = false;
            Random rnd = new Random();

            for (int i = 0; i < 50; i++)
            {
                bar1.Add(i,rnd.Next(100));
            }
            bar1.Add(50, 100);


            bar1.Marks.Visible = false;
}
Can you check if previous code works as you expected? And also, can you please, tell us which version of TeeChart.Net are you using?

Thanks,

Re: Extra value margin added to scale(s)

Posted: Fri Nov 11, 2011 1:06 pm
by 16060157
Hello,

We use 4.1.2011.10192

Re: Extra value margin added to scale(s)

Posted: Fri Nov 11, 2011 3:29 pm
by narcis
Hi BeijerElectronics,

Does the code Sandra posted reproduces the problem at your end? If the problem persists please attach a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.

Re: Extra value margin added to scale(s)

Posted: Wed Nov 16, 2011 2:32 pm
by 16060157
Hi,

The solution seems to be this row:

bar.Marks.Visible = false;

What does it do? Disables the "balloon" tooltips above each bar? So the only way to get the specific minimum and maximum value specified is when disabling the marks, is this a correct behavior?

Re: Extra value margin added to scale(s)

Posted: Thu Nov 17, 2011 2:28 pm
by 10050769
Hello BeijerElectronics,

I think can help you know bar series have property bar.Xvalues.MaxValue, bar.Xvalues.MinValue, bar.Yvalues.MaxValue, bar.Yvalues.MinValue that allow you to fix the size of Axes with specific values of Series. On the other hand, if it isn't a solution for you, please send us a simple project for us, so we can try to give you a good answer about your problem.

Thanks,

Re: Extra value margin added to scale(s)

Posted: Wed Nov 23, 2011 10:40 am
by 16060157
Hi,

The MinValue and MaxValue properties on XValues and YValues on a series are readonly and cannot be assigned.

This sample shows the problem, but disabling the Marks property solves the problem but what if I want the Marks visible also?

Code: Select all

           var bar = new Bar();
            tChart1.Series.Add(bar);

            tChart1.Axes.Left.Minimum = 0;
            tChart1.Axes.Left.Maximum = 100;

            Random rnd = new Random();

            double[] xValues = new double[51];
            double[] yValues = new double[51];

            for (int i = 0; i < 50; i++)
            {
                xValues[i] = i;
                yValues[i] = rnd.Next(100);
            }

            xValues[50] = 50;
            yValues[50] = 100;

            bar.Add(xValues, yValues);

            //bar.Marks.Visible = false;

Re: Extra value margin added to scale(s)

Posted: Wed Nov 23, 2011 12:25 pm
by 10050769
Hello BeijerElectronics,

Ok. I think you can solve your problem changing the MaximumOffset or MinimOffset. In your case I recommend change MaximumOffset from 0 to 1 as do in next example:

Code: Select all

        private void InitializeChart()
        {
              var bar = new Bar();
            tChart1.Series.Add(bar);

            tChart1.Axes.Left.Automatic = false;
            tChart1.Axes.Left.Minimum = 0;
            tChart1.Axes.Left.Maximum = 100;
            tChart1.Axes.Left.MaximumOffset = 1;

            Random rnd = new Random();

            double[] xValues = new double[51];
            double[] yValues = new double[51];

            for (int i = 0; i < 50; i++)
            {
                xValues[i] = i;
                yValues[i] = rnd.Next(100);
            }

            xValues[50] = 50;
            yValues[50] = 100;

            bar.Add(xValues, yValues);

       //     bar.Marks.Visible = false;
           // tChart1.Aspect.ClipPoints = false;
            
        }
Can you please, tell us if previous code works as you expect?

Thanks,