See Also

ChartArea Members  | dotnetCHARTING Namespace

Language

Visual Basic

C#

Show All

See Also Languages dotnetCHARTING Send comments on this topic.

ChartArea Class

Represents an area on which series and elements are plotted.

For a list of all members of this type, see ChartArea members.

Object Model















Inheritance Hierarchy

System.Object
   dotnetCHARTING.ChartArea

Syntax

[Visual Basic]
Public Class ChartArea
[C#]
public class ChartArea

Example

[C#] 

<%@ Page Language="C#" Description="dotnetCHARTING Component" %> 
<%@ Register TagPrefix="dotnet"  Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%> 
<%@ Import Namespace="System.Drawing" %> 
<HTML> 
    <HEAD> 
        <TITLE>.netCHARTING Sample</TITLE> 
        <script runat="server"> 
 
void Page_Load(Object sender,EventArgs e) 

 
    Chart.Type = ChartType.Combo;//Horizontal; 
    Chart.Width = 500; 
    Chart.Height = 350; 
    Chart.TempDirectory = "temp"; 
    Chart.Debug = true; 
     
     
    // This sample will demonstrate how to control the sizes of differnt areas. 
     
    // *DYNAMIC DATA NOTE*  
    // This sample uses random data to populate the chart. To populate  
    // a chart with database data see the following resources: 
    // - Classic samples folder 
    // - Help File > Data Tutorials 
    // - Sample: features/DataEngine.aspx 
    SeriesCollection mySC = getRandomData(); 
 
    // Create the second chart area and add a series to it. 
    ChartArea ca1 = new ChartArea(); 
 
    ca1.SeriesCollection.Add(mySC[0]); 
 
    // This line specifies that our new area is to be 20% of the total height alloted for chart areas. 
    // The main area will size accordingly since we dont specify a size for it. 
    ca1.HeightPercentage = 20; 
     
    ca1.TitleBox.Label.Text = "This area's vertical size is 20%"; 
    Chart.Title = "This area's vertical size is 80%"; 
     
    // Add the new area to the chart. 
    Chart.ExtraChartAreas.Add(ca1);     
 
    // Add random data to the main chart area. 
    Chart.SeriesCollection.Add(mySC[1]); 
     

 
SeriesCollection getRandomData() 

    SeriesCollection SC = new SeriesCollection(); 
    Random myR = new Random(); 
    for(int a = 0; a < 4; a++) 
    { 
        Series s = new Series(); 
        s.Name = "Series " + a; 
        for(int b = 0; b < 4; b++) 
        { 
            Element e = new Element(); 
            e.Name = "Element " + b; 
            //e.YValue = -25 + myR.Next(50); 
            e.YValue = myR.Next(50); 
            s.Elements.Add(e); 
        } 
        SC.Add(s); 
    } 
 
    // Set Different Colors for our Series 
    SC[0].DefaultElement.Color = Color.FromArgb(49,255,49); 
    SC[1].DefaultElement.Color = Color.FromArgb(255,255,0); 
    SC[2].DefaultElement.Color = Color.FromArgb(255,99,49); 
    SC[3].DefaultElement.Color = Color.FromArgb(0,156,255); 
 
    return SC; 

        </script> 
    </HEAD> 
    <BODY> 
        <DIV align="center"> 
            <dotnet:Chart id="Chart" runat="server" Width="568px" Height="344px"> 
            </dotnet:Chart> 
        </DIV> 
    </BODY> 
</HTML> 

[Visual Basic] 

<%@ Page Language="VB" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<HTML>
    <HEAD>
        <TITLE>.netCHARTING Sample</TITLE>
        <script runat="server">


Sub Page_Load(sender As [Object], e As EventArgs)

   Chart.Type = ChartType.Combo 'Horizontal;
   Chart.Width = Unit.Parse(500)
   Chart.Height = Unit.Parse(350)
   Chart.TempDirectory = "temp"
   Chart.Debug = True


   ' This sample will demonstrate how to control the sizes of differnt areas.
   ' *DYNAMIC DATA NOTE*
   ' This sample uses random data to populate the chart. To populate
   ' a chart with database data see the following resources:
   ' - Classic samples folder
   ' - Help File > Data Tutorials
   ' - Sample: features/DataEngine.aspx
   Dim mySC As SeriesCollection = getRandomData()

   ' Create the second chart area and add a series to it.
   Dim ca1 As New ChartArea()

   ca1.SeriesCollection.Add(mySC(0))

   ' This line specifies that our new area is to be 20% of the total height alloted for chart areas.
   ' The main area will size accordingly since we dont specify a size for it.
   ca1.HeightPercentage = 20

   ca1.TitleBox.Label.Text = "This area's vertical size is 20%"
   Chart.Title = "This area's vertical size is 80%"

   ' Add the new area to the chart.
   Chart.ExtraChartAreas.Add(ca1)

   ' Add random data to the main chart area.
   Chart.SeriesCollection.Add(mySC(1))
End Sub 'Page_Load


Function getRandomData() As SeriesCollection
   Dim SC As New SeriesCollection()
   Dim myR As New Random()
   Dim a As Integer
   For a = 0 To 3
      Dim s As New Series()
      s.Name = "Series " & a
      Dim b As Integer
      For b = 0 To 3
         Dim e As New Element()
         e.Name = "Element " & b
         'e.YValue = -25 + myR.Next(50);
         e.YValue = myR.Next(50)
         s.Elements.Add(e)
      Next b
      SC.Add(s)
   Next a

   ' Set Different Colors for our Series
   SC(0).DefaultElement.Color = Color.FromArgb(49, 255, 49)
   SC(1).DefaultElement.Color = Color.FromArgb(255, 255, 0)
   SC(2).DefaultElement.Color = Color.FromArgb(255, 99, 49)
   SC(3).DefaultElement.Color = Color.FromArgb(0, 156, 255)

   Return SC
End Function 'getRandomData
        </script>
    </HEAD>
    <BODY>
        <DIV align="center">
            <dotnet:Chart id="Chart" runat="server" Width="568px" Height="344px">
            </dotnet:Chart>
        </DIV>
    </BODY>
</HTML>

See Also

ChartArea Members  | dotnetCHARTING Namespace

 

 


2002 - 2005 Webavail Productions Inc. & Corporate Web Solutions Ltd.. All Rights Reserved.