[HtmlUnit] [htmlunit:bugs] #2004 HtmlUnit 2.33 not processes chart js

RBRi via HtmlUnit-develop <[email protected]> Mon, 10 Dec 2018 19:33:49 -0000
Newsgroups gmane.comp.java.htmlunit.devel
Message-ID </p/htmlunit/bugs/2004/0f3f486169fb6c5e81be13a64c8a7012a33c4492.bugs@htmlunit.p.sourceforge.net>
- **status**: open --> pending
- **assigned_to**: RBRi
- **Comment**:

Hi Manikandan,

you are (more or less) right, the animation support was not there so far. But with the current snapshot build i have

* added animation support
* have implemented many more canvas functions.

Now chart.js is basically supported.

Because HtmlUnit does not redraw the page like real browsers, you have to force (and you can control) the animation from your code.

~~~
final HtmlPage page = webClient.getPage(url);
webClient.waitForBackgroundJavaScript(4000);

Window window = page.getEnclosingWindow().getScriptableObject();
int i = 0;
do {
    System.out.println("start animation " + i);
    i = window.animateAnimationsFrames();
    System.out.println("end animation");
} while (i > 0);

HtmlCanvas pic = (HtmlCanvas) page.getElementById("canvas");
HTMLCanvasElement picelem = (HTMLCanvasElement) pic.getScriptableObject();

String png = picelem.toDataURL("image/png");
~~~

Hope that helps. Of course the implementation of CanvasRenderingContext2D is far from perfect/complete. It will be great if you can make some more improvements and share your stuff as Github pull request(s).




---

** [bugs:#2004] HtmlUnit 2.33 not processes chart js **

**Status:** pending
**Group:** 2.33
**Created:** Fri Dec 07, 2018 03:15 PM UTC by Manikandan Kabali
**Last Updated:** Fri Dec 07, 2018 03:15 PM UTC
**Owner:** RBRi


Hi all,
I am using chart.js library to create chart in my code. Chart.js renders chart in the canvas dynamically. When I process the html using HtmlUnit, it is not rendering the chart in the canvas. I think HtmlUnit is not processing animation. It results in empty canvas. Please suggest some solutions to process chart.js code.

Thanks,
Manikandan Kabali


---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.

_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop