Gallery
JS Animated Label Icons
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Demonstrates adding points to the js chart in real-time.
Chart.Size = "700x250";
Chart.TempDirectory = "temp";
Chart.Debug = false;
Chart.LegendBox.Visible = false;
Chart.DefaultSeries.Type = SeriesType.Spline;
Chart.DefaultSeries.DefaultElement.Marker.Visible = false;
// Enable JSCharting
Chart.JS.Enabled = true;
// Chart.JS.Buttons.Orientation = dotnetCHARTING.Orientation.TopLeft;
Chart.JS.RenderCallback = "updateStatus";
Chart.XAxis.Line.Visible = false;
Chart.XAxis.ClearValues = true;
Chart.XAxis.Scale = Scale.Time;
Chart.ChartArea.ClearColors();
Chart.YAxis.DefaultTick.GridLine.Color = Color.LightGray;
//Toolbar button
Chart.JS.Settings.Add("toolbar.items.Stop.margin", "10");
Chart.JS.Settings.Add("toolbar.items.Stop.type", "option");
Chart.JS.Settings.Add("toolbar.items.Stop.events_change", "js:playPause");
Chart.JS.Settings.Add("toolbar.items.Stop.states.select.icon.name", "system/default/play");
Chart.JS.Settings.Add("toolbar.items.Stop.icon.name", "system/default/pause");
Chart.JS.Settings.Add("toolbar.items.Stop.label.text", "Pause");
Chart.JS.Settings.Add("toolbar.items.Stop.states.select.label.text", "Play");
Chart.JS.Settings.Add("toolbar.items.Stop.boxVisible", "true");
// *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 = getRandomData();
// Add the random data.
Chart.SeriesCollection.Add(mySC);
}
SeriesCollection getRandomData()
{
Random myR = new Random(1);
SeriesCollection SC = new SeriesCollection();
DateTime dt = DateTime.Now;
Series s = new Series("Series 1");
for (int b = 1; b < 51; b++)
{
Element e = new Element();
e.XDateTime = dt;
dt = dt.AddDays(1);
e.YValue = myR.Next(100);
s.Elements.Add(e);
}
SC.Add(s);
return SC;
}
SeriesCollection getLiveData()
{
DataEngine de = new DataEngine(ConfigurationManager.AppSettings["DNCConnectionString"]);
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>
<script type="text/javascript">
var INTERVAL_ID;
var arrowIcon = '';
var chart;
var date = new Date().getTime();
date = date + (24 * 3600000) * 50;
function updateStatus(c) {
chart = c;
updateLabels();
startUpdate();
}
function playPause(val){
if(val===true){ clearInterval(INTERVAL_ID); } else { startUpdate(); }
}
function addDataPoint() {
chart.series(0).points.add({y:Math.round(Math.random()*100), x:new Date(date)}, {shift: true});
date = date + (24 * 3600000) * 1;
updateLabels();
}
function startUpdate(){
INTERVAL_ID = setInterval(function () { addDataPoint(); }, 1000);
}
function updateLabels() {
var series = chart.series(0);
JSC.label('icon', getIcon(chart), {preserve: true});
JSC.label('labelDiv11', wrapSpanText( series.points(49).replaceTokens('%value')));
JSC.label('labelDiv2', wrapSpanText( series.replaceTokens('%max') )+ '<br><span style="color:gray">Max</span>');
JSC.label('labelDiv3', wrapSpanText( series.replaceTokens('%min') )+ '<br><span style="color:gray">Min</span>');
JSC.label('labelDiv4', wrapSpanText( series.replaceTokens('%average') )+ '<br><span style="color:gray">Average</span>');
JSC.label('labelDiv5', wrapSpanText( series.replaceTokens('%sum') )+ '<br><span style="color:gray">Sum</span>');
function wrapSpanText(txt){
return '<span style="font-size:30px">' + txt + '</span>'
}
function getIcon(){
if(chart.series(0).points(49).options('y') >chart.series(0).points(48).options('y')){
arrowIcon = '<icon name=linearicons/arrow-up size=24 fill=#43a047 rotate=45 animation=true>'
}
else{
arrowIcon = '<icon name=linearicons/arrow-up size=24 fill=#ef5350 rotate=135 animation=true>'
}
return arrowIcon;
}
}
</script>
<body>
<div align="center">
<div id="labelsWrapper" style="max-width: 700px;height: 60px;;margin: 0px auto;display:flex;flex-wrap:wrap;justify-content:space-around;">
<div id="labelDiv1" style="max-width: 200px;display:inline-block">
<div id="icon" style="max-width: 100px;display:inline-block; vertical-align:super"></div>
<div id="labelDiv11" style="max-width: 100px;display:inline-block"></div>
</div>
<div id="labelDiv2" style="max-width: 200px;display:inline-block"></div>
<div id="labelDiv3" style="max-width: 200px;display:inline-block"></div>
<div id="labelDiv4" style="max-width: 200px;display:inline-block"></div>
<div id="labelDiv5" style="max-width: 200px;display:inline-block"></div>
</div>
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dnc" 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 adding points to the js chart in real-time.
Chart.Size = "700x250"
Chart.TempDirectory = "temp"
Chart.Debug = False
Chart.LegendBox.Visible = False
Chart.DefaultSeries.Type = SeriesType.Spline
Chart.DefaultSeries.DefaultElement.Marker.Visible = False
' Enable JSCharting
Chart.JS.Enabled = True
' Chart.JS.Buttons.Orientation = dotnetCHARTING.Orientation.TopLeft;
Chart.JS.RenderCallback = "updateStatus"
Chart.XAxis.Line.Visible = False
Chart.XAxis.ClearValues = True
Chart.XAxis.Scale = Scale.Time
Chart.ChartArea.ClearColors()
Chart.YAxis.DefaultTick.GridLine.Color = Color.LightGray
'Toolbar button
Chart.JS.Settings.Add("toolbar.items.Stop.margin", "10")
Chart.JS.Settings.Add("toolbar.items.Stop.type", "option")
Chart.JS.Settings.Add("toolbar.items.Stop.events_change", "js:playPause")
Chart.JS.Settings.Add("toolbar.items.Stop.states.select.icon.name", "system/default/play")
Chart.JS.Settings.Add("toolbar.items.Stop.icon.name", "system/default/pause")
Chart.JS.Settings.Add("toolbar.items.Stop.label.text", "Pause")
Chart.JS.Settings.Add("toolbar.items.Stop.states.select.label.text", "Play")
Chart.JS.Settings.Add("toolbar.items.Stop.boxVisible", "true")
' *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 = getRandomData()
' Add the random data.
Chart.SeriesCollection.Add(mySC)
End Sub
Function getRandomData() As SeriesCollection
Dim myR As Random = New Random(1)
Dim SC As SeriesCollection = New SeriesCollection()
Dim dt As DateTime = DateTime.Now
Dim s As Series = New Series("Series 1")
For b As Integer = 1 To 50
Dim e As Element = New Element()
e.XDateTime = dt
dt = dt.AddDays(1)
e.YValue = myR.Next(100)
s.Elements.Add(e)
Next b
SC.Add(s)
Return SC
End Function
Function getLiveData() As SeriesCollection
Dim de As DataEngine = New DataEngine(ConfigurationManager.AppSettings("DNCConnectionString"))
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>
<script type="text/javascript">
var INTERVAL_ID;
var arrowIcon = '';
var chart;
var date = new Date().getTime();
date = date + (24 * 3600000) * 50;
function updateStatus(c) {
chart = c;
updateLabels();
startUpdate();
}
function playPause(val){
if(val===true){ clearInterval(INTERVAL_ID); } else { startUpdate(); }
}
function addDataPoint() {
chart.series(0).points.add({y:Math.round(Math.random()*100), x:new Date(date)}, {shift: true});
date = date + (24 * 3600000) * 1;
updateLabels();
}
function startUpdate(){
INTERVAL_ID = setInterval(function () { addDataPoint(); }, 1000);
}
function updateLabels() {
var series = chart.series(0);
JSC.label('icon', getIcon(chart), {preserve: true});
JSC.label('labelDiv11', wrapSpanText( series.points(49).replaceTokens('%value')));
JSC.label('labelDiv2', wrapSpanText( series.replaceTokens('%max') )+ '<br><span style="color:gray">Max</span>');
JSC.label('labelDiv3', wrapSpanText( series.replaceTokens('%min') )+ '<br><span style="color:gray">Min</span>');
JSC.label('labelDiv4', wrapSpanText( series.replaceTokens('%average') )+ '<br><span style="color:gray">Average</span>');
JSC.label('labelDiv5', wrapSpanText( series.replaceTokens('%sum') )+ '<br><span style="color:gray">Sum</span>');
function wrapSpanText(txt){
return '<span style="font-size:30px">' + txt + '</span>'
}
function getIcon(){
if(chart.series(0).points(49).options('y') >chart.series(0).points(48).options('y')){
arrowIcon = '<icon name=linearicons/arrow-up size=24 fill=#43a047 rotate=45 animation=true>'
}
else{
arrowIcon = '<icon name=linearicons/arrow-up size=24 fill=#ef5350 rotate=135 animation=true>'
}
return arrowIcon;
}
}
</script>
<body>
<div align="center">
<div id="labelsWrapper" style="max-width: 700px;height: 60px;;margin: 0px auto;display:flex;flex-wrap:wrap;justify-content:space-around;">
<div id="labelDiv1" style="max-width: 200px;display:inline-block">
<div id="icon" style="max-width: 100px;display:inline-block; vertical-align:super"></div>
<div id="labelDiv11" style="max-width: 100px;display:inline-block"></div>
</div>
<div id="labelDiv2" style="max-width: 200px;display:inline-block"></div>
<div id="labelDiv3" style="max-width: 200px;display:inline-block"></div>
<div id="labelDiv4" style="max-width: 200px;display:inline-block"></div>
<div id="labelDiv5" style="max-width: 200px;display:inline-block"></div>
</div>
<dnc:Chart ID="Chart" runat="server" />
</div>
</body>
</html>
- Sample FilenameJsAnimatedLabelIcons.aspx
- Version9.3
- Uses DatabaseNo