The GeoGebra example that John Travis pointed you to actually uses Java. I have deprecated that example (because it uses Java, which is no longer universally supported / permitted to run in web browsers) and in the past week have posted a "GeoGebraWeb" example that uses JavaScript instead and should run on all web browsers and on other devices such as tablets that support JavaScript. See http://webwork.maa.org/wiki/GeoGebraWeb1 There are a number of GeoGebraWeb examples in the OPL directory
I plan to discuss embedding JavaScript into WeBWorK problems in workshop 4 (or perhaps the end of workshop 3). I have a few working examples of "GeoGebraWeb" (GeoGebra run by JavaScript) and an example using d3.js to display a histogram rendered in html (but not pdf).
Best regards,
Paul Pearson