Gallery
JS Tile Map
<%@ 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 simple tile map chart of US states.
// Specify the JS only chart type.
Chart.Type = ChartType.Heatmap;
// Set the chart size.
Chart.Width = 670;
Chart.Height = 530;
Chart.Palette = new Color[] { };
// Enable JSCharting
Chart.JS.Enabled = true;
Chart.Debug = false;
string [] regionColors = { "#72bc43", "#c5b898", "#f4b810", "#4cafc7" };
string [] regions = { "South", "West", "Northeast", "Midwest"};
for(int a=0;a<regions.Length;a++)
{
Chart.LegendBox.ExtraEntries.Add(new LegendEntry(regions[a], "", ColorTranslator.FromHtml(regionColors[a])));
}
Chart.DefaultSeries.LegendEntry.Visible = false;
Chart.LegendBox.Orientation = dotnetCHARTING.Orientation.Bottom;
Chart.LegendBox.Template = "%icon %name";
//Hide the automatic heatmap colorbar.
Chart.JS.Settings.Add("palette_colorBar_visible","false");
Chart.ChartArea.ClearColors();
//Set the directory where the related JSC files will be created and stored.
Chart.TempDirectory = "temp";
Chart.YAxis.InvertScale = true;
Chart.YAxis.Clear();
Chart.XAxis.Clear();
Chart.DefaultSeries.DefaultElement.ShowValue = true;
Chart.DefaultSeries.DefaultElement.LabelTemplate = "%code";
Chart.DefaultSeries.DefaultElement.ToolTip = "%name (%region)";
DataEngine de = new DataEngine();
de.ChartObject = Chart; // Necessary to view any errors the dataEngine may throw.
de.Data = "./../../data/resources/tile-map-data.csv";
de.DataFields = "name=state,xvalue=col,yValue=row,code,region";//cvs must have header
SeriesCollection sc = de.GetSeries();
for (int s = 0; s < sc.Count; s++)
{
foreach (Element el in sc[s].Elements)
{
int index = Array.IndexOf(regions,el.CustomAttributes["region"].ToString());
el.ZValue =index;
el.Color = ColorTranslator.FromHtml(regionColors[index]);
}
}
Chart.SeriesCollection.Add(sc);
Chart.JS.Settings.Add("defaultSeries_legendEntry_visible","false");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Gallery 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 simple tile map chart of US states.
' Specify the JS only chart type.
Chart.Type = ChartType.Heatmap
' Set the chart size.
Chart.Width = 670
Chart.Height = 530
Chart.Palette = New Color() { }
' Enable JSCharting
Chart.JS.Enabled = True
Chart.Debug = False
Dim regionColors As String() = { "#72bc43", "#c5b898", "#f4b810", "#4cafc7" }
Dim regions As String() = { "South", "West", "Northeast", "Midwest"}
For a As Integer = 0 To regions.Length - 1
Chart.LegendBox.ExtraEntries.Add(New LegendEntry(regions(a), "", ColorTranslator.FromHtml(regionColors(a))))
Next a
Chart.DefaultSeries.LegendEntry.Visible = False
Chart.LegendBox.Orientation = dotnetCHARTING.Orientation.Bottom
Chart.LegendBox.Template = "%icon %name"
'Hide the automatic heatmap colorbar.
Chart.JS.Settings.Add("palette_colorBar_visible","false")
Chart.ChartArea.ClearColors()
'Set the directory where the related JSC files will be created and stored.
Chart.TempDirectory = "temp"
Chart.YAxis.InvertScale = True
Chart.YAxis.Clear()
Chart.XAxis.Clear()
Chart.DefaultSeries.DefaultElement.ShowValue = True
Chart.DefaultSeries.DefaultElement.LabelTemplate = "%code"
Chart.DefaultSeries.DefaultElement.ToolTip = "%name (%region)"
Dim de As DataEngine = New DataEngine()
de.ChartObject = Chart ' Necessary to view any errors the dataEngine may throw.
de.Data = "./../../data/resources/tile-map-data.csv"
de.DataFields = "name=state,xvalue=col,yValue=row,code,region" 'cvs must have header
Dim sc As SeriesCollection = de.GetSeries()
For s As Integer = 0 To sc.Count - 1
For Each el As Element In sc(s).Elements
Dim index As Integer = Array.IndexOf(regions,el.CustomAttributes("region").ToString())
el.ZValue =index
el.Color = ColorTranslator.FromHtml(regionColors(index))
Next el
Next s
Chart.SeriesCollection.Add(sc)
Chart.JS.Settings.Add("defaultSeries_legendEntry_visible","false")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Gallery Sample</title>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsTileMap.aspx
- Version10.3
- Uses DatabaseNo