Gallery
JS Box Positions
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Collections.Generic" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates annotations showing how items are positioned and stacked around the chartArea.
// Set the size
Chart.Width = 920;
Chart.Height = 440;
// Set the temp directory
Chart.TempDirectory = "temp";
// Debug mode. ( Will show generated errors if any )
Chart.Debug = true;
Chart.Palette = new Color[] { };//prevent setting DNC default palette
Chart.DefaultBox.ClearColors();
Chart.ChartArea.Line.Color = Color.LightGray;
Chart.Annotations.Add(GetAnnotations());
//JS settings
Chart.JS.Enabled = true;
Chart.JS.Settings.Add("defaultAnnotation.margin","4");
}
AnnotationCollection GetAnnotations()
{
AnnotationCollection ac = new AnnotationCollection();
string[] pos = "top left,top,top right,right top,right,bottom right,right bottom,bottom,bottom left,left bottom,left,left top".Split(',');
List<string> positions = new List<string>(pos);
Annotation an1 = new Annotation("Annotation, uiItems, and legend <br>positioning layout around the chartArea.");
an1.Position = "inside center";
an1.Label.Alignment = StringAlignment.Center;
an1.ClearColors();
ac.Add(an1);
foreach (var position in positions)
{
Annotation an = new Annotation( position +" 1");
an.Position = position;
ac.Add(an);
}
positions.Add("center");
foreach (var position in positions)
{
Annotation an = new Annotation("inside " + position + " 1");
an.Position = "inside " + position;
ac.Add(an);
}
// Double the annotations.
foreach (var position in positions)
{
Annotation an = new Annotation(position + " 2");
an.Position = position;
ac.Add(an);
}
foreach (var position in positions)
{
Annotation an = new Annotation("inside " + position + " 2");
an.Position = "inside " + position;
ac.Add(an);
}
return ac;
}
</script>
<script type="text/javascript">
</script>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Collections.Generic" %>
<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)
' Demonstrates annotations showing how items are positioned and stacked around the chartArea.
' Set the size
Chart.Width = 920
Chart.Height = 440
' Set the temp directory
Chart.TempDirectory = "temp"
' Debug mode. ( Will show generated errors if any )
Chart.Debug = True
Chart.Palette = New Color() { } 'prevent setting DNC default palette
Chart.DefaultBox.ClearColors()
Chart.ChartArea.Line.Color = Color.LightGray
Chart.Annotations.Add(GetAnnotations())
'JS settings
Chart.JS.Enabled = True
Chart.JS.Settings.Add("defaultAnnotation.margin","4")
End Sub
Function GetAnnotations() As AnnotationCollection
Dim ac As AnnotationCollection = New AnnotationCollection()
Dim pos As String() = "top left,top,top right,right top,right,bottom right,right bottom,bottom,bottom left,left bottom,left,left top".Split(","c)
Dim positions As List(Of String) = New List(Of String)(pos)
Dim an1 As Annotation = New Annotation("Annotation, uiItems, and legend <br>positioning layout around the chartArea.")
an1.Position = "inside center"
an1.Label.Alignment = StringAlignment.Center
an1.ClearColors()
ac.Add(an1)
For Each Dim position In positions
Dim an As Annotation = New Annotation(position & " 1")
an.Position = position
ac.Add(an)
Next position
positions.Add("center")
For Each Dim position In positions
Dim an As Annotation = New Annotation("inside " & position & " 1")
an.Position = "inside " & position
ac.Add(an)
Next position
' Double the annotations.
For Each Dim position In positions
Dim an As Annotation = New Annotation(position & " 2")
an.Position = position
ac.Add(an)
Next position
For Each Dim position In positions
Dim an As Annotation = New Annotation("inside " & position & " 2")
an.Position = "inside " & position
ac.Add(an)
Next position
Return ac
End Function
</script>
<script type="text/javascript">
</script>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsBoxPositions.aspx
- Version9.1
- Uses DatabaseNo