Hi ashraft1,
Pie chart doesn't support animation. Animation is not listed as a supported option for pie charts. See the link.
https://developers.google.com/chart/interactive/docs/gallery/piechart#configuration-options
You can load the chart without postback using jQuery.
Refer the below example.
HTML
<center>
<asp:DropDownList ID="DrpMonth" runat="server" >
<asp:ListItem Text="Finland" Value="Finland" Selected="True"></asp:ListItem>
<asp:ListItem Text="Brazil" Value="Brazil"></asp:ListItem>
<asp:ListItem Text="USA" Value="USA"></asp:ListItem>
<asp:ListItem Text="Italy" Value="Italy"></asp:ListItem>
<asp:ListItem Text="Germany" Value="Germany"></asp:ListItem>
</asp:DropDownList>
</center>
<div id="chart" style="width: 900px; height: 500px;">
</div>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jsapi.js"></script>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(function () {
drawChart();
$("#DrpMonth").on("change", function () {
drawChart();
});
});
function drawChart() {
var country = $("#DrpMonth option:selected").val();
$.ajax({
type: "POST",
url: "CS.aspx/GetChartData",
data: "{country: '" + country + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var data = google.visualization.arrayToDataTable(r.d);
var chart = new google.visualization.PieChart($("#chart")[0]);
chart.draw(data, { title: country + ' Distribution', is3D: false });
},
failure: function (r) {
alert(r.d);
},
error: function (r) {
alert(r.d);
}
});
}
</script>
C#
[WebMethod]
public static List<object> GetChartData(string country)
{
string query = "SELECT ShipCity, COUNT(orderid) TotalOrders FROM Orders WHERE ShipCountry = @Country GROUP BY ShipCity";
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
List<object> chartData = new List<object>();
chartData.Add(new object[] { "ShipCity", "TotalOrders" });
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@Country", country);
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
chartData.Add(new object[] { sdr["ShipCity"], sdr["TotalOrders"] });
}
}
con.Close();
return chartData;
}
}
}
Output
