Gallery
Full Chart Tooltips DB Grouping
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates showing this chart in tooltips of each element and based on SubValues created using SubValueDateGrouping property.
// Common chart settings.
Chart.Size = "600x350";
Chart.ShowDateInTitle = false;
Chart.TempDirectory = "temp";
Chart.Debug = true;
Chart.YAxis.FormatString = "Currency";
Chart.DefaultElement.DefaultSubValue.Visible = false;
Chart.TitleBox.Label.Text = "<block hAlign='left'>2022 Sales";
Chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
Chart.TitleBox.Label.Color = Color.Black;
Chart.TitleBox.Padding = 8;
Chart.TitleBox.Background.ShadingEffectMode = ShadingEffectMode.Background2;
Chart.TitleBox.Background.Color = Color.LightSteelBlue;
Chart.ShadingEffectMode = ShadingEffectMode.Three;
Chart.ChartArea.Line.Color = Color.FromArgb(236, 236, 236);
Chart.ChartArea.Background.Color = Color.White;
Chart.ChartArea.YAxis.AlternateGridBackground.Color = Color.FromArgb(25, 220, 220, 220);
// See if this chart is to stream for tooltip.
string stream = HttpContext.Current.Request.QueryString["stream"];
if (stream != null && stream == "true")
{
// Specify setting for the streamed version of this chart.
Chart.Title = "<block hAlign='left'>" + HttpContext.Current.Request.QueryString["startDate"] + " 2022 Sales";
Chart.UseFile = false;
Chart.Background.Color = Color.Transparent;
// Parse the values passed in the query strying and add them as elements to the chart.
string vals = HttpContext.Current.Request.QueryString["vals"];
if (vals != null && vals.Length > 0)
{
string[] valsAr = vals.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
Series s = new Series();
int i = 1;
foreach (string val in valsAr)
{
Element el = new Element(i.ToString());
try
{
el.YValue = (double)float.Parse(val);
} catch { }
s.Elements.Add(el);
i++;
}
Chart.SeriesCollection.Add(s);
}
}
else
{
// if not streaming, show the main data.
Chart.ChartArea.Label.Text = "Hover bars for details or click bars for a full sized detail chart.";
// Tooltip definition.
Chart.DefaultElement.ToolTip = "<Chart:Image src='FullChartTooltipsDBGrouping.aspx?startDate=%Name&vals=%SubValueList&stream=true' size='300x200'>";
Chart.DefaultElement.URL = "?startDate=%Name&vals=%SubValueList&stream=true";
Chart.DefaultElement.URLTarget = "_blank";
Chart.SeriesCollection.Add(getLiveData());
}
}
Series getLiveData()
{
DataEngine de = new DataEngine(ConfigurationManager.AppSettings["DNCConnectionString"]);
de.ChartObject = Chart; // Necessary to view any errors the dataEngine may throw.
de.StartDate = new DateTime(2022, 1, 1, 0, 0, 0);
de.EndDate = new DateTime(2022, 12, 31, 23, 59, 59);
de.SqlStatement = "SELECT OrderDate,Total,Name,Quantity FROM Orders WHERE OrderDate >= #STARTDATE# AND OrderDate <= #ENDDATE#";
de.DataFields = "xAxis=OrderDate,yAxis=Total,Quantity";
de.DateGrouping = TimeInterval.Year;
de.SubValueDateGrouping = TimeInterval.Days;
return de.GetSeries()[0];
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
</head>
<body>
<div align="center">
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates showing this chart in tooltips of each element and based on SubValues created using SubValueDateGrouping property.
' Common chart settings.
Chart.Size = "600x350"
Chart.ShowDateInTitle = False
Chart.TempDirectory = "temp"
Chart.Debug = True
Chart.YAxis.FormatString = "Currency"
Chart.DefaultElement.DefaultSubValue.Visible = False
Chart.TitleBox.Label.Text = "<block hAlign='left'>2022 Sales"
Chart.TitleBox.Position = TitleBoxPosition.FullWithLegend
Chart.TitleBox.Label.Color = Color.Black
Chart.TitleBox.Padding = 8
Chart.TitleBox.Background.ShadingEffectMode = ShadingEffectMode.Background2
Chart.TitleBox.Background.Color = Color.LightSteelBlue
Chart.ShadingEffectMode = ShadingEffectMode.Three
Chart.ChartArea.Line.Color = Color.FromArgb(236, 236, 236)
Chart.ChartArea.Background.Color = Color.White
Chart.ChartArea.YAxis.AlternateGridBackground.Color = Color.FromArgb(25, 220, 220, 220)
' See if this chart is to stream for tooltip.
Dim stream As String = HttpContext.Current.Request.QueryString("stream")
If Not stream Is Nothing AndAlso stream = "true" Then
' Specify setting for the streamed version of this chart.
Chart.Title = "<block hAlign='left'>" & HttpContext.Current.Request.QueryString("startDate") & " 2022 Sales"
Chart.UseFile = False
Chart.Background.Color = Color.Transparent
' Parse the values passed in the query strying and add them as elements to the chart.
Dim vals As String = HttpContext.Current.Request.QueryString("vals")
If Not vals Is Nothing AndAlso vals.Length > 0 Then
Dim valsAr As String() = vals.Split(New String() { "," }, StringSplitOptions.RemoveEmptyEntries)
Dim s As Series = New Series()
Dim i As Integer = 1
For Each val As String In valsAr
Dim el As Element = New Element(i.ToString())
Try
el.YValue = CDbl(Single.Parse(val))
Catch
End Try
s.Elements.Add(el)
i += 1
Next val
Chart.SeriesCollection.Add(s)
End If
Else
' if not streaming, show the main data.
Chart.ChartArea.Label.Text = "Hover bars for details or click bars for a full sized detail chart."
' Tooltip definition.
Chart.DefaultElement.ToolTip = "<Chart:Image src='FullChartTooltipsDBGrouping.aspx?startDate=%Name&vals=%SubValueList&stream=true' size='300x200'>"
Chart.DefaultElement.URL = "?startDate=%Name&vals=%SubValueList&stream=true"
Chart.DefaultElement.URLTarget = "_blank"
Chart.SeriesCollection.Add(getLiveData())
End If
End Sub
Function getLiveData() As Series
Dim de As DataEngine = New DataEngine(ConfigurationManager.AppSettings("DNCConnectionString"))
de.ChartObject = Chart ' Necessary to view any errors the dataEngine may throw.
de.StartDate = New DateTime(2022, 1, 1, 0, 0, 0)
de.EndDate = New DateTime(2022, 12, 31, 23, 59, 59)
de.SqlStatement = "SELECT OrderDate,Total,Name,Quantity FROM Orders WHERE OrderDate >= #STARTDATE# AND OrderDate <= #ENDDATE#"
de.DataFields = "xAxis=OrderDate,yAxis=Total,Quantity"
de.DateGrouping = TimeInterval.Year
de.SubValueDateGrouping = TimeInterval.Days
Return de.GetSeries()(0)
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
</head>
<body>
<div align="center">
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameFullChartTooltipsDBGrouping.aspx
- Version5.3
- Uses DatabaseYes