score:0

right, well i found the problem and the solution. the root of the issue came about when my page refreshed and the chart would resize. i then tried the chart.defaults.global.maintainaspectratio= false;command which worked but duplicated the x-axis tick labels.

the problem: these two commands cannot work together. it causes the duplication on hover.

chart.defaults.global.responsive = true; 
chart.defaults.global.maintainaspectratio= false;

the solution: found in the chartjs.org documentation. detecting when the canvas size changes can not be done directly from the canvas element. chart.js uses its parent container to update the canvas render and display sizes. however, this method requires the container to be relatively positioned and dedicated to the chart canvas only. responsiveness can then be achieved by setting relative values for the container size (example):

<div class="chart-container" style="position: relative; height:40vh; width:80vw">
    <canvas id="chart"></canvas>
</div>

note that in order for the above code to correctly resize the chart height, the maintainaspectratio option must also be set to false.

i added the div's to encase my canvas, changed the sizing and this fixed my problem :)


Related Query

More Query from same tag