1

I'm using the GWT Highcharts wrapper created by moxiegroup and want to add/change functionality to my project but also slowly move away from the moxiegroup wrapper as it uses JSNI and isn't maintained anymore. I am having trouble with importing Highcharts using Jsinterop in a way where i can use the JavaScriptObject as parameters for the Highcharts function. What i want to do is use the native Highcharts function setTitle() to change the title of my already existing Chart object created by the wrapper. Before i have fixed this by passing the object as a JavaScriptObject to JSNI like in the following example:

private static native void nativeAddAxis(JavaScriptObject chart, JavaScriptObject axisOptions, boolean isX, boolean redraw, boolean animationFlag) /*-{
        chart.addAxis(axisOptions, isX, redraw, animationFlag);
    }-*/;

But when trying to do the same with Jsinterop the code wont compile because the native functions don't accept the JavaScriptObject type. I have tried casting it to the correct Js type and looking at other projects that use Jsinterop to wrap highcharts without any success. Any help or suggestion on how to reach what i am trying to achieve without using JSNI is much appreciated. I must also add that i am very new to Js and far from a GWT guru.

  • Welcome to StackOverflow! Though the exercise of using JSInterop to wrap a library has value in and of itself, I'd suggest that you check out https://github.com/ascendtech/gwt-highcharts, a "relatively comprehensive JSInterop wrapping of Highcharts.js", to see it it suits your needs. – Boris Brudnoy Jun 24 '22 at 15:08
  • You could also contribute to the original library, https://github.com/squinn/gwt-highcharts, which isn't archived or deprecated but hasn't seen updates in a while. – Boris Brudnoy Jun 24 '22 at 15:09
  • I have checked out the GWT-Highcharts project and even though it seems nice it would mean i would have to rewrite the entire project code to replace the current wrapper as they cant really be combined. Therefore if possible it would be easier to write the few functions in Jsinterop instead of having to edit and debug some thousand lines of code which i dont have the resources to do atm. – Carl Ridderstolpe Jun 27 '22 at 13:14
  • Yeah @BorisBrudnoy if i don't find someone who know how to figure out this using Jsinterop or do it myself i will just have to write JSNI functions for the old wrapper or add the function later. And yes its not archived but it hasn't been updated for 17months and the questions in its forum hasn't been answered for 2+ years so its quite inactive. Its also built on a soon to be deleted functionality so it needs heavy restructuring to not be deprecated. – Carl Ridderstolpe Jun 27 '22 at 13:18

0 Answers0