Gallery
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender,EventArgs e)
{
Chart.Type = ChartType.Combo;//Horizontal;
Chart.Width = 600;
Chart.Height = 350;
Chart.TempDirectory = "temp";
Chart.Debug = true;
// Demonstrates advanced legend entry header features.
// *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();
// Instantiate a legend entry to be our first header.
LegendEntry header1 = new LegendEntry("Group A","Value","The Icon");
// Notice we used a constructor that takes a string for the icon. This can also be done by adding an attribute with
// a 'icon' key' like so:
header1.CustomAttributes = "Icon=The Icon";
// Now we'll instantiate our second header entry.
LegendEntry header2 = new LegendEntry("Group B","Value","The Icon");
header2.CustomAttributes = "Icon=The Icon";
// We'll add some additional padding at the top of each header.
header1.PaddingTop = 5;
header2.PaddingTop = 5;
// Specify a divider line color.
header1.DividerLine.Color = Color.Black;
header2.DividerLine.Color = Color.Black;
// Set a different font and color for the headers.
header1.LabelStyle.Font = new Font("Arial",8,FontStyle.Bold);
header2.LabelStyle.Font = new Font("Arial",8,FontStyle.Bold);
header1.LabelStyle.Color = Color.DarkBlue;
header2.LabelStyle.Color = Color.DarkBlue;
// This will demonstrate how a header can start a new column.
header2.HeaderMode = LegendEntryHeaderMode.StartNewColumn;
// We have our headers but since they are normal legend entries we must ensure they are placed before
// the series they represent. Each legend entry sort order is by default 0 so for the first entry
// we set the sort order to -1. Then series mySC[0] and mySC[1] will follow.
header1.SortOrder = -1;
// Now the second entry order we'll set to 1 so if follows the first group and set the sort order of the series
// it represents to 2.
header2.SortOrder = 1;
mySC[2].LegendEntry.SortOrder = 2;
mySC[3].LegendEntry.SortOrder = 2;
//Finally we add the header entries to our box.
Chart.LegendBox.ExtraEntries.Add(header1);
Chart.LegendBox.ExtraEntries.Add(header2);
// Add the random data.
Chart.SeriesCollection.Add(mySC);
}
SeriesCollection getRandomData()
{
SeriesCollection SC = new SeriesCollection();
Random myR = new Random();
for(int a = 1; a < 5; a++)
{
Series s = new Series();
s.Name = "Series " + a;
for(int b = 1; b < 5; 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);
}
return SC;
}
</script>
</head>
<body>
<div style="text-align:center">
<dotnet:Chart id="Chart" runat="server" Width="568px" Height="344px">
</dotnet:Chart>
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Chart.Type = ChartType.Combo 'Horizontal;
Chart.Width = 600
Chart.Height = 350
Chart.TempDirectory = "temp"
Chart.Debug = True
' Demonstrates advanced legend entry header features.
' *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()
' Instantiate a legend entry to be our first header.
Dim header1 As LegendEntry = New LegendEntry("Group A","Value","The Icon")
' Notice we used a constructor that takes a string for the icon. This can also be done by adding an attribute with
' a 'icon' key' like so:
header1.CustomAttributes = "Icon=The Icon"
' Now we'll instantiate our second header entry.
Dim header2 As LegendEntry = New LegendEntry("Group B","Value","The Icon")
header2.CustomAttributes = "Icon=The Icon"
' We'll add some additional padding at the top of each header.
header1.PaddingTop = 5
header2.PaddingTop = 5
' Specify a divider line color.
header1.DividerLine.Color = Color.Black
header2.DividerLine.Color = Color.Black
' Set a different font and color for the headers.
header1.LabelStyle.Font = New Font("Arial",8,FontStyle.Bold)
header2.LabelStyle.Font = New Font("Arial",8,FontStyle.Bold)
header1.LabelStyle.Color = Color.DarkBlue
header2.LabelStyle.Color = Color.DarkBlue
' This will demonstrate how a header can start a new column.
header2.HeaderMode = LegendEntryHeaderMode.StartNewColumn
' We have our headers but since they are normal legend entries we must ensure they are placed before
' the series they represent. Each legend entry sort order is by default 0 so for the first entry
' we set the sort order to -1. Then series mySC[0] and mySC[1] will follow.
header1.SortOrder = -1
' Now the second entry order we'll set to 1 so if follows the first group and set the sort order of the series
' it represents to 2.
header2.SortOrder = 1
mySC(2).LegendEntry.SortOrder = 2
mySC(3).LegendEntry.SortOrder = 2
'Finally we add the header entries to our box.
Chart.LegendBox.ExtraEntries.Add(header1)
Chart.LegendBox.ExtraEntries.Add(header2)
' Add the random data.
Chart.SeriesCollection.Add(mySC)
End Sub
Function getRandomData() As SeriesCollection
Dim SC As SeriesCollection = New SeriesCollection()
Dim myR As Random = New Random()
For a As Integer = 1 To 4
Dim s As Series = New Series()
s.Name = "Series " & a
For b As Integer = 1 To 4
Dim e As Element = 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
Return SC
End Function
</script>
</head>
<body>
<div style="text-align:center">
<dotnet:Chart id="Chart" runat="server" Width="568px" Height="344px">
</dotnet:Chart>
</div>
</body>
</html>
- Sample FilenameLegendBoxCustomHeader.aspx
- VersionLegacy (Pre 3.0)
- Uses DatabaseNo