"The Piechart created using the below code displays duplicate values randomly, on refreshing the chart gets corrected."
Want to understand the problem and solution thereof...
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json",
url: '@Url.Action("VisualizeBookingStatus", "View")',
success: function (result) {
// Load the Visualization API and the corechart package.
google.charts.load('current', { 'packages': ['corechart'] });
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(function () {
drawChart(result);
});
}
});
});
function drawChart(result) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Agency');
data.addColumn('number', 'Booked');
var dataArray = [];
$.each(result, function (i, obj) {
});
data.addRows(dataArray);
var chartoptions = {
'title': 'Booking-Agencywise',
chartArea: { width: 500, height: 400 },
is3D: true
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, chartoptions);
}