Our overlayLogo
function will calculate the new height and position for our logo. Then, we will use the drawImage
method to convert the image and make it part of the main canvas. We wrap all of this in a setInterval
function because we have to wait for jqPlot to render all the canvas elements before we can add our image. Perform the following steps to add extra canvas elements:
We start by setting
yPos
tobottom
if nothing is passed in for this parameter. When calculating coordinates for acanvas
element, we begin at the upper-left corner. So, we declare variables for our height and the x and y coordinates. Next, we create a variable to hold oursetInterval
function as follows:function overlayLogo(id, scaledWidth, yPos) { if(typeof(yPos) === 'undefined') { yPos = 'bottom' }; var height = 0, top = 0, left = 0, canvas = ''; var checkCanvas = setInterval(function() {
jqPlot does not add an ID to the
canvas
elements it creates, so we need to locate ourcanvas...