FVANCOP / ChartNew.js

MIT License
420 stars 142 forks source link

updateChart fails to update the entire dataset #415

Closed MaxEvron closed 8 years ago

MaxEvron commented 8 years ago

Hey,

I use a page where users can select a report and set some parameters to retrieve associated data. When I retrieve the data for the very first time since the page is loaded, I call the following:

new Chart(document.getElementById("mycanvas").getContext("2d")).Line(data, options));

If the user choose another report or set others parameters, then when I retrieve other data, I call the following :

updateChart(document.getElementById("mycanvas").getContext("2d"), data, options, true, true);

My options are as follow:

var options = {
        responsive : true,
        animationByDataset : true,
        animationLeftToRight : true,
        legend : true,
        inGraphDataShow : true,
        inGraphDataAlign : "center",
        inGraphDataPaddingY : 15,
        inGraphDataPaddingX : 0,
        inGraphDataFontStyle : "bold",
        highLight: true,
        mouseMove: chartMouseFocus,
        mouseOut: chartMouseBlur
}

With chartMouseFocus and chartMouseBlur some personal functions to highlight data in an isolated html <table>.

On the screen, the chart is redrawn the right way and highlight works fine when retrieving data for the very first time. But, after retrieving new data and calling updateChart, even if the chart is redrawn the right way, hovering the chart suddenly replaces the freshly redrawn chart with the one created from the data loaded the very first time.

Thus, it seems updateChart does not do all the job.

FVANCOP commented 8 years ago

I think that you have the same problem that I found with the drillDown.js add-ins used in association with the highLight feature.

One think that you can try, is to put a call to "deleteHighLight(ctx,data);" just before the update function.

If it does not work, can you send your code to my email address so that I can try to debug the problem and find a solution.

Regards, François

MaxEvron commented 8 years ago

Thanks François. Could you please tell me what is data, here? Is this the previous or the new data?

FVANCOP commented 8 years ago

For safety, you can do it for both data; But please, take contact by mail for subsequent questions about that problem; Otherwise, followers receive lot of mails they are not interested in.

FVANCOP commented 8 years ago

Problem fixed with last published version.

Thanks to @MaxEvron for his help - He founds the root of the problem.