Hi
I'm using Bortosky Google Visualisation Library 
 http://code.google.com/p/bortosky-google-visualization/  
to plot a line chart on my web page. I need to update the chart when I new 
data is put into the data base, i tried using update panel. But it doesnt 
work. Im doing this for the first time, if Im totally wrong.If so
How would I implement it.?

Here is the code im working on: 

 <asp:UpdatePanel ID="UpdatePanel3"   runat="server" UpdateMode="Conditional">
                        <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="Timer1" />
                        </Triggers> 
                        <contenttemplate>


  <%@ Import Namespace = "WeatherLibrary" %>

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {

     Label1.Text = DateTime.Now.ToLongTimeString();

     Label2.Text = DateTime.Now.ToLongDateString();
     PullData();


         var googleDataTable = new 
Bortosky.Google.Visualization.GoogleDataTable(getData(0));

         Page.ClientScript.RegisterStartupScript(
             this.GetType(), "vis", string.Format("var fundata = {0};", 
googleDataTable.GetJson()), true);
 }



   System.Data.DataTable getData(int  i) // a DataTable filled using a custom 
library
    {
        var dt = new System.Data.DataTable();
        String[] sensorName = new String[] { "umtTemp1", "umtWindSpeed" };
        dt.Columns.Add("Time", typeof(System.String)).Caption = "Time Stamp";
        dt.Columns.Add("Value", typeof(System.Double)).Caption = "Measured 
Value";
        WeatherData wLib = new WeatherData();
        DateTime baseDate = DateTime.Today;
        var format = "yyyy-MM-dd HH:mm:ss";

        var now = DateTime.Now.ToString(format);
        var frm = baseDate.AddHours(-1).ToString(format);



        var value = wLib.GetWeatherItemData(sensorName[i], frm, now).Value;
        var time = wLib.GetWeatherItemData(sensorName[i], frm,now).TimeStamp;
        var k=0;

     for ( k = 0; k < value.Length; k++)
      {
         dt.Rows.Add(new object[] { time[k], Math.Round(value[k],1) });

      }

        return dt;
    }

<script type="text/javascript" src="http://www.google.com/jsapi";></script>
<script type="text/javascript">
    google.load("visualization", "1", { "packages": ["corechart"] });
    google.setOnLoadCallback(function () {
        var data = new google.visualization.DataTable(fundata, 0.5);
        var chart = new 
google.visualization.LineChart(document.getElementById("chart_div"));
        chart.draw(data, { title: "Chart1", hAxis: { title: "Time Stamp" }, 
vAxis: { title: "Measured Value"} });
    });</script>
  </contenttemplate>
 </asp:UpdatePanel>

<div id="chart_div" style="width:100%; height: 500px;"></div>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/MPVUSifKnmcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to