title: Refresh the Bar Char in ChartJS (v2.6.0) Using Ajax Correct Way
body: <p>I am refreshing my Bar Chart on change of a drop down. I just Want to know that am I doing it in correct way. In my code every time I am replacing my existing canvas with new one.
  Is there any better way to achieve same thing?</p>
  
  <p>My JS Code:</p>
  
  <pre><code>var chart_= function () {
  
      $('#canvas_id').replaceWith('&lt;canvas id="canvas_id" style="height:280px"&gt;&lt;/canvas&gt;');
      $.ajax({
          type: 'POST', //post method
          url: 'url', //ajaxformexample url
          dataType: "json",
          success: function (result, textStatus, jqXHR)
          {
              // GENERATE CHART DATA
              var labels = result.obj.map(function (e) {
                  return e.label;
              });
              var data = result.obj.map(function (e) {
                  return e.data;
              });
              new Chart($("#canvas_id"), {
                  type: 'bar',
                  options: options_object,
                  data: {
                      labels: labels,
                      datasets: [
                          {
                              label: "",
                              backgroundColor: '#00c0ef',
                              data: data
                          }
                      ]
                  }
  
              });
  
          }
      });
  };
  </code></pre>