.NET Framework Developer Center > .NET Development Forums > Chart Controls for .NET Framework > how to calculate size of chart and ChartArea control
Ask a questionAsk a question
 

Answerhow to calculate size of chart and ChartArea control

  • Thursday, November 05, 2009 11:20 AMHemal Kotak Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    C#, Winforms
    scenario : how to set the size of chart control dynamically, and fixing the size of multiple chartareas?
    when number of chartareas increases the chart control's size also should increase!

    which event and how to implement ?

    any suggestion?

    Hems

Answers

  • Friday, November 06, 2009 6:13 AMHemal Kotak Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    this is what i have done.


    [ in loop ]
    chartArea[i].Position.Auto =true;
                        
    chartArea[i].AlignmentOrientation = AreaAlignmentOrientations.Vertical;
    if (i == 0)
           chartArea[i].AlignWithChartArea = chartArea[i].Name;
    else
           chartArea[i].AlignWithChartArea = chartArea[i - 1].Name;

    now even if i increase the height of chart control all chartareas getting big size but it is not allowing more chart areas, and if i remove " chartArea[i].AlignWithChartArea" property setting, charareas are coming but if more than 3 chartarea then 2nd column likewise...

    my exact requirement  is to get all the chartareas in single column only with scrollbar, irrespective of number of chartareas.

    Hems

All Replies

  • Thursday, November 05, 2009 2:21 PMDhruv Patel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The ChartArea's points automatically gets their proper height based on Chart Control's height.

    So, try setting Chart's height as there is no Height property for ChartArea - coz there can be multiple series/chartareas in single Chart Control.
    Dhruv Patel
    [ Email : mail2dhruv@rocketmail.com ]
    Please Mark As Answer if you think the answer was correct.
  • Friday, November 06, 2009 6:13 AMHemal Kotak Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    this is what i have done.


    [ in loop ]
    chartArea[i].Position.Auto =true;
                        
    chartArea[i].AlignmentOrientation = AreaAlignmentOrientations.Vertical;
    if (i == 0)
           chartArea[i].AlignWithChartArea = chartArea[i].Name;
    else
           chartArea[i].AlignWithChartArea = chartArea[i - 1].Name;

    now even if i increase the height of chart control all chartareas getting big size but it is not allowing more chart areas, and if i remove " chartArea[i].AlignWithChartArea" property setting, charareas are coming but if more than 3 chartarea then 2nd column likewise...

    my exact requirement  is to get all the chartareas in single column only with scrollbar, irrespective of number of chartareas.

    Hems
  • Saturday, November 07, 2009 1:35 PMsipla Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Explicitly set the position of each chart area the way you want using ChartArea.Position . You have to manually increase the size of the chart using Chart.Height each time you add a chart area if this is what you want.

    This thread already has the answer you want along with an example.