Gallery
JS Grid Summary Row
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates a summary row defined for a data grid connected to a chart.
Chart.Type = ChartType.Combo;
Chart.Width = 640;
Chart.Height = 300;
Chart.TempDirectory = "temp";
Chart.Debug = false;
Chart.DefaultSeries.Type = SeriesType.Line;
Chart.JS.Enabled = true;
Chart.JS.ControlID = "myJSC";
Chart.JS.RenderCallback = "populateGrids";
Chart.JS.DataGrid.Enabled = true;
Chart.JS.DataGrid.EnableExportButton = false;
Chart.TitleBox.Position = TitleBoxPosition.Full;
Chart.TitleBox.Label.Text = "Chart Grid Samples";
Chart.LegendBox.Template = "%yValue %icon %name";
// *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();
Chart.XAxis.Label.Text = "Quarters";
Chart.YAxis.Label.Text = "Units Sold";
// Add the random data.
Chart.SeriesCollection.Add(mySC);
}
SeriesCollection getRandomData()
{
SeriesCollection SC = new SeriesCollection();
Random myR = new Random(1);
DateTime dt = new DateTime(2019, 12, 1);
Series Saw = new Series();
Saw.Name = "Saw";
Series Hammer = new Series();
Hammer.Name = "Hammer";
Series Grinder = new Series();
Grinder.Name = "Grinder";
Series Drill = new Series();
Drill.Name = "Drill";
for (int b = 1; b < 5; b++)
{
Element e = new Element();
e.YValue = myR.Next(20, 200);
e.Name = "Q " + b.ToString();
Saw.Elements.Add(e);
e = new Element();
e.YValue = myR.Next(20, 90);
e.Name = "Q " + b.ToString();
Hammer.Elements.Add(e);
e = new Element();
e.YValue = myR.Next(20, 200);
e.Name = "Q " + b.ToString();
Grinder.Elements.Add(e);
e = new Element();
e.YValue = myR.Next(90, 200);
e.Name = "Q " + b.ToString();
Drill.Elements.Add(e);
}
SC.Add(Saw);
SC.Add(Hammer);
SC.Add(Grinder);
SC.Add(Drill);
return SC;
}
</script>
<style type="text/css">
.dnc{
margin: 0px auto;
max-width:840px;
}
.myGrid{
display:inline-block;
margin-left:10px;
width:600px;
}
.summaryCell {
font-weight: bold;
color: black !important;
}
</style>
<script type="text/javascript">
function populateGrids(c){
c.toGrid('gridDiv', { className: 'dataTable', summaryRow: ['Total', '', '{%sum:n}'] });
}
</script>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server" Width="840px" Height="600px" CssClass="dnc">
</dotnet:Chart>
<div class="myGrid">
<div id="gridDiv"></div>
</div>
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<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 a summary row defined for a data grid connected to a chart.
Chart.Type = ChartType.Combo
Chart.Width = 640
Chart.Height = 300
Chart.TempDirectory = "temp"
Chart.Debug = False
Chart.DefaultSeries.Type = SeriesType.Line
Chart.JS.Enabled = True
Chart.JS.ControlID = "myJSC"
Chart.JS.RenderCallback = "populateGrids"
Chart.JS.DataGrid.Enabled = True
Chart.JS.DataGrid.EnableExportButton = False
Chart.TitleBox.Position = TitleBoxPosition.Full
Chart.TitleBox.Label.Text = "Chart Grid Samples"
Chart.LegendBox.Template = "%yValue %icon %name"
' *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()
Chart.XAxis.Label.Text = "Quarters"
Chart.YAxis.Label.Text = "Units Sold"
' 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(1)
Dim dt As DateTime = New DateTime(2019, 12, 1)
Dim Saw As Series = New Series()
Saw.Name = "Saw"
Dim Hammer As Series = New Series()
Hammer.Name = "Hammer"
Dim Grinder As Series = New Series()
Grinder.Name = "Grinder"
Dim Drill As Series = New Series()
Drill.Name = "Drill"
For b As Integer = 1 To 4
Dim e As Element = New Element()
e.YValue = myR.Next(20, 200)
e.Name = "Q " & b.ToString()
Saw.Elements.Add(e)
e = New Element()
e.YValue = myR.Next(20, 90)
e.Name = "Q " & b.ToString()
Hammer.Elements.Add(e)
e = New Element()
e.YValue = myR.Next(20, 200)
e.Name = "Q " & b.ToString()
Grinder.Elements.Add(e)
e = New Element()
e.YValue = myR.Next(90, 200)
e.Name = "Q " & b.ToString()
Drill.Elements.Add(e)
Next b
SC.Add(Saw)
SC.Add(Hammer)
SC.Add(Grinder)
SC.Add(Drill)
Return SC
End Function
</script>
<style type="text/css">
.dnc{
margin: 0px auto;
max-width:840px;
}
.myGrid{
display:inline-block;
margin-left:10px;
width:600px;
}
.summaryCell {
font-weight: bold;
color: black !important;
}
</style>
<script type="text/javascript">
function populateGrids(c){
c.toGrid('gridDiv', { className: 'dataTable', summaryRow: ['Total', '', '{%sum:n}'] });
}
</script>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server" Width="840px" Height="600px" CssClass="dnc">
</dotnet:Chart>
<div class="myGrid">
<div id="gridDiv"></div>
</div>
</div>
</body>
</html>
- Sample FilenameJsGridSummaryRow.aspx
- Version9.3
- Uses DatabaseNo