Autoscaling problem with multiple series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
charlesw
Newbie
Newbie
Posts: 14
Joined: Sun Mar 09, 2003 5:00 am
Location: ithaca, ny

Autoscaling problem with multiple series

Post by charlesw » Fri Nov 22, 2013 6:51 pm

I created a chart with six fastline series and only the first series controls the y-axis (left axis) scaling. Is there a way to have the chart auto-scale based on data from all the series?

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

Re: Autoscaling problem with multiple series

Post by Sandra » Mon Nov 25, 2013 10:45 am

Hello Charlesw,

I think you can find the Minimum and Maximum of all series and using SetMinMax define the Minimum and Maxium of the series and have scale based in all the series. You can do something as next:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    private void InitializeChart()
    {
      for (int i = 0; i < 6; i++)
      {
        tChart1.Aspect.View3D = false; 
        new FastLine(tChart1.Chart);
        tChart1[i].FillSampleValues(100);
      }
      SetAxisLeftMinAndMaxSeries();
      button1.Click += button1_Click;
    }

    void button1_Click(object sender, EventArgs e)
    {
      
      tChart1.ShowEditor(); 
    }

    private void SetAxisLeftMinAndMaxSeries()
    {
      double Min,Max;
      Min = 0; 
      Max=0; 
      for(int i=0; i<tChart1.Series.Count-1; ++i)
      {
        Min = tChart1[i].YValues.Minimum;
        Max = tChart1[i].YValues.Maximum; 
        if (Math.Min(tChart1[i].YValues.Minimum, tChart1[i + 1].YValues.Minimum)<Min)
        {
          Min = Math.Min(tChart1[i].YValues.Minimum, tChart1[i + 1].YValues.Minimum);
        }

        if (Max< Math.Max(tChart1[i].YValues.Maximum, tChart1[i + 1].YValues.Maximum))
        {
          Max = Math.Max(tChart1[i].YValues.Maximum, tChart1[i + 1].YValues.Maximum);
        }
      }
      tChart1.Axes.Left.SetMinMax(Min, Max); 
    }
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

charlesw
Newbie
Newbie
Posts: 14
Joined: Sun Mar 09, 2003 5:00 am
Location: ithaca, ny

Re: Autoscaling problem with multiple series

Post by charlesw » Mon Nov 25, 2013 4:24 pm

Sandra,

Thanks very much for your reply, it was very helpful.

Your implied response was that auto-scaling multiple series in the same chart is not supported at design time but must be customer-coded. So I wrote an auto-scaling, run-time algorithm, based on your suggestion, and that worked.

It also fixed the chart crashing when any other series than the first was selected. I should mention that the user can select any combination of the six series to display; all six are not always displayed.

Thank you for your time,
Alex Specker--using CharlesW login

Post Reply