0

i'm new of this forum. i want to make a chart with multiple chart area, every chart area has to be at the bottom of the previous one, i put my chart in a panel and i activate the autoscroll. but i saw the maximum size of Chart1.ChartAreas["ChartArea1" + i.ToString()].Position.Y is 100. my question is: how do i make multiple chart area in a column, every chartarea has to has a Height=50.

here my code:

        public List<double> lista = new List<double>();
        for (int i = 0; i < 5; i++)
        {
            Chart1.Series.Add("Series1" + i.ToString());
            Chart1.ChartAreas.Add("ChartArea1" + i.ToString());
            Chart1.Legends.Add("Legend1" + i.ToString());

            Chart1.Series[i].ChartArea = "ChartArea1" + i.ToString();
            Chart1.Series[i].ChartType = SeriesChartType.Spline;
            Chart1.Series[i].BorderWidth = 2;

            Chart1.ChartAreas["ChartArea1" + i.ToString()].AxisX.Title = "x";
            Chart1.ChartAreas["ChartArea1" + i.ToString()].AxisY.Title = "y";

            Chart1.ChartAreas["ChartArea1" + i.ToString()].Position.Auto = false; //customizare la posizione chartarea
            Chart1.ChartAreas["ChartArea1" + i.ToString()].Position.X = 0; //posizione x
            Chart1.ChartAreas["ChartArea1" + i.ToString()].Position.Y = 3 + 50 * i; //posizione y
            Chart1.ChartAreas["ChartArea1" + i.ToString()].Position.Height = 40; //altezza
            Chart1.ChartAreas["ChartArea1" + i.ToString()].Position.Width = 95; //larghezza

            lista.Clear();
            double numero;      
            for(int k = 0; k < 100; k++)
            {
                numero = Math.Cos(k) * Math.Sin(k);
                lista.Add(numero);
            }    

            foreach (var item in lista)
            {
                var index1 = Chart1.Series[i].Points.AddY(item);
            }
        }

i want to get something like in the picture enter image description here thanks for the help

McGrady
  • 10,869
  • 13
  • 47
  • 69
  • Note that Positions are always in percent of the surrounding chartelement. So you can't make 4x50 but rather 4x25 (or less if you want a chart title). Chart however doesn't support AutoScroll. You can make it large and nest it in AutoScrolling Panel, though. – TaW Aug 02 '17 at 15:45
  • Here is a pice of working code: `chart9.Height = panel1.ClientSize.Height * 2; chart9.Width = panel1.ClientSize.Width ;...for (int i = 0; i < chart9.ChartAreas.Count; i++) { ChartArea ca = chart9.ChartAreas[i]; ca.BackColor = Color.FromArgb(i*55, i*44, rnd.Next(256)); ca.Position = new ElementPosition(0, i * 25, 90, 25); ca.InnerPlotPosition = new ElementPosition(10, 0, 90, 100);}` – TaW Aug 02 '17 at 15:46
  • Note that I also set the `InnerPlotPosition` so the y-axes will have a common amout of space for their labels. – TaW Aug 02 '17 at 17:18
  • thanks! also i have found another solution here: https://stackoverflow.com/questions/37567374/how-can-i-align-the-innerplots –  Dec 06 '17 at 17:25

0 Answers0