Click here to Skip to main content
15,885,366 members
Articles / Web Development / ASP.NET

Silverlight based AJAX line graph

Rate me:
Please Sign up or sign in to vote.
4.41/5 (19 votes)
7 Aug 20073 min read 105.2K   485   40  
An article on creating real time line graphs for webpages using AJAX and Silverlight.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Line Graph Example</title>
<script type="text/javascript" src="wPFGraph.js"></script>
<script language="javascript">
var mygraph;
var start =true;
function OnCanvasLoaded(sender,args)
{
mygraph = new WPFGraph("slvr1",26,200);
PageMethods.GetNextValue(OnComplete,null);
}

function OnComplete(a)
{
    mygraph.PlotValue(a);
    if(start ==false)return;
    window.setTimeout("PageMethods.GetNextValue(OnComplete,null)",500);
}

function startstop()
{start=!start;
if(start)PageMethods.GetNextValue(OnComplete,null);
}

</script> 
</head>

<body>
<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"  EnablePageMethods="true"/>
    <div>
        <object id="slvr1"  width="300px" height="270px" type="application/x-silverlight">
            <param name="SourceElement" value=null />
            <param name="Source" value="Graph.xaml" />
            <param name="WindowlessMode" value="false" /> 
            <param name="MaxFrameRate" value="30" /> 
            <param name="OnError" value="myErrorHandler" /> 
        </object> 
    </div>
    <input id="Button1" type="button" onclick="startstop()" value="Start/Stop" />
</form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Ashish is an Electronics Engineer. He loves computers and programming, and always tries to do something different. Ashish started his programming career with FoxPro 2.5 (6 years ago) .Ashish has programmed in number of languages including C\C++ , Tcl\Tk , Assembly Language , JavaScript. Currently he works with ASP.NET, C# and VB.NET. He is currently working in multinational consulting company in India.

He devotes much of his free time to his website: http://ashishware.com , which contains lot of cool stuff on webdevelopment and programing in general.

Comments and Discussions