add a function to adapt data to the canvas width and height