Quantcast
Viewing all articles
Browse latest Browse all 32057

Google Gauge chart in update panel not getting generated

I'm trying to generate a gauge chart based on changing MTBF values, However when I run the webapplication, I don't see any chart, just the button. Is my approach in the right direction. Thanks for all your help

usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;

namespaceWebApplication1
{
 
publicpartialclassWebForm3:System.Web.UI.Page
 
{

 
protectedvoidPage_Load(object sender,EventArgs e)
 
{

 
}

 
protectedvoidButton1_Click(object sender,EventArgs e)
 
{

 using(Test_Manager_DatabaseEntities entities =newTest_Manager_DatabaseEntities())
 
{
 
intTestExecID=Convert.ToInt32(Request.QueryString["ExecutionID"]);
 
var execution = entities.TestExecutionDetails.Where(p => p.TestExecutionID==TestExecID).Select(p => p).OrderBy(p => p.StartTime).ToArray();
 
var failures = entities.TestExecutionDetails.Select(p => p.Result!="Pass  ").Count();
 
var count = entities.TestExecutionDetails.Count();
 
var uptime = entities.TestExecutionDetails.Where(p => p.Result=="Pass  ").Select(p => p);
 
TimeSpan elapsedDuration =newTimeSpan(0);
 
foreach(var p in uptime)
 
{

  elapsedDuration
+=(p.EndTime.Value- p.StartTime.Value);

 
}
 
var mtbfdisplay = elapsedDuration.TotalSeconds/ failures;


 
string str1 =@"

  data = google.visualization.arrayToDataTable(["
;

 
string str2 =@"['Label', 'Value'],['MTBF',"+ mtbfdisplay +@"],]);";

 
string str3 =@"var options = {
  width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5
  };


  var chart = new google.visualization.gauge(document.getelementbyid('chart-success'));
  drawchart(data, options);"
;

 
string postData = str1 + str2 + str3;

 
Console.WriteLine(postData);


 
ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"test", postData,true);

 
}


 
}
 
}
}

.aspx


<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm3.aspx.cs"Inherits="WebApplication1.WebForm3" %>
<!DOCTYPE html><htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server"><title></title></head>
<body><formid="form1"runat="server">
<scripttype="text/javascript"src="https://www.google.com/jsapi"></script>
<scripttype="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>

<asp:ScriptManagerID="ScriptManager1"runat="server">
</asp:ScriptManager>
<asp:LabelID="Label2"runat="server"Text="1"></asp:Label>
<br/>
<div><asp:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:HiddenFieldID="HiddenField1"runat="server"Value="1"/>
<br/>
<asp:LabelID="Label1"runat="server"Text="1"></asp:Label>
<br/><asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/>
<divid="chart-success"></div>
</ContentTemplate>
</asp:UpdatePanel>
</div></form></body></html>

Viewing all articles
Browse latest Browse all 32057

Trending Articles