Dear Friends, How I can show the pie chart in asp.net c# as all my data came from the database so I write the code in aspx page as below
*<asp:Content ID="Content2" ContentPlaceHolderID="head" Runat="Server">* * <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>* * <script type="text/javascript">* * google.charts.load("current", {packages:["corechart"]});* * google.charts.setOnLoadCallback(drawChart);* * function drawChart() {* * var data = google.visualization.arrayToDataTable([* * <asp:Repeater ID="rptMarkers" runat="server">* * <ItemTemplate>* * {* * "Trail Type"; '<%# Eval("Trail_Type") %>',* * "Plot"; '<%# Eval("Plot") %>',* * }* * </ItemTemplate>* * <SeparatorTemplate>* * ,* * </SeparatorTemplate>* * </asp:Repeater>* * ]);* * var options = {* * title: 'My Trial Assigment',* * is3D: true,* * };* * var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));* * chart.draw(data, options);* * }* * </script>* *</asp:Content>* *<asp:Content ID="Content3" ContentPlaceHolderID="body" Runat="Server">* * <div id="piechart_3d" style="width: 900px; height: 500px;"></div>* *</asp:Content>* *and CS page code as Below* *if (!this.IsPostBack) { DataTable dt = this.GetData("SP_Name"); rptMarkers.DataSource = dt; rptMarkers.DataBind(); } } protected DataTable GetData(string query) { string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString; SqlCommand cmd = new SqlCommand(query); cmd.Parameters.AddWithValue("@ddlyear", "2019"); cmd.Parameters.AddWithValue("@season", "K"); cmd.Parameters.AddWithValue("@usercode", "97******"); cmd.Parameters.AddWithValue("@role", "0"); cmd.CommandType = CommandType.StoredProcedure; using (SqlConnection con = new SqlConnection(conString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); return dt; } } } }This code bind the data to"Trail Type"; '<%# Eval("Trail_Type") %>', "Plot"; '<%# Eval("Plot") %>',as below var data = google.visualization.arrayToDataTable([ { "Trail Type"; 'DEM', "Plot"; '94', } , { "Trail Type"; 'GCA', "Plot"; '2', } , ]); But chart not visible on page.can anyone help me?* -- This email and any attachments may contain confidential material and is solely for the use of the intended recipient(s). If you have received this email in error, please notify the sender immediately and delete this email and any attachments. If you are not the intended recipient(s), you must not use, retain or disclose any information contained in this email. Any use, reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message or any part thereof, its contents or its attachment(s), if any, in any manner whatsoever, other than by its intended recipient(s), is strictly prohibited. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. Mahyco* *therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. Mahyco does not guarantee that this email or any attachments are free from viruses or 100% secure even though reasonable precautions are taken. Mahyco accepts no liability for any damage caused by any virus transmitted by this email or any attachment. Mahyco reserves the right to monitor all E-mail communications through its network. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/1290b278-3a7c-4e0a-8ff5-9b8d40870d9f%40googlegroups.com.
