Gallery
JS Gantt Timeline
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Collections.Generic" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates a gantt timeline chart with multiple axes.
Chart.Type = ChartType.ComboHorizontal;
//setting to Gantt, ignor setting yAxis timeInteral, orientation,..
Chart.Size = "800x250";
Chart.TempDirectory = "temp";
Chart.Debug = false;
Chart.JS.Enabled = true;
Chart.Title = "MacOS Version History";
Chart.LegendBox.Visible = false;
Chart.YAxis.Clear();
Chart.DefaultElement.Outline.Color = Color.White;
Chart.DefaultElement.Outline.Width = 2;
Chart.DefaultElement.ToolTip = "%name %version %vName<br><b>%yStart - %yValue</b>";
Chart.Palette = new Color[] { Color.Black };
Series ser = new Series();
ser.Elements.Add(getData());
ser.DefaultElement.Color = Color.Black;
Chart.SeriesCollection.Add(ser);
Chart.XAxis.Orientation = dotnetCHARTING.Orientation.Top;
Axis shadowAxis = Chart.XAxis.Calculate("");
shadowAxis.Orientation = dotnetCHARTING.Orientation.Bottom;
shadowAxis.DefaultTick.Line.Length = 25;
shadowAxis.DefaultTick.Line.EndCap = LineCap.ArrowAnchor;
shadowAxis.ClearValues = true;
shadowAxis.TickLabelAngle = 90;
shadowAxis.DefaultTick.Label.Text = "%name";
shadowAxis.ExtraTicks.Add(getAxisTicks());
Chart.AxisCollection.Add(shadowAxis);
}
object[,] data = {
{"Cheetah", "3/24/2001", 10},
{"Puma", "9/25/2001", 10.1},
{"Jaguar", "8/23/2002", 10.2},
{"Panther", "10/24/2003", 10.3},
{"Tiger", "4/29/2005", 10.4},
{"Leopard", "10/26/2007", 10.5},
{"Snow Leopard", "8/28/2009", 10.6},
{"Lion", "7/20/2011", 10.7},
{"Mountain Lion", "7/25/2012", 10.8},
{"Mavericks", "10/22/2013", 10.9},
{"Yosemite", "10/16/2014", 10.1},
{"El Capitan", "6/8/2015", 10.11},
{"Sierra", "9/20/2016", 10.12},
{"High Sierra", "9/25/2017", 10.13},
{"Mojave", "9/24/2018", 10.14},
{"Catalina", "10/7/2019", 10.15}
};
ElementCollection getData()
{
ElementCollection ec = new ElementCollection();
int len = data.GetLength(0);
for (int i = 0; i < len; i++)
{
Element el = new Element();
el.Name = "MacOS";
el.YDateTimeStart = DateTime.Parse(data[i, 1].ToString());
el.YDateTime = i < len - 1 ? DateTime.Parse(data[i + 1, 1].ToString()) : DateTime.Now;
el.CustomAttributes.Add("version", double.Parse(data[i, 2].ToString()));
el.CustomAttributes.Add("vName", data[i, 0].ToString());
ec.Add(el);
}
return ec;
}
AxisTickCollection getAxisTicks()
{
AxisTickCollection ec = new AxisTickCollection();
int len = data.GetLength(0);
for (int i = 0; i < len; i++)
{
AxisTick el = new AxisTick();
el.Label.Text = data[i, 0].ToString();
el.Value = DateTime.Parse(data[i, 1].ToString());
ec.Add(el);
}
return ec;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
</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.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Collections.Generic" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates a gantt timeline chart with multiple axes.
Chart.Type = ChartType.ComboHorizontal
'setting to Gantt, ignor setting yAxis timeInteral, orientation,..
Chart.Size = "800x250"
Chart.TempDirectory = "temp"
Chart.Debug = False
Chart.JS.Enabled = True
Chart.Title = "MacOS Version History"
Chart.LegendBox.Visible = False
Chart.YAxis.Clear()
Chart.DefaultElement.Outline.Color = Color.White
Chart.DefaultElement.Outline.Width = 2
Chart.DefaultElement.ToolTip = "%name %version %vName<br><b>%yStart - %yValue</b>"
Chart.Palette = New Color() { Color.Black }
Dim ser As Series = New Series()
ser.Elements.Add(getData())
ser.DefaultElement.Color = Color.Black
Chart.SeriesCollection.Add(ser)
Chart.XAxis.Orientation = dotnetCHARTING.Orientation.Top
Dim shadowAxis As Axis = Chart.XAxis.Calculate("")
shadowAxis.Orientation = dotnetCHARTING.Orientation.Bottom
shadowAxis.DefaultTick.Line.Length = 25
shadowAxis.DefaultTick.Line.EndCap = LineCap.ArrowAnchor
shadowAxis.ClearValues = True
shadowAxis.TickLabelAngle = 90
shadowAxis.DefaultTick.Label.Text = "%name"
shadowAxis.ExtraTicks.Add(getAxisTicks())
Chart.AxisCollection.Add(shadowAxis)
End Sub
Dim data As Object(,) = { {"Cheetah", "3/24/2001", 10}, {"Puma", "9/25/2001", 10.1}, {"Jaguar", "8/23/2002", 10.2}, {"Panther", "10/24/2003", 10.3}, {"Tiger", "4/29/2005", 10.4}, {"Leopard", "10/26/2007", 10.5}, {"Snow Leopard", "8/28/2009", 10.6}, {"Lion", "7/20/2011", 10.7}, {"Mountain Lion", "7/25/2012", 10.8}, {"Mavericks", "10/22/2013", 10.9}, {"Yosemite", "10/16/2014", 10.1}, {"El Capitan", "6/8/2015", 10.11}, {"Sierra", "9/20/2016", 10.12}, {"High Sierra", "9/25/2017", 10.13}, {"Mojave", "9/24/2018", 10.14}, {"Catalina", "10/7/2019", 10.15} }
Function getData() As ElementCollection
Dim ec As ElementCollection = New ElementCollection()
Dim len As Integer = data.GetLength(0)
For i As Integer = 0 To len - 1
Dim el As Element = New Element()
el.Name = "MacOS"
el.YDateTimeStart = DateTime.Parse(data(i, 1).ToString())
If i < len - 1 Then
el.YDateTime = DateTime.Parse(data(i + 1, 1).ToString())
Else
el.YDateTime = DateTime.Now
End If
el.CustomAttributes.Add("version", Double.Parse(data(i, 2).ToString()))
el.CustomAttributes.Add("vName", data(i, 0).ToString())
ec.Add(el)
Next i
Return ec
End Function
Function getAxisTicks() As AxisTickCollection
Dim ec As AxisTickCollection = New AxisTickCollection()
Dim len As Integer = data.GetLength(0)
For i As Integer = 0 To len - 1
Dim el As AxisTick = New AxisTick()
el.Label.Text = data(i, 0).ToString()
el.Value = DateTime.Parse(data(i, 1).ToString())
ec.Add(el)
Next i
Return ec
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsGanttTimeline.aspx
- Version10.1
- Uses DatabaseNo