speech-commands/demo/dataset-vis.js
function getCanvasClickRelativeXCoordinate(canvasElement, event) {
  let x;
  if (event.pageX) {
    x = event.pageX;
  } else {
    x = event.clientX + document.body.scrollLeft +
        document.documentElement.scrollLeft;
  }
  x -= canvasElement.offsetLeft;
  return x / canvasElement.width;
}
function getCanvasClickRelativeXCoordinate(canvasElement, event) {
  let x;
  if (event.pageX) {
    x = event.pageX;
  } else {
    x = event.clientX + document.body.scrollLeft +
        document.documentElement.scrollLeft;
  }
  x -= canvasElement.offsetLeft;
  return x / canvasElement.width;
}
function getCanvasClickRelativeXCoordinate ( canvasElement , event ) { let x ; if ( event . pageX ) { x = event . pageX ; } else { x = event . clientX + document . body . scrollLeft + document . documentElement . scrollLeft ; } x -= canvasElement . offsetLeft ; return x / canvasElement . width ; }
Get the relative x-coordinate of a click event in a canvas.

@param {HTMLCanvasElement} canvasElement The canvas in which the click
event happened.
@param {Event} event The click event object.
@return {number} The relative x-coordinate: a `number` between 0 and 1.
Get the relative x - coordinate of a click event in a canvas .