Gallery
JS Axis Shadow Token Ticks
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates dynamic calculated ticks that update in real-time with JSCharting.
Chart.Type = ChartType.Combo;
Chart.Size = "600x350";
Chart.TempDirectory = "temp";
Chart.Debug = false;
Chart.JS.Enabled = true;
Chart.JS.RenderCallback = "callbackFunc";
Axis replicaAxis = Chart.YAxis.Calculate("", true, dotnetCHARTING.Orientation.Right);
AxisTick at = new AxisTick();
//By assigning a token as the value, the axis tick can update if chart data changes.
at.Value = "%average";
at.Label.Text = "Agv: %value";
replicaAxis.ExtraTicks.Add(at);
at = new AxisTick();
at.Value = "%max";
at.Label.Text = "Max: %max";
replicaAxis.ExtraTicks.Add(at);
Chart.AxisCollection.Add(replicaAxis);
// *DYNAMIC DATA NOTE*
// This sample uses random data to populate the chart. To populate
// a chart with database data see the following resources:
// - Classic samples folder
// - Help File > Data Tutorials
// - Sample: features/DataEngine.aspx
SeriesCollection mySC = getRandomData();
mySC[2][2].JsID = "myDynamicPoint";
// Add the random data.
Chart.SeriesCollection.Add(mySC);
}
SeriesCollection getRandomData()
{
SeriesCollection SC = new SeriesCollection();
Random myR = new Random(1);
for (int a = 1; a < 5; a++)
{
Series s = new Series();
s.Name = "Series " + a.ToString();
for (int b = 1; b < 5; b++)
{
Element e = new Element();
e.Name = "Element " + b.ToString();
e.YValue = myR.Next(50);
s.Elements.Add(e);
}
SC.Add(s);
}
return SC;
}
</script>
<script type="text/javascript">
var val = 60;
var updateChart;
function callbackFunc(chart) {
updateChart= function () {
var point = chart.series().points("myDynamicPoint");
val = (val == 60) ? 20 : 60;
point.options({ y: val });
}
}
</script>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server"/>
</div>
<div align="center" style="margin-right:130px;">
<input type="button" value="Update Data" onclick="updateChart()" />
</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" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Demonstrates dynamic calculated ticks that update in real-time with JSCharting.
Chart.Type = ChartType.Combo
Chart.Size = "600x350"
Chart.TempDirectory = "temp"
Chart.Debug = False
Chart.JS.Enabled = True
Chart.JS.RenderCallback = "callbackFunc"
Dim replicaAxis As Axis = Chart.YAxis.Calculate("", True, dotnetCHARTING.Orientation.Right)
Dim at As AxisTick = New AxisTick()
'By assigning a token as the value, the axis tick can update if chart data changes.
at.Value = "%average"
at.Label.Text = "Agv: %value"
replicaAxis.ExtraTicks.Add(at)
at = New AxisTick()
at.Value = "%max"
at.Label.Text = "Max: %max"
replicaAxis.ExtraTicks.Add(at)
Chart.AxisCollection.Add(replicaAxis)
' *DYNAMIC DATA NOTE*
' This sample uses random data to populate the chart. To populate
' a chart with database data see the following resources:
' - Classic samples folder
' - Help File > Data Tutorials
' - Sample: features/DataEngine.aspx
Dim mySC As SeriesCollection = getRandomData()
mySC(2)(2).JsID = "myDynamicPoint"
' Add the random data.
Chart.SeriesCollection.Add(mySC)
End Sub
Function getRandomData() As SeriesCollection
Dim SC As SeriesCollection = New SeriesCollection()
Dim myR As Random = New Random(1)
For a As Integer = 1 To 4
Dim s As Series = New Series()
s.Name = "Series " & a.ToString()
For b As Integer = 1 To 4
Dim e As Element = New Element()
e.Name = "Element " & b.ToString()
e.YValue = myR.Next(50)
s.Elements.Add(e)
Next b
SC.Add(s)
Next a
Return SC
End Function
</script>
<script type="text/javascript">
var val = 60;
var updateChart;
function callbackFunc(chart) {
updateChart= function () {
var point = chart.series().points("myDynamicPoint");
val = (val == 60) ? 20 : 60;
point.options({ y: val });
}
}
</script>
</head>
<body>
<div align="center">
<dotnet:Chart ID="Chart" runat="server"/>
</div>
<div align="center" style="margin-right:130px;">
<input type="button" value="Update Data" onclick="updateChart()" />
</div>
</body>
</html>
- Sample FilenameJsAxisShadowTokenTicks.aspx
- Version8.4
- Uses DatabaseNo