Plotting a function graph in JavaScript using canvas element.