Gallery
Image Zoomer Date Time Labels
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender,EventArgs e)
{
// Demonstrates using Ajax zooming with time label automation.
Chart.Width = 600;
Chart.Height = 400;
Chart.TempDirectory = "temp";
Chart.Title = "Sales totals";
Chart.Debug = true;
// Enable Scrolling
Chart.XAxis.Viewport.TimeInterval = new TimeIntervalAdvanced(new TimeSpan(30, 0, 0, 0));
Chart.Zoomer.Enabled = true;
Chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
Chart.LegendBox.Template = "%Icon%Name";
Chart.DefaultElement.Marker.Size = 5;
Chart.DefaultSeries.DefaultElement.Transparency = 30;
Chart.DefaultSeries.Type = SeriesType.AreaLine;
Chart.YAxis.Scale = Scale.Stacked;
Chart.YAxis.Label.Text = "Products sold";
// Modify the x axis labels.
Chart.XAxis.Scale = Scale.Time;
Chart.XAxis.TimeScaleLabels.Mode = TimeScaleLabelMode.Dynamic;
Chart.XAxis.TimeScaleLabels.DayFormatString = "o";
Chart.XAxis.TimeScaleLabels.MonthFormatString = "MMM";
Chart.XAxis.TimeInterval = TimeInterval.Day;
Chart.XAxis.TimeScaleLabels.RangeIntervals.Add(TimeInterval.Month);
// *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();
// 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();
DateTime startDT = new DateTime(2020,1,1);
s.Name = "Product " + a.ToString();
for(int b = 0; b < 101; b++)
{
Element e = new Element();
e.XDateTime = startDT;
startDT = startDT.AddDays(1);
e.YValue = myR.Next(50);
s.Elements.Add(e);
}
SC.Add(s);
}
return SC;
}
</script>
</head>
<body>
<center>
<dotnet:Chart id="Chart" runat="server"/>
</center>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<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 using Ajax zooming with time label automation.
Chart.Width = 600
Chart.Height = 400
Chart.TempDirectory = "temp"
Chart.Title = "Sales totals"
Chart.Debug = True
' Enable Scrolling
Chart.XAxis.Viewport.TimeInterval = New TimeIntervalAdvanced(New TimeSpan(30, 0, 0, 0))
Chart.Zoomer.Enabled = True
Chart.TitleBox.Position = TitleBoxPosition.FullWithLegend
Chart.LegendBox.Template = "%Icon%Name"
Chart.DefaultElement.Marker.Size = 5
Chart.DefaultSeries.DefaultElement.Transparency = 30
Chart.DefaultSeries.Type = SeriesType.AreaLine
Chart.YAxis.Scale = Scale.Stacked
Chart.YAxis.Label.Text = "Products sold"
' Modify the x axis labels.
Chart.XAxis.Scale = Scale.Time
Chart.XAxis.TimeScaleLabels.Mode = TimeScaleLabelMode.Dynamic
Chart.XAxis.TimeScaleLabels.DayFormatString = "o"
Chart.XAxis.TimeScaleLabels.MonthFormatString = "MMM"
Chart.XAxis.TimeInterval = TimeInterval.Day
Chart.XAxis.TimeScaleLabels.RangeIntervals.Add(TimeInterval.Month)
' *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()
' 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()
Dim startDT As DateTime = New DateTime(2020,1,1)
s.Name = "Product " & a.ToString()
For b As Integer = 0 To 100
Dim e As Element = New Element()
e.XDateTime = startDT
startDT = startDT.AddDays(1)
e.YValue = myR.Next(50)
s.Elements.Add(e)
Next b
SC.Add(s)
Next a
Return SC
End Function
</script>
</head>
<body>
<center>
<dotnet:Chart id="Chart" runat="server"/>
</center>
</body>
</html>
- Sample FilenameImageZoomerDateTimeLabels.aspx
- Version5.0
- Uses DatabaseNo