Gallery
JS Org Path Selection Modes
<%@ 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 different point selection modes.
Chart.TempDirectory = "temp";
Chart.Debug = true;
Chart.JS.Enabled = true;
Chart.JS.ControlID = "jsChart";
Chart.Size = "700x450";
Chart.TitleBox.Label.Text = "View the paths emanating from points on hover in the selected direction.";
Chart.TitleBox.Position = TitleBoxPosition.Center;
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 = 1;
Chart.DefaultElement.Outline.Color = Color.LightGray;
Chart.DefaultElement.Outline.DashStyle = DashStyle.Dash;
Chart.DefaultElement.Color = Color.FromArgb(243,247,255);
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;
// Wire up interactive functionality:
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");
Chart.JS.Settings.Add("defaultSeries.pointSelection", "single");
/* Muted state is used to highlight points down the tree. */
Chart.JS.Settings.Add("defaultPoint.states.mute", "JS:{ enabled: true, opacity: 1, outline_color: '#504545' }");
/* Ensure select styles are created despite being disabled with point clicks. (defaultSeries.pointSelection) */
Chart.JS.Settings.Add("defaultPoint.states.select", "JS:{ fill: '#bac9e1', outline: { color: '#544040' } }");
// *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 = "Project Manager";
ser.Elements.Add(el1);
Element el2 = new Element();
el2.Name = "Deputy Project Manager";
el2.Parent = el1;
ser.Elements.Add(el2);
Element el3 = new Element();
el3.Name = "System Engineering";
el3.Parent = el2;
ser.Elements.Add(el3);
Element el4 = new Element();
el4.Name = "Independent Test Group";
el4.Parent = el2;
ser.Elements.Add(el4);
Element el5 = new Element();
el5.Name = "Project Technical Lead";
el5.Parent = el2;
ser.Elements.Add(el5);
Element el6 = new Element();
el6.Name = "Quality Assurance";
el6.Parent = el2;
ser.Elements.Add(el6);
Element el7 = new Element();
el7.Name = "Configuration Manager";
el7.Parent = el2;
ser.Elements.Add(el7);
Element el8 = new Element();
el8.Name = "S/W Subproject Manager 1";
el8.Parent = el5;
ser.Elements.Add(el8);
Element el9 = new Element();
el9.Name = "Team 1";
el9.Parent = el8;
ser.Elements.Add(el9);
Element el10 = new Element();
el10.Name = "Team 2";
el10.Parent = el8;
ser.Elements.Add(el10);
Element el11 = new Element();
el11.Name = "Team 3";
el11.Parent = el8;
ser.Elements.Add(el11);
Element el12 = new Element();
el12.Name = "S/W Subproject Manager 2";
el12.Parent = el5;
ser.Elements.Add(el12);
Element el13 = new Element();
el13.Name = "Team 1";
el13.Parent = el12;
ser.Elements.Add(el13);
Element el14 = new Element();
el14.Name = "Team 2";
el14.Parent = el12;
ser.Elements.Add(el14);
Element el15 = new Element();
el15.Name = "S/W Subproject Manager 3";
el15.Parent = el5;
ser.Elements.Add(el15);
Element el16 = new Element();
el16.Name = "Team 1";
el16.Parent = el15;
ser.Elements.Add(el16);
Element el17 = new Element();
el17.Name = "Team 2";
el17.Parent = el15;
ser.Elements.Add(el17);
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 = '#544040',
mutedHighlightColor = '#504545',
hoverConnectorsColor = '#4b2f2f',
selectionMode = 'single';
var selectedPoints = [];
function pointSelectionChanged(points) {
selectedPoints = points.map(function (p) {
return p.id;
});
// Clear all connector styling.
this.connectors();
styleSelectedPoints(this);
}
function styleSelectedPoints(c) {
// Clear point mute states.
c.series()
.points()
.options({ muted: false });
if (selectedPoints.length) {
var paths = selectedPoints.map(function (pid) {
return [pid, 'up'];
});
c.connectors(paths, { color: highlightColor, dashStyle: 'dash', width: 2 });
c.series()
.points(paths)
.options({ muted: true });
}
}
function pointMouseOver() {
this.chart.connectors([this.id, 'up'], { color: hoverConnectorsColor });
return false;
}
function pointMouseOut() {
// Reset only the point connectors that were highlighted by pointMouseOver().
// This prevents the currently selected connectors from flickering.
this.chart.connectors([this.id, 'up']);
styleSelectedPoints(this.chart);
return false;
}
function selectionChanged() {
var val = document.querySelector('input[name="selection"]:checked').value;
jsChart.options({ defaultSeries: { pointSelection: val.length < 2 ? { max: parseInt(val) } : val } });
}
</script>
<style type="text/css">
html
{
font-family:"Lucida Grande","Lucida Sans Unicode","Bitstream Vera Sans","Trebuchet MS",Verdana,sans-serif
}</style>
</head>
<body>
<div style="margin: 8px auto;max-width: 750px;">
Selection Mode:
<input type="radio" id="2" name="selection" value="2" onclick="selectionChanged()"><label for="2">2</label>
� <input type="radio" id="3" name="selection" value="3" onclick="selectionChanged()"><label for="3">3</label>
� <input type="radio" id="single" name="selection" value="single" checked onclick="selectionChanged()"><label for="single">single</label>
<input type="radio" id="multiple" name="selection" value="multiple" onclick="selectionChanged()"><label for="multiple">multiple</label>
<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 different point selection modes.
Chart.TempDirectory = "temp"
Chart.Debug = True
Chart.JS.Enabled = True
Chart.JS.ControlID = "jsChart"
Chart.Size = "700x450"
Chart.TitleBox.Label.Text = "View the paths emanating from points on hover in the selected direction."
Chart.TitleBox.Position = TitleBoxPosition.Center
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 = 1
Chart.DefaultElement.Outline.Color = Color.LightGray
Chart.DefaultElement.Outline.DashStyle = DashStyle.Dash
Chart.DefaultElement.Color = Color.FromArgb(243,247,255)
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
' Wire up interactive functionality:
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")
Chart.JS.Settings.Add("defaultSeries.pointSelection", "single")
' Muted state is used to highlight points down the tree.
Chart.JS.Settings.Add("defaultPoint.states.mute", "JS:{ enabled: true, opacity: 1, outline_color: '#504545' }")
' Ensure select styles are created despite being disabled with point clicks. (defaultSeries.pointSelection)
Chart.JS.Settings.Add("defaultPoint.states.select", "JS:{ fill: '#bac9e1', outline: { color: '#544040' } }")
' *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 = "Project Manager"
ser.Elements.Add(el1)
Dim el2 As Element = New Element()
el2.Name = "Deputy Project Manager"
el2.Parent = el1
ser.Elements.Add(el2)
Dim el3 As Element = New Element()
el3.Name = "System Engineering"
el3.Parent = el2
ser.Elements.Add(el3)
Dim el4 As Element = New Element()
el4.Name = "Independent Test Group"
el4.Parent = el2
ser.Elements.Add(el4)
Dim el5 As Element = New Element()
el5.Name = "Project Technical Lead"
el5.Parent = el2
ser.Elements.Add(el5)
Dim el6 As Element = New Element()
el6.Name = "Quality Assurance"
el6.Parent = el2
ser.Elements.Add(el6)
Dim el7 As Element = New Element()
el7.Name = "Configuration Manager"
el7.Parent = el2
ser.Elements.Add(el7)
Dim el8 As Element = New Element()
el8.Name = "S/W Subproject Manager 1"
el8.Parent = el5
ser.Elements.Add(el8)
Dim el9 As Element = New Element()
el9.Name = "Team 1"
el9.Parent = el8
ser.Elements.Add(el9)
Dim el10 As Element = New Element()
el10.Name = "Team 2"
el10.Parent = el8
ser.Elements.Add(el10)
Dim el11 As Element = New Element()
el11.Name = "Team 3"
el11.Parent = el8
ser.Elements.Add(el11)
Dim el12 As Element = New Element()
el12.Name = "S/W Subproject Manager 2"
el12.Parent = el5
ser.Elements.Add(el12)
Dim el13 As Element = New Element()
el13.Name = "Team 1"
el13.Parent = el12
ser.Elements.Add(el13)
Dim el14 As Element = New Element()
el14.Name = "Team 2"
el14.Parent = el12
ser.Elements.Add(el14)
Dim el15 As Element = New Element()
el15.Name = "S/W Subproject Manager 3"
el15.Parent = el5
ser.Elements.Add(el15)
Dim el16 As Element = New Element()
el16.Name = "Team 1"
el16.Parent = el15
ser.Elements.Add(el16)
Dim el17 As Element = New Element()
el17.Name = "Team 2"
el17.Parent = el15
ser.Elements.Add(el17)
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 = '#544040',
mutedHighlightColor = '#504545',
hoverConnectorsColor = '#4b2f2f',
selectionMode = 'single';
var selectedPoints = [];
function pointSelectionChanged(points) {
selectedPoints = points.map(function (p) {
return p.id;
});
// Clear all connector styling.
this.connectors();
styleSelectedPoints(this);
}
function styleSelectedPoints(c) {
// Clear point mute states.
c.series()
.points()
.options({ muted: false });
if (selectedPoints.length) {
var paths = selectedPoints.map(function (pid) {
return [pid, 'up'];
});
c.connectors(paths, { color: highlightColor, dashStyle: 'dash', width: 2 });
c.series()
.points(paths)
.options({ muted: true });
}
}
function pointMouseOver() {
this.chart.connectors([this.id, 'up'], { color: hoverConnectorsColor });
return false;
}
function pointMouseOut() {
// Reset only the point connectors that were highlighted by pointMouseOver().
// This prevents the currently selected connectors from flickering.
this.chart.connectors([this.id, 'up']);
styleSelectedPoints(this.chart);
return false;
}
function selectionChanged() {
var val = document.querySelector('input[name="selection"]:checked').value;
jsChart.options({ defaultSeries: { pointSelection: val.length < 2 ? { max: parseInt(val) } : val } });
}
</script>
<style type="text/css">
html
{
font-family:"Lucida Grande","Lucida Sans Unicode","Bitstream Vera Sans","Trebuchet MS",Verdana,sans-serif
}</style>
</head>
<body>
<div style="margin: 8px auto;max-width: 750px;">
Selection Mode:
<input type="radio" id="2" name="selection" value="2" onclick="selectionChanged()"><label for="2">2</label>
� <input type="radio" id="3" name="selection" value="3" onclick="selectionChanged()"><label for="3">3</label>
� <input type="radio" id="single" name="selection" value="single" checked onclick="selectionChanged()"><label for="single">single</label>
<input type="radio" id="multiple" name="selection" value="multiple" onclick="selectionChanged()"><label for="multiple">multiple</label>
<dotnet:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsOrgPathSelectionModes.aspx
- Version10.5
- Uses DatabaseNo