Redraw Morris Donut after AJAX call
<p>I'm using Morris Donut for a dashboard I'm working on and retrieving data via AJAX using two date ranges as parameters. The problem I'm facing is when I enter two new date ranges the Donut Chart renders a new one on top of Donut already created upon page load. I've searched about and can see information on using <code>setData()</code>, but I have no idea how to include this within my code.</p>

<p><strong>My Code:</strong></p>

<pre><code>$(document).ready(function () {
        var start = $('#SearchStart').val();
        var end = $('#SearchEnd').val();
        populateDonut(start, end); 
});
</code></pre>

<p>The search button does the following when clicked:</p>

<pre><code>$('#DateRange').click(function() {
        var start = $('#SearchStart').val();
        var end = $('#SearchEnd').val();
        populateDonut(start, end);
});
</code></pre>

<p>Here is the function that is called. </p>

<pre><code>function populateDonut(start, end) {
var param = { start: start, end: end };
$.ajax({
    type: "POST",
    url: "/WebService.asmx/getDonutData",
    contentType: "application/json; charset=utf-8",
    dataType: 'json',
    async: true,
    data: JSON.stringify(param),
    success: function (result) {
        var data = eval("(" + result.d + ")");
        var pieChart = '';
        if (data.status == 0) {
            var donut = Morris.Donut({
                element: 'pieChart',
                data: [
                    { label: "Inbound", value: data.inbound },
                    { label: "Outbound", value: data.outbound },
                    { label: "Unanswered", value: data.unanswered }
                ],
                colors: ['#1ca8dd', '#33b86c', '#ebc142'],
                resize: true,
                formatter: function (x) { return x + "%" }
            });
        }   
    }
  });
}
</code></pre>

<p><strong>Screenshot of what is happening after entering new date ranges:</strong>   </p>

<p><a href="https://i.stack.imgur.com/XY5tW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XY5tW.png" alt="enter image description here"></a></p>