draw new chart over an older chart

hi all
here is my app : http://codepen.io/spyshow/pen/WGZRvv?editors=0010
it’s an weather app … when i press the F/C button it will redraw another chart with new dataset over the old one . but if you hover the mouse over the point of the old chart the old chart will come forward .

how can i delete the old chart and redraw the new one after that?


Author: Fantashit

1 thought on “draw new chart over an older chart

  1. You can’t really replace the chart canvas because it requires some initialization done at the chart construction time but also because you should not use the chart object after calling destroy(). So if you still want to use that approach, you need to create a new chart each time you re-create the canvas:

    $('#' + childCanvasId).remove();
    $(this).append('<canvas id="' + childCanvasId + '"></canvas>');
    charts[childCanvasId] = new Chart($("#" + childCanvasId), config);

    But again, if your chart type doesn’t change, update() is the best approach 🙂

Comments are closed.