I have a problem when I create a chart with chart.js and then I create another chart from the menu that is on the same page. It creates the graph, but when I move the cursor over the graph it changes to the previous graph.
Update
After a search in the chartJS documentation I found a supposed method that cleans the graph information with .removeData()
. I applied this method to the controller, but unfortunately it still displays the previous graph in the background when I move the mouse over the graph. I also made a console.log
in the array that contains the information and this information is updated with the last request information sent.
Driver Code
$scope.getChart = function (report) {
$scope.modalLabels = [];
$scope.data = {values: ([])}; //Array that contains the data recieved from the server
if($('#chartBar')!=null){
$('#chartBar').removeData();
}
/*Funçao para que obtém as informações por parte do servidor*/
//Se receber informação
var avgCapacity = [];
for (var i = 0, length = data.length; i < length; i++) {
avgCapacity.push(data[i].Volume);
$scope.modalLabels.push(data[i].Day + "/" + data[i].Month);
}
$scope.data.values = ([avgCapacity]);
First chart Secondchart Htmlthatgeneratesthegraphics:
<divng-hide="data==0">
<h4 id="chartTitle"><b>{{Title}}</b></h4>
<canvas id="bar" class="chart chart-bar" chart-data="data" chart-options="options"
chart-labels="modalLabels" chart-legend="true" chart-series="series">