0

I am trying to display a simple chart using eclipse scout 22 using their default abstract chart and not chart.js for simplicity. However the error I am left with now when loading the form with the chart on it is as follows:

 java.lang.IllegalArgumentException: No factory found for model null/ChartField 

I followed this tutorial put out by eclipse scout. To regurgitate the tutorial here is what i have done:

1.) In just the client pom.xml I added

 <dependency>
   <groupId>org.eclipse.scout.rt</groupId>
   <artifactId>org.eclipse.scout.rt.chart.client</artifactId>
 </dependency>

2.) I updated the maven project in the eclipse IDE and cleaned the project.

3.) In the package.json file in my ui.html I added "@eclipse-scout/chart": "22.0.0-beta.10", To "dependencies".

4.) In UI.html > MYPROJECT.js I added

import * as chart from '@eclipse-scout/chart';
Object.assign({}, chart);

5.) And in MYPROJECT-theme.less / MYPROJECT-theme-dark.less I added respecctfully:

@import "~@eclipse-scout/chart/src/index";
@import "~@eclipse-scout/chart/src/index-dark";

6.) Finally in my form within a group box i added:

public class ChartField extends AbstractChartField<Chart> {
   public class Chart extends AbstractChart {
   }
}

From what I've researched at this point it appears I need to maybe make a JsonObjectFactory for an adapter? I'm not sure how to do that in this case nor can I find a proper guide online. This is also the point in the tutorial where I could not add the fake data to the pie chart as seen in the link above for the scout tutorial. Im not sure where to put it? Reference: 21.2.3. Add data to the chart.

UPDATE: In my UI.HTML src/main/java I added a package with a folder for JsonObjectFactory, inside of that I have the following:

@Bean
 @Order(100)
 public class JsonObjectFactory extends AbstractJsonObjectFactory {

@Override
public IJsonAdapter<?> createJsonAdapter(Object model, IUiSession session, String id, IJsonAdapter<?> parent) {
    System.out.println("MY JSON ADAPTER BITCH");
    if (model instanceof IChartField) {
        return new JsonChartField((IChartField) model, session, id, parent);
    }
    return null;
}

}

without any further linking when I open the form containing the chart it still throws an error but inside my server side console I have print outs in my JsonObjectFactory. So now I am attempting to make a JsonChartField.java file. Once I get all errors resolved I will post another update. But I have a feeling I need a lot more css and js files to get this to even display a chart?

1 Answers1

1

I had a similar problem and exception in the JsonObjectFactory because of the ambiguity of the tutorial. You'll have to add the chart dependencies to the client-, shared- and ui.html pom files. Here is my post asking a question and its resolution on the Eclipse Scout form.

I hope this helps.

JDaniel

EDIT: To change chart types, change the IChartType in the code below. IChartType can have values from IChartType.BAR to IChartType.VENN.

@Order(1000)
public class Chart extends AbstractChart {
   @Override
   protected IChartConfig getConfiguredConfig() {
      return super.getConfiguredConfig().withType(IChartType.BAR);
   }
}
JDaniel
  • 100
  • 4
  • 9
  • Going to try out now, this is really helpful regardless – Reese Houseknecht Jan 24 '23 at 03:56
  • I have to keep trying but adding the maven dependency in the ui html is giving me missing artifact errors even after cleaning and updating maven several times – Reese Houseknecht Jan 24 '23 at 04:14
  • After forcing snap release when updating the maven project in eclipse on the specific folder (ui.html) it resolved the errors. Cant just update the whole project it lol thank you so much, and yes the technical guide made a big mistake with the or instead of and – Reese Houseknecht Jan 24 '23 at 04:30
  • If you dont mind me asking, i can also just post a separate question, but how can i then do a bar chart? is it just a plug and play of words that i just dont know or? – Reese Houseknecht Jan 24 '23 at 04:42