pepstock-org / Charba

J2CL and GWT Charts library based on CHART.JS
https://pepstock-org.github.io/Charba-Wiki/docs
Apache License 2.0
62 stars 6 forks source link

Do not use com.google.gwt classes #53

Closed FrankW76 closed 4 years ago

FrankW76 commented 4 years ago

To be future proof with GWT3/J2CL, using JsInterop instead of JSNI is not enough. You can also not use any of the com.google.gwt.* classes.

These should all be replaced by elemntal2, elemento or any from these https://ci.vertispan.com/

stockiNail commented 4 years ago

@FrankW76 Yes, we have started having a look to elemental2 and also new gwt-events. We are going to remove GWT dependencies from next major version.

Nevertheless it's still not clear some GWT capabiltiies how they will be implemented. For instance Client Bundle and how it will be implemented. At the moment, Client Bundle allows us to inject code in sync mode and it's very comfortable. As far as we have seen, the only way should be to do that async way and this means to change heavily the java scripts (and other resources) injection.

FYI, we are working to new version 3 (a branch has been already created) where we are addressing 2 main topics:

  1. Go to J2CL (elemental2), removing GWT dependencies
  2. CHART.JS 3

Let me say that this change will be time consuming because I have the feeling that some GWT capabilities won't be ported into elemental or other projects and we have to understand how to implement them.

stockiNail commented 4 years ago

@FrankW76 I had a look to https://ci.vertispan.com/ and the feeling is the things are moving but it looks like faraway to be consistent. I don't think it's a good idea create dependencies with snapshots. Hopefully new version will come soon. Furthermore many users are still using GWT and going to those artifacts, we will break definitely the support of current GWT because the packages are changed.

Then we created a specific branch where we are introducing elemental2, with the goal to remove (or better reduce) the dependency with GWT, even if it will introduce other dependencies (i.e. JSINTEROP base). I wrote "reduce" because we are thinking to provide anyway a hook in order to use Charba in current GWT and at the moment we are thinking to maintain:

These 2 items will force us to maintain the dependency with GWt but we could provide 2 artifacts, 1 with dependency and other without. There are many changes to do (for instance creating objects that usually are provided by GWT) because I'd like to reduce at minimum the amount of dependencies.

stockiNail commented 4 years ago

@FrankW76 let me share briefly what we are doing in order to face your request.

First of all, we opened an issue because last version 1.0.0 of elemental2 throws an exception with GWT 2.8.2. The answer to the issue is that the GWT team is developing version 2.9 and the support for GWT 2.8.2 is definitely dropped.

then we took a decision to develop a small DOM wrapper, completely decoupled from other libraries and GWT itself. This DOM wrapper does not have the goal to be used publicly because we haven't implemented all properties and methods, but only what Charba needs. We are going also to provide some cast helpers in order to hook Charba in other DOM wrappers (like elementals2, GWT Elemento or GWT itself).

Of course in next version we will release a jar as J2CL chart library (without any dependecy with GWT) and another artifact for GWT (2.8.2), with that dependency. And of course, we are mapping many breaking changes for Charba users (we're a Charba user as well). We are gonna do our best to reduce at minimum the changes.

The branch is called elemental but not committed yet.

More in next days.

stockiNail commented 4 years ago

@FrankW76 short update. The prototype (90%) is ready and we are testing that everything is working as expected. The prototype has been built as described above, and Charba is mainly a J2CL chart library and then a GWT one.

Hopefully we can complete by end of the month, committing on master. Nevertheless this is a big breaking change that would need of major version and we are evaluating if wait for CHART.JS 3.0 or not.

stockiNail commented 4 years ago

@FrankW76 the prelimary tests are completed. Showcase works as expected and also with Elemental2 and Elemento without using any GWT classes (even if tested on GWT). Additional tests on J2Cl platform will be performed soon. Now we are cleaning up the code and preparing the documentation (due to the many breaking changes will take days)

Here is the simple sample of Charba and Elemental2:

ResourcesType.setClientBundle(EmbeddedResources.INSTANCE);

LineChart chart = new LineChart();
chart.getOptions().setResponsive(true);
chart.getOptions().getLegend().setPosition(Position.TOP);
chart.getOptions().getTitle().setDisplay(true);
chart.getOptions().getTitle().setText("Charba Bar Chart3");

LineDataset dataset1 = chart.newDataset();
dataset1.setLabel("Eccome");

dataset1.setBackgroundColor(HtmlColor.BLUE.alpha(0.2));
dataset1.setBorderColor(HtmlColor.BLUE);

dataset1.setData(10, 45, 50, 25, 30, 5);

chart.getData().setLabels("1", "2", "3", "4", "5", "6");
chart.getData().setDatasets(dataset1);

chart.getChartElement().getStyle().setWidth("600px");
chart.getChartElement().getStyle().setHeight("300px");

Element elel = chart.getChartElement().as();

DomGlobal.document.body.appendChild(elel);

Let me know if you'd like to have a beta version to test/use, being aware that it will not the final version.

stockiNail commented 4 years ago

@FrankW76 the code is ready for version 3.0. The doc (wiki) has been updated. We are updating our Ivy configuration in order to push into MVN repo the 2 artifacts, one for J2Cl and one for GWT.

stockiNail commented 4 years ago

Showcase and wiki are tagged to version 3.0 and deployed. Charba itself is coming in next hours to have time to test some optimization the Ivy build (code is ready).

You can have a look to wiki. We have prepared a page about migration of current GWT projects and integration with other DOM tree frameworks (mainly Elemental2)

stockiNail commented 4 years ago

Version 3.0 has been published.