Gallery
<%@ Page Language="C#" Description="dotnetCHARTING Component"%>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<script runat="server">
void Page_Load(Object sender,EventArgs e)
{
// Demonstrates a finance line chart.
Chart.JS.Enabled = true;
// Set the title.
//Chart.Title="My Chart";
//Chart.Type = ChartType.Financial;
// Set the financial chart type
Chart.DefaultSeries.Type = SeriesType.Line;
Chart.DefaultSeries.DefaultElement.Marker.Visible = false;
//Chart.JS.Settings.Add("xAxis_crosshair_enabled", "true");
Chart.DefaultSeries.DefaultElement.ToolTip = "Price:%yvalue";
// Set the legend template
Chart.LegendBox.Template = "IconName";
Chart.LegendBox.Position = LegendBoxPosition.ChartArea;
Chart.LegendBox.Orientation = dotnetCHARTING.Orientation.TopLeft;
Chart.Palette = new Color[] { };//use JSC default palette
// Set the directory where the images will be stored.
Chart.TempDirectory="temp";
// Set the format
Chart.XAxis.FormatString = "d";
Chart.YAxis.FormatString = "c";
//Set the time padding for the x axis.
Chart.XAxis.TimePadding = new TimeSpan(5, 0, 0, 0);
// Set he chart size.
Chart.Width = 600;
Chart.Height = 350;
// Add the random data.
Chart.SeriesCollection.Add(getData());
}
private SeriesCollection getData()
{
SeriesCollection SC = new SeriesCollection();
Random myR = new Random();
for(int i = 0; i < 1; i++)
{
Series s = new Series();
s.Name = "X Company";
double closePrice = 50;
DateTime startDT = new DateTime(2020,1,1);
for(int b = 0; b < 175; b++)
{
Element e = new Element();
e.XDateTime = startDT;
startDT = startDT.AddDays(1);
if(myR.Next(10) > 5)
closePrice += myR.Next(5);
else
closePrice -= myR.Next(3);
e.Close = closePrice;
s.Elements.Add(e);
}
SC.Add(s);
}
return(SC);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Gallery 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" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates a finance line chart.
Chart.JS.Enabled = True
' Set the title.
'Chart.Title="My Chart";
'Chart.Type = ChartType.Financial;
' Set the financial chart type
Chart.DefaultSeries.Type = SeriesType.Line
Chart.DefaultSeries.DefaultElement.Marker.Visible = False
'Chart.JS.Settings.Add("xAxis_crosshair_enabled", "true");
Chart.DefaultSeries.DefaultElement.ToolTip = "Price:%yvalue"
' Set the legend template
Chart.LegendBox.Template = "IconName"
Chart.LegendBox.Position = LegendBoxPosition.ChartArea
Chart.LegendBox.Orientation = dotnetCHARTING.Orientation.TopLeft
Chart.Palette = New Color() { } 'use JSC default palette
' Set the directory where the images will be stored.
Chart.TempDirectory="temp"
' Set the format
Chart.XAxis.FormatString = "d"
Chart.YAxis.FormatString = "c"
'Set the time padding for the x axis.
Chart.XAxis.TimePadding = New TimeSpan(5, 0, 0, 0)
' Set he chart size.
Chart.Width = 600
Chart.Height = 350
' Add the random data.
Chart.SeriesCollection.Add(getData())
End Sub
Private Function getData() As SeriesCollection
Dim SC As SeriesCollection = New SeriesCollection()
Dim myR As Random = New Random()
For i As Integer = 0 To 0
Dim s As Series = New Series()
s.Name = "X Company"
Dim closePrice As Double = 50
Dim startDT As DateTime = New DateTime(2020,1,1)
For b As Integer = 0 To 174
Dim e As Element = New Element()
e.XDateTime = startDT
startDT = startDT.AddDays(1)
If myR.Next(10) > 5 Then
closePrice += myR.Next(5)
Else
closePrice -= myR.Next(3)
End If
e.Close = closePrice
s.Elements.Add(e)
Next b
SC.Add(s)
Next i
Return(SC)
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Gallery Sample</title></head>
<body>
<div align="center">
<dotnet:Chart id="Chart" runat="server"/>
</div>
</body>
</html>
- Sample FilenameJsFinanceLine.aspx
- Version9.2
- Uses DatabaseNo