Gallery
JS Mosaic Plot
<%@ 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 Mosaic Plot variwide chart with full stacked y axis.
Chart.TitleBox.Label.Text = "Worldwide Smartphone Sales to End Users by Vendor";
Chart.TempDirectory = "temp";
Chart.Debug = false;
Chart.Type = ChartType.Variwide;
Chart.Size = "750x450";
Chart.JS.Enabled = true;
Chart.ChartArea.ClearColors();
Chart.XAxis.Label.Text = "Vendors";
Chart.YAxis.Label.Text = "Units Sold";
Chart.YAxis.Scale = Scale.FullStacked;
Chart.DefaultElement.ToolTip = "<b>%name %seriesName</b><br>Units Sold: %yValue";
Chart.DefaultElement.ShowValue = false;
// *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 companies = new Series("4Q14");
Element e1 = new Element("Samsung", 73031);
Element e2 = new Element("Apple", 74831 );
Element e3 = new Element("Huawei", 21038);
Element e4 = new Element("Xiaomi", 18581 );
companies.AddElements(e1, e2, e3, e4);
sc.Add(companies);
companies = new Series("4Q15");
e1 = new Element("Samsung", 83437);
e2 = new Element("Apple", 71525 );
e3 = new Element("Huawei", 32116 );
e4 = new Element("Xiaomi", 18216 );
companies.AddElements(e1, e2, e3, e4);
sc.Add(companies);
companies = new Series("4Q16");
e1 = new Element("Samsung",76782 );
e2 = new Element("Apple", 77038 );
e3 = new Element("Huawei", 40803);
e4 = new Element("Xiaomi", 15751);
companies.AddElements(e1, e2, e3, e4);
sc.Add(companies);
companies = new Series("4Q17");
e1 = new Element("Samsung",74026 );
e2 = new Element("Apple", 73175 );
e3 = new Element("Huawei", 43887 );
e4 = new Element("Xiaomi", 28187 );
companies.AddElements(e1, e2, e3, e4);
sc.Add(companies);
return sc;
}
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" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates a Mosaic Plot variwide chart with full stacked y axis.
Chart.TitleBox.Label.Text = "Worldwide Smartphone Sales to End Users by Vendor"
Chart.TempDirectory = "temp"
Chart.Debug = False
Chart.Type = ChartType.Variwide
Chart.Size = "750x450"
Chart.JS.Enabled = True
Chart.ChartArea.ClearColors()
Chart.XAxis.Label.Text = "Vendors"
Chart.YAxis.Label.Text = "Units Sold"
Chart.YAxis.Scale = Scale.FullStacked
Chart.DefaultElement.ToolTip = "<b>%name %seriesName</b><br>Units Sold: %yValue"
Chart.DefaultElement.ShowValue = False
' *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 companies As Series = New Series("4Q14")
Dim e1 As Element = New Element("Samsung", 73031)
Dim e2 As Element = New Element("Apple", 74831)
Dim e3 As Element = New Element("Huawei", 21038)
Dim e4 As Element = New Element("Xiaomi", 18581)
companies.AddElements(e1, e2, e3, e4)
sc.Add(companies)
companies = New Series("4Q15")
e1 = New Element("Samsung", 83437)
e2 = New Element("Apple", 71525)
e3 = New Element("Huawei", 32116)
e4 = New Element("Xiaomi", 18216)
companies.AddElements(e1, e2, e3, e4)
sc.Add(companies)
companies = New Series("4Q16")
e1 = New Element("Samsung",76782)
e2 = New Element("Apple", 77038)
e3 = New Element("Huawei", 40803)
e4 = New Element("Xiaomi", 15751)
companies.AddElements(e1, e2, e3, e4)
sc.Add(companies)
companies = New Series("4Q17")
e1 = New Element("Samsung",74026)
e2 = New Element("Apple", 73175)
e3 = New Element("Huawei", 43887)
e4 = New Element("Xiaomi", 28187)
companies.AddElements(e1, e2, e3, e4)
sc.Add(companies)
Return sc
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 FilenameJsMosaicPlot.aspx
- Version9.2
- Uses DatabaseNo