Gallery
JS Accessible Pie
<%@ 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 Accessible pie chart with labels.
// Set tabIndex chart control and adding description
Chart.JS.Enabled = true;
Chart.JS.Buttons.EnableExportButton=true;
Chart.JS.Buttons.EnablePrintButton = true;
Chart.JS.Settings.Add("description", "Accessible %type chart with legend");
Chart.JS.Settings.Add("title_description", "%type chart with title %title");
Chart.JS.Settings.Add("defaultSeries_tabIndex", "auto");
Chart.JS.Settings.Add("defaultPoint_tabIndex", "auto");
Chart.JS.Settings.Add("legend_defaultEntry_tabIndex", "auto");
Chart.JS.Settings.Add("toolbar_items_export_description", "export menu");
Chart.Type = ChartType.Pies;
Chart.Size = "600x480";
Chart.TitleBox.Label.Text = "Countries GDP";
Chart.PaletteName = Palette.Two;
Chart.TempDirectory = "temp";
Chart.Debug = false;
Chart.LegendBox.Template = "%percentOfTotal:n1% %icon %name";
Chart.DefaultElement.SmartLabel.Text = "<b>%Name</b>";
Chart.DefaultElement.ShowValue = true;
Chart.YAxis.Label.Text = "GDP";
Chart.YAxis.FormatString = "n";
// *DYNAMIC DATA NOTE*
// This sample uses random data to populate the chart. To populate
// a chart with database data see the following resources:
// - Use the getLiveData() method using the dataEngine to query a database.
// - Help File > Getting Started > Data Tutorials
// - DataEngine Class in the help file
// - Sample: features/DataEngine.aspx
SeriesCollection mySC = getData();
// Add the random data.
Chart.SeriesCollection.Add(mySC);
}
SeriesCollection getData()
{
SeriesCollection SC = new SeriesCollection();
Series s1 = new Series();
s1.Name = "Countries";
Element el = new Element();
el.Name = "United States";
el.YValue = 5452500;
s1.Elements.Add(el);
el = new Element();
el.Name = "Canada";
el.YValue = 786052;
s1.Elements.Add(el);
el = new Element();
el.Name = "United Kingdom";
el.YValue = 477338;
s1.Elements.Add(el);
el = new Element();
el.Name = "Mexico";
el.YValue = 155313;
s1.Elements.Add(el);
SC.Add(s1);
return SC;
}
SeriesCollection getLiveData()
{
DataEngine de = new DataEngine(ConfigurationManager.AppSettings["DNCConnectionString"]);
de.ChartObject = Chart; // Necessary to view any errors the dataEngine may throw.
de.SqlStatement = "SELECT XAxisColumn, YAxisColumn FROM ....";
return de.GetSeries();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
</head>
<body>
<div align="center">
<dnc:Chart ID="Chart" Width="600" Height="480" 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 Accessible pie chart with labels.
' Set tabIndex chart control and adding description
Chart.JS.Enabled = True
Chart.JS.Buttons.EnableExportButton=True
Chart.JS.Buttons.EnablePrintButton = True
Chart.JS.Settings.Add("description", "Accessible %type chart with legend")
Chart.JS.Settings.Add("title_description", "%type chart with title %title")
Chart.JS.Settings.Add("defaultSeries_tabIndex", "auto")
Chart.JS.Settings.Add("defaultPoint_tabIndex", "auto")
Chart.JS.Settings.Add("legend_defaultEntry_tabIndex", "auto")
Chart.JS.Settings.Add("toolbar_items_export_description", "export menu")
Chart.Type = ChartType.Pies
Chart.Size = "600x480"
Chart.TitleBox.Label.Text = "Countries GDP"
Chart.PaletteName = Palette.Two
Chart.TempDirectory = "temp"
Chart.Debug = False
Chart.LegendBox.Template = "%percentOfTotal:n1% %icon %name"
Chart.DefaultElement.SmartLabel.Text = "<b>%Name</b>"
Chart.DefaultElement.ShowValue = True
Chart.YAxis.Label.Text = "GDP"
Chart.YAxis.FormatString = "n"
' *DYNAMIC DATA NOTE*
' This sample uses random data to populate the chart. To populate
' a chart with database data see the following resources:
' - Use the getLiveData() method using the dataEngine to query a database.
' - Help File > Getting Started > Data Tutorials
' - DataEngine Class in the help file
' - Sample: features/DataEngine.aspx
Dim mySC As SeriesCollection = getData()
' Add the random data.
Chart.SeriesCollection.Add(mySC)
End Sub
Function getData() As SeriesCollection
Dim SC As SeriesCollection = New SeriesCollection()
Dim s1 As Series = New Series()
s1.Name = "Countries"
Dim el As Element = New Element()
el.Name = "United States"
el.YValue = 5452500
s1.Elements.Add(el)
el = New Element()
el.Name = "Canada"
el.YValue = 786052
s1.Elements.Add(el)
el = New Element()
el.Name = "United Kingdom"
el.YValue = 477338
s1.Elements.Add(el)
el = New Element()
el.Name = "Mexico"
el.YValue = 155313
s1.Elements.Add(el)
SC.Add(s1)
Return SC
End Function
Function getLiveData() As SeriesCollection
Dim de As DataEngine = New DataEngine(ConfigurationManager.AppSettings("DNCConnectionString"))
de.ChartObject = Chart ' Necessary to view any errors the dataEngine may throw.
de.SqlStatement = "SELECT XAxisColumn, YAxisColumn FROM ...."
Return de.GetSeries()
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" Width="600" Height="480" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsAccessiblePie.aspx
- Version9.3
- Uses DatabaseNo