On Tuesday, February 25, 2014 3:50:43 PM UTC, Missy wrote:
>
> I am getting the "failed to draw" error on the client-end using the 
> following code below:
>
> <script type="text/javascript">
> function drawVisualization(dataValues, chartTitle, columnNames, 
> categoryCaption) {
>             if (dataValues.length < 1)
>                 return;
>
>             var data = new google.visualization.DataTable();
>             data.addColumn('string', columnNames.split(',')[0]);
>             data.addColumn('number', columnNames.split(',')[1]);
>             data.addColumn('string', columnNames.split(',')[2]);
>
>
>             for (var i = 0; i < dataValues.length; i++) {
>                 data.addRow([dataValues[i].ColumnName, 
> dataValues[i].Value, dataValues[i].Type]);
>             }
>
>             // Define a category picker control for the Gender column
>             var categoryPicker = new google.visualization.ControlWrapper({
>                 'controlType': 'CategoryFilter',
>                 'containerId': 'CategoryPickerContainer',
>                 'options': {
>                     'filterColumnLabel': columnNames.split(',')[2],
>                     'ui': {
>                         'labelStacking': 'horizontal',
>                         'allowTyping': false,
>                         'allowMultiple': false,
>                         'caption': categoryCaption,
>                         'label': columnNames.split(',')[2]
>                     }
>                 }
>             });
>
>             // Define a Pie chart
>             var pie = new google.visualization.ChartWrapper({
>                 'chartType': 'LineChart',
>                 'containerId': 'PieChartContainer',
>                 'options': {
>                     'width': 950,
>                     'height': 450,
>                     'legend': 'right',
>                     'title': chartTitle,
>                     'chartArea': { 'left': 100, 'top': 100, 'right': 0, 
> 'bottom': 100 },
>                     'pieSliceText': 'label',
>                     'tooltip': { 'text': 'percentage' }
>                 },
>                 'view': { 'columns': [0, 1] }
>             });
>
>             new 
> google.visualization.Dashboard(document.getElementById('PieChartExample')).bind([categoryPicker],[pie]).draw(data);
>         }
>
>
> </script>
>       <div id="PieChartExample">
>             <table>
>                 <tr style='vertical-align: top'>
>                     <td>
>                         <div id="CategoryPickerContainer"></div>      
>                         <div id="control1"></div>
>                         <div id="control2"></div>             
>                     </td>
>                 </tr>
>                 <tr>
>                     <td >
>                         <div style="float: left;" 
> id="PieChartContainer"></div>            
>                     </td>
>                     
>                 </tr>
>             </table>         
>         </div>
>
> Code behind - default.aspx.cs
> protected void Page_Load(object sender, EventArgs e)
>     {
>         if (!IsPostBack)
>         {
>
>             JavaScriptSerializer jss = new JavaScriptSerializer();
>             ClientScript.RegisterStartupScript(this.GetType(), 
> "TestInitPageScript",
>             //string.Format("<script 
> type=\"text/javascript\">google.load('visualization','1.0',{{'packages':['corechart','controls']}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>",
>            string.Format("<script 
> type=\"text/javascript\">google.load('visualization','1.0',{{'packages':['corechart','controls']}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}');}});</script>",
>             jss.Serialize(GetData()),
>             "Text Example",
>              "Name,type,"));
>  
>
>         }
>     }
>
>     [WebMethod]
>     public static List<Data> GetData()
>     {
>         SqlConnection conn = new SqlConnection("######");                 
>                                                                             
>      
>         DataSet ds = new DataSet();
>         DataTable dt = new DataTable();
>         conn.Open();
>         string cmdstr = "select top 100 Name, [Decimal price],Cover from 
> [dbo].[database]";
>         SqlCommand cmd = new SqlCommand(cmdstr, conn);
>         SqlDataAdapter adp = new SqlDataAdapter(cmd);
>         adp.Fill(ds);
>         dt = ds.Tables[0];
>         List<Data> dataList = new List<Data>();
>         string cat="";
>         float val=0;
>         string typ = "";
>         
>         foreach (DataRow dr in dt.Rows)
>         {
>             try
>             {
>                 cat = dr[0].ToString();
>
>                 val = Convert.ToInt32(dr[1]);
>
>                 typ = dr[2].ToString();
>
>             }
>             catch
>             {
>             }
>             dataList.Add(new Data(cat, val, typ));
>         }
>         return dataList;
>     }
>
> Any help would be very much appreciated. Thanks 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to