Sign in to follow this  
hjohan

Realtime Chart With Vb

Recommended Posts

Hi I am a complete novis to your exellent library. I want to feed a realtime widget with time and speedvalue from a SQL database.. Can you help me to spot What I am doing wrong.. How to activate a timerlike function

so that we ask for latest record(speed/time)

 

Best regards

Johan

 

 

 

ASPX

 

######################

 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="realtime.aspx.vb" Inherits="realtime" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

 

 

 

<head id="Head1" runat="server">

<title>Xtrakk zoomline</title>

<script type="text/javascript" src="FusionCharts/FusionCharts.js"></script>

</head>

<body>

<form id="form1" runat="server">

<div>

<div class="gen-chart-render">

 <asp:DropDownList ID="DropDownList1" runat="server">

</asp:DropDownList> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999" CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana"

Font-Size="8pt" ForeColor="Black" Height="180px" Width="200px">

<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />

<NextPrevStyle VerticalAlign="Bottom" />

<OtherMonthDayStyle ForeColor="#808080" />

<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />

<SelectorStyle BackColor="#CCCCCC" />

<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />

<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />

<WeekendDayStyle BackColor="#FFFFCC" />

</asp:Calendar>

<asp:Button ID="Button1" runat="server" Text="Button" />

 

<br />

 

<br />

<asp:Literal ID="Literal1" runat="server"></asp:Literal>

</div>

 

</div>

</form>

</body>

</html>

 

######################

 

Code behind VB

 

 

Dim dataURL As String

'Create dataURL

dataURL = Server.UrlEncode("ChartDataURL.aspx?modem_id=" & DropDownList1.SelectedItem.Value & "&calday=" & Calendar1.SelectedDate.ToString("yyyy/MM/dd") & "&graphXML=" & "realtime" & "")

'Render Chart

Literal1.Text = FusionCharts.RenderChart("xcharts/realtimeline.swf", dataURL, "", "actuall speed", "600", "350", False, True)

 

#################################

Code behind ChartDataURL.aspx

 

 

 

Public Sub realtime_singleline(ByVal modemId As String, ByVal calday As String)

 

'create recordset to get details for the factory id

Dim X As New SqlConnection(Z) : X.Open()

Dim Q As New SqlCommand("SELECT top(1) * FROM A1 WHERE MODEM_ID='" & modemId & "' ORDER BY RTC_TIME desc", X)

Dim R As SqlDataReader = Q.ExecuteReader

Dim speedvalue As String = Nothing

While R.Read

speedvalue = R("speed")

End While

 

'Define variables

Dim dateTimeLabel As String

 

 

'Generate the x-axis label (time in hh:mm:ss format)

Dim objToday As Date = Now

dateTimeLabel = objToday.Hour.ToString + ":" + objToday.Minute.ToString + ":" + objToday.Second.ToString

 

'Now write it to output stream

Response.Write("&label=" + dateTimeLabel + "&value=120")

End Sub

Share this post


Link to post
Share on other sites

Hi,

 

Please note that you would need to pass a XML file priorly created with static data and realtime attributes in the following line of code.

Literal1.Text = FusionCharts.RenderChart("xcharts/realtimeline.swf", data.xml, "", "actuall speed", "600", "350", False, True)

 

You would need to create an XML file with the real-time chart attributes like "dataStreamURL" and "refreshInterval" in the <chart> element of the XML where you would pass the data stream URL page (ChartDataURL.aspx) as querystring and the time interval at which the chart would be updating itself respectively.

 

For further details on the Real-time chart, its relevant XML attribute and other details , please refer to the following links.

Ref.- http://www.fusioncha...meOverview.html

http://www.fusioncha...DataFormat.html

http://www.fusioncha...lTimeStamp.html

 

Hope this helps. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this