Beispiel #1
0
        public void PassRatesBroadband()
        {
            using (NetaServiceClient proxy = new NetaServiceClient())
            {
                allBBandPRItems = proxy.MyView();
                var serilizer = new System.Web.Script.Serialization.JavaScriptSerializer();
            }

            DataTable dt = new DataTable();

            dt = ConvertToDatatable(allBBandPRItems);


            StringBuilder str = new StringBuilder();

            str.Append(@"<script type = 'text/javascript'>
                      google.load('visualization', '1', { packages: ['corechart']});
            
                      function drawVisualization() {
                      var data = google.visualization.arrayToDataTable([
                       ['SchoolName','PercentPassed','AverageSpeed'],");

            int count = dt.Rows.Count - 1;

            for (int i = 0; i <= count; i++)
            {
                if (count == i)
                {
                    str.Append("['"
                               + dt.Rows[i]["SchoolName"].ToString()
                               + "',"
                               + dt.Rows[i]["PercentPassed"].ToString()
                               + ","
                               + dt.Rows[i]["AverageSpeed"].ToString()
                               + "]]);");
                }
                else
                {
                    str.Append("['"
                               + dt.Rows[i]["SchoolName"].ToString()
                               + "',"
                               + dt.Rows[i]["PercentPassed"].ToString()
                               + ","
                               + dt.Rows[i]["AverageSpeed"].ToString()
                               + "],");
                }
            }


            str.Append("var options = {vAxes: {0: { title: 'Percent', format: ''},1: { title: 'Average Speed (mbps)', format: '##'}},hAxis: { title: 'School Name', format: ''},seriesType: 'bars',series:{ 0:{ type: 'bars', targetAxisIndex: 0}, 1: { type: 'line', targetAxisIndex: 1}}, };");

            str.Append(" var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));  chart.draw(data, options); } google.setOnLoadCallback(drawVisualization);");

            bbprScripts.Text = str.ToString() + "</script>";
        }//PassRatesBroadband