Method to set starting Y value in Left Axes

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
toolbox
Newbie
Newbie
Posts: 12
Joined: Fri Mar 23, 2012 12:00 am

Method to set starting Y value in Left Axes

Post by toolbox » Fri Jun 22, 2012 8:41 pm

Is there a way to set the starting Y value where X/Y intersect? I have the need to show the lowest value from the Y Axis in the chart. I should note that this chart has both area and line within one chart. Also to note is that this is using the iOS Tchart library.

I have tried a couple different ways including:

Setting automatic to false and then specifying the left minimum and maximum values
areaLY.Chart.Axes.Left.Automatic = false;
areaLY.Chart.Axes.Left.Minimum = Math.Round(areaLY.Chart.Axes.Left.MinYValue);

lineTY.Chart.Axes.Left.Automatic = false;
lineTY.Chart.Axes.Left.Minimum = Math.Round(lineTY.Chart.Axes.Left.MinYValue);

areaLY.Chart.Axes.Left.Maximum = Math.Round(areaLY.Chart.Axes.Left.MaxYValue);
lineTY.Chart.Axes.Left.Maximum = Math.Round(lineTY.Chart.Axes.Left.MaxYValue);

The second method:

areaLY.Chart.Axes.Left.SetMinMax(Math.Round(areaLY.Chart.Axes.Left.MinYValue),areaLY.Chart.Axes.Left.MaxYValue);
lineTY.Chart.Axes.Left.SetMinMax(Math.Round(lineTY.Chart.Axes.Left.MinYValue),lineTY.Chart.Axes.Left.MaxYValue);

In the attached screen shot the lowest value is actually 932, so I want to show 900 where x/y intersect in the chart. Currently you'll see in the chart the starting value is 1000.
Attachments
ios tchart.jpg
ios tchart.jpg (24.8 KiB) Viewed 3477 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Method to set starting Y value in Left Axes

Post by Sandra » Tue Jun 26, 2012 11:59 am

Hello Toolbox,

Can you tell us if next code help you to solve your problem:

Code: Select all

     public Form1()
        {
            InitializeComponent();
            InitializeChart();
        } 
        Steema.TeeChart.Styles.Line lineTY;
        Steema.TeeChart.Styles.Area areaLY;
        private void InitializeChart()
        {
            double max, min;
            tChart1.Aspect.View3D = false;
            areaLY = new Area(tChart1.Chart);
            lineTY = new Line(tChart1.Chart);
    
            areaLY.Color = Color.Green;
            areaLY.Transparency = 50;
            lineTY.Color = Color.Red;
            lineTY.LinePen.Width = 2;
            tChart1.Axes.Left.Grid.Visible = false;
            areaLY.AreaLines.Visible = false;
            Random rnd = new Random();
            for (int i = 0; i < 52; i++)
            {
                areaLY.Add(i, rnd.Next(1500));
                lineTY.Add(i, rnd.Next(1500));
            }

            max = Math.Max(areaLY.MaxYValue(), lineTY.MaxYValue());
            min = Math.Min(areaLY.MinYValue(), lineTY.MinYValue());

            tChart1.Axes.Left.SetMinMax(min, max);
Note, that my code is in Winforms and you need adapt it to TeeChart for iOs. Also, can help you to achieve as you want is change the Min/Max offset value,e.g change 0 to 1.

Thanks,

Post Reply