Gallery
JS Org Breadcrumbs Paths
<%@ 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 an organizational chart with automatically colorized levels applied after the chart is rendered in JS.
Color highlightColor = Color.FromArgb(77, 144, 152);
Chart.TempDirectory = "temp";
Chart.Debug = true;
Chart.JS.Enabled = true;
Chart.JS.ControlID = "jsChart";
Chart.Size = "600x350";
Chart.Type = ChartType.Organizational;
// Default Mode:
Chart.OrganizationalConnectorType = OrganizationalConnectorType.RightAngle;
//Disable tooltip
Chart.DefaultElement.ToolTip = "";
// Spacing between nodes:
Chart.ChartArea.Padding = 5;
// Alternatively, set CSS style px margin array values with:
// Chart.JS.Settings.Add("defaultPoint.annotation.margin", "[15,5]");
// Connector line style
Chart.DefaultSeries.Line.Width = 1;
Chart.DefaultSeries.Line.Color = Color.LightGray;
// Node styling
Chart.DefaultElement.Outline.Width = 2;
Chart.DefaultElement.Color = Color.FromArgb(221,225,232);
Chart.DefaultElement.FocusGlow.Visible = false;
Chart.DefaultElement.Annotation.Padding = 9;
Chart.DefaultElement.Annotation.SyncHeight = SyncDimention.Level;
Chart.DefaultElement.Annotation.DefaultCorner = BoxCorner.Round;
Chart.DefaultElement.Annotation.CornerSize = 3;
// Note annotation
Annotation note = new Annotation("Click on a node to view the breadcrumbs leading up to it");
note.Position = "inside top";
note.ClearColors();
Chart.Annotations.Add(note);
// Breadcrumb annotation updated dynamically when nodes are clicked.
Annotation crumbs = new Annotation(" ");
crumbs.JsID = "crumbs";
crumbs.Position = "inside bottom";
crumbs.Label.Font = new Font("Arial", 11, FontStyle.Bold);
crumbs.ClearColors();
Chart.Annotations.Add(crumbs);
Chart.JS.Settings.Add("defaultSeries.pointSelection", "single");
Chart.JS.Settings.Add("events.pointSelectionChanged", "JS:pointSelectionChanged");
Chart.JS.Settings.Add("defaultPoint.events.mouseOver", "JS:pointMouseOver");
Chart.JS.Settings.Add("defaultPoint.events.mouseOut", "JS:pointMouseOut");
// The mute state is used to style points that are part a clicked path.
Chart.JS.Settings.Add("defaultPoint.states.mute", "JS:{ enabled: true, opacity: 1, outline: { color: '#4D7298' } }");
// The select state is used by points that are clicked.
Chart.JS.Settings.Add("defaultPoint.states.select", "JS:{ fill: ['#4D7298', 0.3], outline: { color: '#4D7298' } }");
// *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 ser = new Series("");
Element el1 = new Element();
el1.Name = "Aida";
ser.Elements.Add(el1);
Element el2 = new Element();
el2.Name = "Ain";
el2.Parent = el1;
ser.Elements.Add(el2);
Element el3 = new Element();
el3.Name = "John";
el3.Parent = el1;
ser.Elements.Add(el3);
Element el4 = new Element();
el4.Name = "William";
el4.Parent = el1;
ser.Elements.Add(el4);
Element el5 = new Element();
el5.Name = "Frank";
el5.Parent = el2;
ser.Elements.Add(el5);
Element el6 = new Element();
el6.Name = "Eric";
el6.Parent = el2;
ser.Elements.Add(el6);
Element el7 = new Element();
el7.Name = "David";
el7.Parent = el3;
ser.Elements.Add(el7);
Element el8 = new Element();
el8.Name = "Stephen";
el8.Parent = el3;
ser.Elements.Add(el8);
Element el9 = new Element();
el9.Name = "George";
el9.Parent = el3;
ser.Elements.Add(el9);
Element el10 = new Element();
el10.Name = "Lori";
el10.Parent = el9;
ser.Elements.Add(el10);
Element el11 = new Element();
el11.Name = "Walt";
el11.Parent = el9;
ser.Elements.Add(el11);
Element el12 = new Element();
el12.Name = "Thomas";
el12.Parent = el10;
ser.Elements.Add(el12);
Element el13 = new Element();
el13.Name = "James";
el13.Parent = el10;
ser.Elements.Add(el13);
Element el14 = new Element();
el14.Name = "Tim";
el14.Parent = el10;
ser.Elements.Add(el14);
Element el15 = new Element();
el15.Name = "Jack";
el15.Parent = el10;
ser.Elements.Add(el15);
Element el16 = new Element();
el16.Name = "Robert";
el16.Parent = el4;
ser.Elements.Add(el16);
Element el17 = new Element();
el17.Name = "Jose";
el17.Parent = el4;
ser.Elements.Add(el17);
Element el18 = new Element();
el18.Name = "Joe";
el18.Parent = el16;
ser.Elements.Add(el18);
Element el19 = new Element();
el19.Name = "Mark";
el19.Parent = el16;
ser.Elements.Add(el19);
return new SeriesCollection(ser);
}
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>
<script type="text/javascript">
var highlightColor = '#4D7298';
var selectedPoint;
function pointMouseOver() {
if (this.id === selectedPoint) {
this.chart.connectors([this.id, 'up'], { color: highlightColor, width: 2 });
} else {
this.chart.connectors([this.id, 'up'], { color: highlightColor });
}
this.chart
.series()
.points([this.id, 'up'])
.options({ muted: true });
return false;
}
function pointMouseOut() {
styleSelectedPoints(this.chart);
return false;
}
/**
* Event Handler
*/
function pointSelectionChanged(points) {
selectedPoint = points.map(function (p) {
return p.id;
})[0];
styleSelectedPoints(this);
showBreadcrumbs(this);
}
function styleSelectedPoints(c) {
// Clear styling
c.connectors();
c.series()
.points()
.options({ muted: false });
if (selectedPoint) {
var path = [selectedPoint, 'up'];
c.connectors(path, { color: highlightColor, width: 2 });
c.series()
.points(path)
.options({ muted: true });
}
}
function reset(c) {
c.connectors();
c.series()
.points()
.options({ selected: false });
}
/**
* Generate breadcrumbs path
*/
function showBreadcrumbs(c) {
var text = '';
if (selectedPoint) {
var path = c.connectors([selectedPoint, 'up'], {});
if (path) {
text = path[0].map(idToPointName).join(' > ');
}
}
c.annotations('crumbs').options({ label_text: text });
function idToPointName(id) {
var point = c.series().points(id);
return point.x || point.name;
}
}
function clearClick() {
reset(jsChart);
selectedPoint = undefined;
}
</script>
</head>
<body>
<div align="center">
<input type="button" value="Clear Selection" onclick="clearClick()" />
<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 an organizational chart with automatically colorized levels applied after the chart is rendered in JS.
Dim highlightColor As Color = Color.FromArgb(77, 144, 152)
Chart.TempDirectory = "temp"
Chart.Debug = True
Chart.JS.Enabled = True
Chart.JS.ControlID = "jsChart"
Chart.Size = "600x350"
Chart.Type = ChartType.Organizational
' Default Mode:
Chart.OrganizationalConnectorType = OrganizationalConnectorType.RightAngle
'Disable tooltip
Chart.DefaultElement.ToolTip = ""
' Spacing between nodes:
Chart.ChartArea.Padding = 5
' Alternatively, set CSS style px margin array values with:
' Chart.JS.Settings.Add("defaultPoint.annotation.margin", "[15,5]");
' Connector line style
Chart.DefaultSeries.Line.Width = 1
Chart.DefaultSeries.Line.Color = Color.LightGray
' Node styling
Chart.DefaultElement.Outline.Width = 2
Chart.DefaultElement.Color = Color.FromArgb(221,225,232)
Chart.DefaultElement.FocusGlow.Visible = False
Chart.DefaultElement.Annotation.Padding = 9
Chart.DefaultElement.Annotation.SyncHeight = SyncDimention.Level
Chart.DefaultElement.Annotation.DefaultCorner = BoxCorner.Round
Chart.DefaultElement.Annotation.CornerSize = 3
' Note annotation
Dim note As Annotation = New Annotation("Click on a node to view the breadcrumbs leading up to it")
note.Position = "inside top"
note.ClearColors()
Chart.Annotations.Add(note)
' Breadcrumb annotation updated dynamically when nodes are clicked.
Dim crumbs As Annotation = New Annotation(" ")
crumbs.JsID = "crumbs"
crumbs.Position = "inside bottom"
crumbs.Label.Font = New Font("Arial", 11, FontStyle.Bold)
crumbs.ClearColors()
Chart.Annotations.Add(crumbs)
Chart.JS.Settings.Add("defaultSeries.pointSelection", "single")
Chart.JS.Settings.Add("events.pointSelectionChanged", "JS:pointSelectionChanged")
Chart.JS.Settings.Add("defaultPoint.events.mouseOver", "JS:pointMouseOver")
Chart.JS.Settings.Add("defaultPoint.events.mouseOut", "JS:pointMouseOut")
' The mute state is used to style points that are part a clicked path.
Chart.JS.Settings.Add("defaultPoint.states.mute", "JS:{ enabled: true, opacity: 1, outline: { color: '#4D7298' } }")
' The select state is used by points that are clicked.
Chart.JS.Settings.Add("defaultPoint.states.select", "JS:{ fill: ['#4D7298', 0.3], outline: { color: '#4D7298' } }")
' *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 ser As Series = New Series("")
Dim el1 As Element = New Element()
el1.Name = "Aida"
ser.Elements.Add(el1)
Dim el2 As Element = New Element()
el2.Name = "Ain"
el2.Parent = el1
ser.Elements.Add(el2)
Dim el3 As Element = New Element()
el3.Name = "John"
el3.Parent = el1
ser.Elements.Add(el3)
Dim el4 As Element = New Element()
el4.Name = "William"
el4.Parent = el1
ser.Elements.Add(el4)
Dim el5 As Element = New Element()
el5.Name = "Frank"
el5.Parent = el2
ser.Elements.Add(el5)
Dim el6 As Element = New Element()
el6.Name = "Eric"
el6.Parent = el2
ser.Elements.Add(el6)
Dim el7 As Element = New Element()
el7.Name = "David"
el7.Parent = el3
ser.Elements.Add(el7)
Dim el8 As Element = New Element()
el8.Name = "Stephen"
el8.Parent = el3
ser.Elements.Add(el8)
Dim el9 As Element = New Element()
el9.Name = "George"
el9.Parent = el3
ser.Elements.Add(el9)
Dim el10 As Element = New Element()
el10.Name = "Lori"
el10.Parent = el9
ser.Elements.Add(el10)
Dim el11 As Element = New Element()
el11.Name = "Walt"
el11.Parent = el9
ser.Elements.Add(el11)
Dim el12 As Element = New Element()
el12.Name = "Thomas"
el12.Parent = el10
ser.Elements.Add(el12)
Dim el13 As Element = New Element()
el13.Name = "James"
el13.Parent = el10
ser.Elements.Add(el13)
Dim el14 As Element = New Element()
el14.Name = "Tim"
el14.Parent = el10
ser.Elements.Add(el14)
Dim el15 As Element = New Element()
el15.Name = "Jack"
el15.Parent = el10
ser.Elements.Add(el15)
Dim el16 As Element = New Element()
el16.Name = "Robert"
el16.Parent = el4
ser.Elements.Add(el16)
Dim el17 As Element = New Element()
el17.Name = "Jose"
el17.Parent = el4
ser.Elements.Add(el17)
Dim el18 As Element = New Element()
el18.Name = "Joe"
el18.Parent = el16
ser.Elements.Add(el18)
Dim el19 As Element = New Element()
el19.Name = "Mark"
el19.Parent = el16
ser.Elements.Add(el19)
Return New SeriesCollection(ser)
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>
<script type="text/javascript">
var highlightColor = '#4D7298';
var selectedPoint;
function pointMouseOver() {
if (this.id === selectedPoint) {
this.chart.connectors([this.id, 'up'], { color: highlightColor, width: 2 });
} else {
this.chart.connectors([this.id, 'up'], { color: highlightColor });
}
this.chart
.series()
.points([this.id, 'up'])
.options({ muted: true });
return false;
}
function pointMouseOut() {
styleSelectedPoints(this.chart);
return false;
}
/**
* Event Handler
*/
function pointSelectionChanged(points) {
selectedPoint = points.map(function (p) {
return p.id;
})[0];
styleSelectedPoints(this);
showBreadcrumbs(this);
}
function styleSelectedPoints(c) {
// Clear styling
c.connectors();
c.series()
.points()
.options({ muted: false });
if (selectedPoint) {
var path = [selectedPoint, 'up'];
c.connectors(path, { color: highlightColor, width: 2 });
c.series()
.points(path)
.options({ muted: true });
}
}
function reset(c) {
c.connectors();
c.series()
.points()
.options({ selected: false });
}
/**
* Generate breadcrumbs path
*/
function showBreadcrumbs(c) {
var text = '';
if (selectedPoint) {
var path = c.connectors([selectedPoint, 'up'], {});
if (path) {
text = path[0].map(idToPointName).join(' > ');
}
}
c.annotations('crumbs').options({ label_text: text });
function idToPointName(id) {
var point = c.series().points(id);
return point.x || point.name;
}
}
function clearClick() {
reset(jsChart);
selectedPoint = undefined;
}
</script>
</head>
<body>
<div align="center">
<input type="button" value="Clear Selection" onclick="clearClick()" />
<dotnet:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsOrgBreadcrumbsPaths.aspx
- Version10.5
- Uses DatabaseNo