Gallery
JS Emissions By Income
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates a range ticks with variwide (bar mekko) columns.
Chart.TempDirectory = "temp";
Chart.Debug = false;
Chart.Type = ChartType.Variwide;
Chart.Size = "750x450";
Chart.LegendBox.Visible = false;
Chart.JS.Enabled = true;
Chart.ChartArea.ClearColors();
Chart.YAxis.Label.Text = "Per capita carbon emissions<br/>(tCO<sub>2</sub> per person per year)";
Chart.YAxis.Maximum = 15;
Chart.YAxis.DefaultTick.GridLine.Color = Color.LightGray;
Chart.YAxis.Line.Width = 0;
Chart.XAxis.JsID = "mainX";
Chart.XAxis.Label.Text = "Population";
// Setup the shadow axis and add it.
Axis shadowX = Chart.XAxis.Calculate("");
shadowX.DefaultTick.GridLine.Color = Color.Empty;
shadowX.Line.Visible = false;
shadowX.DefaultTick.Line.Width = 2;
shadowX.Orientation = dotnetCHARTING.Orientation.Top;
Chart.JS.Settings.Add("xAxis.1.defaultTick.rangeMode", "'measure'");
AxisTick at = new AxisTick();
at.Label.Text = "51% of population<br/>86% of global CO<sub>2</sub>";
Chart.JS.Settings.Add("xAxis.1.customTicks.0.value", "['High income','Upper-middle income']");
at.Line.Color = ColorTranslator.FromHtml("#e52232");
at.Label.Color = ColorTranslator.FromHtml("#e52232");
shadowX.ExtraTicks.Add(at);
at = new AxisTick();
at.Label.Text = "49% of population<br/>14% of global CO<sub>2</sub>";
Chart.JS.Settings.Add("xAxis.1.customTicks.1.value", "['Lower-middle income','Low income']");
shadowX.ExtraTicks.Add(at);
at = new AxisTick();
at.Label.Text = "16% of population<br/>38% of global CO<sub>2</sub>";
Chart.JS.Settings.Add("xAxis.1.customTicks.2.value", "'High income'");
at.Line.Color = ColorTranslator.FromHtml("#2469e5");
at.Label.Color = ColorTranslator.FromHtml("#2469e5");
shadowX.ExtraTicks.Add(at);
at = new AxisTick();
at.Label.Text = "9% of population<br/>0.5% of global CO<sub>2</sub>";
Chart.JS.Settings.Add("xAxis.1.customTicks.3.value", "'Low income'");
at.Line.Color = ColorTranslator.FromHtml("#20a042");
at.Label.Color = ColorTranslator.FromHtml("#20a042");
shadowX.ExtraTicks.Add(at);
Chart.AxisCollection.Add(shadowX);
Chart.DefaultElement.ShowValue = true;
Chart.DefaultElement.ToolTip="<b>%xValue</b><br/>%zValue billion people<br/>%yValue tCO<sub>2</sub>/person/y";
Chart.DefaultElement.LabelTemplate = "%zValue billion people<br/>%yValue tCO<sub>2</sub>/person/y";
// *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()
{
Series reps = new Series("Representatives");
Element e1 = new Element("High income",11.3);
e1.ZValue = 1.2;
Element e2 = new Element("Upper-middle income",6.4);
e2.ZValue = 2.6;
Element e3 = new Element("Lower-middle income",1.6);
e3.ZValue = 3;
Element e4 = new Element("Low income",0.26);
e4.ZValue = 0.7;
reps.AddElements(e1, e2, e3, e4);
reps.Palette = new Color[] { ColorTranslator.FromHtml("#2469e5"), ColorTranslator.FromHtml("#e52232"), ColorTranslator.FromHtml("gray"), ColorTranslator.FromHtml("#20a042") };
return new SeriesCollection(reps);
}
SeriesCollection getLiveData()
{
DataEngine de = new DataEngine("ConnectionString goes here");
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">
<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" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates a range ticks with variwide (bar mekko) columns.
Chart.TempDirectory = "temp"
Chart.Debug = False
Chart.Type = ChartType.Variwide
Chart.Size = "750x450"
Chart.LegendBox.Visible = False
Chart.JS.Enabled = True
Chart.ChartArea.ClearColors()
Chart.YAxis.Label.Text = "Per capita carbon emissions<br/>(tCO<sub>2</sub> per person per year)"
Chart.YAxis.Maximum = 15
Chart.YAxis.DefaultTick.GridLine.Color = Color.LightGray
Chart.YAxis.Line.Width = 0
Chart.XAxis.JsID = "mainX"
Chart.XAxis.Label.Text = "Population"
' Setup the shadow axis and add it.
Dim shadowX As Axis = Chart.XAxis.Calculate("")
shadowX.DefaultTick.GridLine.Color = Color.Empty
shadowX.Line.Visible = False
shadowX.DefaultTick.Line.Width = 2
shadowX.Orientation = dotnetCHARTING.Orientation.Top
Chart.JS.Settings.Add("xAxis.1.defaultTick.rangeMode", "'measure'")
Dim at As AxisTick = New AxisTick()
at.Label.Text = "51% of population<br/>86% of global CO<sub>2</sub>"
Chart.JS.Settings.Add("xAxis.1.customTicks.0.value", "['High income','Upper-middle income']")
at.Line.Color = ColorTranslator.FromHtml("#e52232")
at.Label.Color = ColorTranslator.FromHtml("#e52232")
shadowX.ExtraTicks.Add(at)
at = New AxisTick()
at.Label.Text = "49% of population<br/>14% of global CO<sub>2</sub>"
Chart.JS.Settings.Add("xAxis.1.customTicks.1.value", "['Lower-middle income','Low income']")
shadowX.ExtraTicks.Add(at)
at = New AxisTick()
at.Label.Text = "16% of population<br/>38% of global CO<sub>2</sub>"
Chart.JS.Settings.Add("xAxis.1.customTicks.2.value", "'High income'")
at.Line.Color = ColorTranslator.FromHtml("#2469e5")
at.Label.Color = ColorTranslator.FromHtml("#2469e5")
shadowX.ExtraTicks.Add(at)
at = New AxisTick()
at.Label.Text = "9% of population<br/>0.5% of global CO<sub>2</sub>"
Chart.JS.Settings.Add("xAxis.1.customTicks.3.value", "'Low income'")
at.Line.Color = ColorTranslator.FromHtml("#20a042")
at.Label.Color = ColorTranslator.FromHtml("#20a042")
shadowX.ExtraTicks.Add(at)
Chart.AxisCollection.Add(shadowX)
Chart.DefaultElement.ShowValue = True
Chart.DefaultElement.ToolTip="<b>%xValue</b><br/>%zValue billion people<br/>%yValue tCO<sub>2</sub>/person/y"
Chart.DefaultElement.LabelTemplate = "%zValue billion people<br/>%yValue tCO<sub>2</sub>/person/y"
' *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 reps As Series = New Series("Representatives")
Dim e1 As Element = New Element("High income",11.3)
e1.ZValue = 1.2
Dim e2 As Element = New Element("Upper-middle income",6.4)
e2.ZValue = 2.6
Dim e3 As Element = New Element("Lower-middle income",1.6)
e3.ZValue = 3
Dim e4 As Element = New Element("Low income",0.26)
e4.ZValue = 0.7
reps.AddElements(e1, e2, e3, e4)
reps.Palette = New Color() { ColorTranslator.FromHtml("#2469e5"), ColorTranslator.FromHtml("#e52232"), ColorTranslator.FromHtml("gray"), ColorTranslator.FromHtml("#20a042") }
Return New SeriesCollection(reps)
End Function
Function getLiveData() As SeriesCollection
Dim de As DataEngine = New DataEngine("ConnectionString goes here")
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">
<dotnet:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsEmissionsByIncome.aspx
- Version9.3
- Uses DatabaseNo