Wrapping Javascript library (chart.js) using JSInterop

100 views
Skip to first unread message

Manas

unread,
Sep 11, 2022, 5:11:00 AM9/11/22
to GWT Users
Hi All,

Good Day!

I'm new in GWT and I'm going through documentation and JSInterop. I'm facing issues with implementing chart.js using JSInterop. Can anyone guide me on how to resolve and keep things working? I am facing an error - "The import elemental2 cannot be resolved"

code is - 
package chartjs;

import elemental2.dom.HTMLCanvasElement; => facing error on this line
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public class Chart {

    public Chart(HTMLCanvasElement canvasElement, ChartConfiguration configuration) {
    }
}

Michael Conrad

unread,
Sep 11, 2022, 8:29:36 AM9/11/22
to google-we...@googlegroups.com
Check your dependencies. That is an add-on library which must be included explicitly.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/d85e1313-7a55-482f-b712-022cf6fef5acn%40googlegroups.com.

Manas

unread,
Sep 11, 2022, 8:53:25 AM9/11/22
to GWT Users
I have added a pom.xml file in the project attached below while running the command - mvn clean install I got an error - Compiling module com.jsinteropdemo.JSInteropDemo
[INFO]    [ERROR] Module has no entry points defined
Also attaching the screenshot of my project folder and default .XML file
Screenshot (15).png
pom.xml

Andrea Stocchero

unread,
Sep 11, 2022, 11:49:38 AM9/11/22
to GWT Users
Why don't you use Charba? https://github.com/pepstock-org/Charba

Charba is providing the wrapper of Chart.js for GWT and J2CL.
Reply all
Reply to author
Forward
0 new messages