| Home » Eclipse Projects » Eclipse Scout » Cannot get simple chart example working(Chart example in the Technical Guide not working for me)
 Goto Forum:| 
| Cannot get simple chart example working [message #1856738] | Tue, 27 December 2022 08:13  |  | 
| Eclipse User  |  |  |  |  | Hi there everyone, 
 I'm having some trouble getting the most basic chart example to work in Eclipse Scout.
 
 I am trying to implement the example in the technical guide:  https://eclipsescout.github.io/22.0/technical-guide.html#how-to-create-a-chart
 
 I decided to try in in the basic Hello Scout project.
 
 The project's HelloWorldForm.java now looks like this:
 
 
 
@FormData(value = HelloWorldFormData.class, sdkCommand = FormData.SdkCommand.CREATE)
public class HelloWorldForm extends AbstractForm {
	public HelloWorldForm() {
		setHandler(new ViewHandler());
	}
	@Override
	protected boolean getConfiguredAskIfNeedSave() {
		return false;
	}
	@Override
	protected int getConfiguredModalityHint() {
		return MODALITY_HINT_MODELESS;
	}
	@Override
	protected String getConfiguredIconId() {
		return AbstractIcons.World;
	}
	public MainBox getMainBox() {
		return getFieldByClass(MainBox.class);
	}
	public ChartBox getChartBox() {
		return getFieldByClass(ChartBox.class);
	}
	public TopBox getTopBox() {
		return getFieldByClass(TopBox.class);
	}
	public MessageField getMessageField() {
		return getFieldByClass(MessageField.class);
	}
	@Order(1000)
	public class MainBox extends AbstractGroupBox {
		@Order(1000)
		public class TopBox extends AbstractGroupBox {
			@Override
			protected String getConfiguredLabel() {
				return TEXTS.get("MessageFromServer");
			}
			@Order(1000)
			public class MessageField extends AbstractStringField {
				@Override
				protected int getConfiguredGridW() {
					return 2;
				}
				@Override
				protected String getConfiguredLabel() {
					return TEXTS.get("Message");
				}
				@Override
				protected boolean getConfiguredEnabled() {
					return false;
				}
			}
		}
		@Order(2000)
		public class ChartBox extends AbstractGroupBox {
			@Override
			protected String getConfiguredLabel() {
				return TEXTS.get("Chart");
			}
		
			@Order(1000)
			public class ChartField extends AbstractChartField<Chart> {
				public class Chart extends AbstractChart {
					
					ChartData data = new ChartData();
					
					List<IChartAxisBean> axis = new ArrayList<>();
					Stream.of("Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec.").forEach(label -> axis.add(new ChartAxisBean(label, label)));
					data.getAxes().add(axis);
					
					
					MonupleChartValueGroupBean vanilla = new MonupleChartValueGroupBean();
					vanilla.setGroupName("Vanilla");
					IntStream.of(0, 0, 0, 94, 162, 465, 759, 537, 312, 106, 0, 0)
					    .forEach(value -> vanilla.getValues().add(new BigDecimal(value)));
					data.getChartValueGroups().add(vanilla);
					MonupleChartValueGroupBean chocolate = new MonupleChartValueGroupBean();
					chocolate.setGroupName("Chocolate");
					IntStream.of(0, 0, 0, 81, 132, 243, 498, 615, 445, 217, 0, 0)
					    .forEach(value -> chocolate.getValues().add(new BigDecimal(value)));
					data.getChartValueGroups().add(chocolate);
					MonupleChartValueGroupBean strawberry = new MonupleChartValueGroupBean();
					strawberry.setGroupName("Strawberry");
					IntStream.of(0, 0, 0, 59, 182, 391, 415, 261, 75, 31, 0, 0)
					    .forEach(value -> strawberry.getValues().add(new BigDecimal(value)));
					data.getChartValueGroups().add(strawberry);
					chart.setData(data);				
				}
			}		
		
		}		
	}
	public class ViewHandler extends AbstractFormHandler {
		@Override
		protected void execLoad() {
			IHelloWorldService service = BEANS.get(IHelloWorldService.class);
			HelloWorldFormData formData = new HelloWorldFormData();
			exportFormData(formData);
			formData = service.load(formData);
			importFormData(formData);
		}
	}
}
 The problem is that the project does not compile anymore because of 3 lines:
 
 
	List<IChartAxisBean> axis = new ArrayList<>();
	Stream.of("Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec.").forEach(label -> axis.add(new ChartAxisBean(label, label)));
	data.getAxes().add(axis);
 The errors I'm getting are in the attached screenshot
 
 I know this may seem trivial but I really don't know where I got it wrong. Can anyone please help me figure this out. Thanks a lot.
 
 Cheers,
 
 JD
 
 |  |  |  |  |  |  |  |  | 
| Re: Cannot get simple chart example working [message #1856849 is a reply to message #1856738] | Thu, 05 January 2023 09:02   |  | 
| Eclipse User  |  |  |  |  | Hi there Mat, 
 Thanks a lot for your reply and clarifications. I've moved the chart creation code into the ViewHandler's execLoad, but it still does not work.
 
 This is what the HelloWorldForm.java class looks like now:
 
 
 
public class HelloWorldForm extends AbstractForm {
  public HelloWorldForm() {
    setHandler(new ViewHandler());
  }
  @Override
  protected boolean getConfiguredAskIfNeedSave() {
    return false;
  }
  @Override
  protected int getConfiguredModalityHint() {
    return MODALITY_HINT_MODELESS;
  }
  @Override
  protected String getConfiguredIconId() {
    return AbstractIcons.World;
  }
  public MainBox getMainBox() {
    return getFieldByClass(MainBox.class);
  }
  public ChartBox getChartBox() {
    return getFieldByClass(ChartBox.class);
  }
  
  public HelloScoutChartField getChartField() {
    return getFieldByClass(HelloScoutChartField.class);
  }
  public IChart getFieldChart() {
    return getChartField().getChart();
  }
  
  public TopBox getTopBox() {
    return getFieldByClass(TopBox.class);
  }
  public MessageField getMessageField() {
    return getFieldByClass(MessageField.class);
  }
  @Order(1000)
  public class MainBox extends AbstractGroupBox {
    @Order(1000)
    public class TopBox extends AbstractGroupBox {
      @Override
      protected String getConfiguredLabel() {
        return TEXTS.get("MessageFromServer");
      }
      @Order(1000)
      public class MessageField extends AbstractStringField {
        @Override
        protected int getConfiguredGridW() {
          return 2;
        }
        @Override
        protected String getConfiguredLabel() {
          return TEXTS.get("Message");
        }
        @Override
        protected boolean getConfiguredEnabled() {
          return false;
        }
      }
    }
    @Order(2000)
    public class ChartBox extends AbstractGroupBox {
      @Override
      protected String getConfiguredLabel() {
        return TEXTS.get("Chart");
      }
      
      @Order(1000)
      public class HelloScoutChartField extends AbstractChartField<IChart> {
        
        @Override
        protected int getConfiguredGridH() {
          return 10;
        }
        
        @Override
        protected boolean getConfiguredLabelVisible() {
          return false;
        };
        
        @Override
        protected boolean getConfiguredStatusVisible() {
          return false;
        };
        public class Chart extends AbstractChart {         
        }
      }
    }
       
  }
  public class ViewHandler extends AbstractFormHandler {
    @Override
    protected void execLoad() {
      IHelloWorldService service = BEANS.get(IHelloWorldService.class);
      HelloWorldFormData formData = new HelloWorldFormData();
      exportFormData(formData);
      formData = service.load(formData);
      importFormData(formData);
      
      // Chart creation
      ChartData data = new ChartData();
      List<IChartAxisBean> axis = new ArrayList<>();
      Stream.of("Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec.")
          .forEach(label -> axis.add(new ChartAxisBean(label, label)));
      data.getAxes().add(axis);
      MonupleChartValueGroupBean vanilla = new MonupleChartValueGroupBean();
      vanilla.setGroupName("Vanilla");
      IntStream.of(0, 0, 0, 94, 162, 465, 759, 537, 312, 106, 0, 0)
          .forEach(value -> vanilla.getValues().add(new BigDecimal(value)));
      data.getChartValueGroups().add(vanilla);
      MonupleChartValueGroupBean chocolate = new MonupleChartValueGroupBean();
      chocolate.setGroupName("Chocolate");
      IntStream.of(0, 0, 0, 81, 132, 243, 498, 615, 445, 217, 0, 0)
          .forEach(value -> chocolate.getValues().add(new BigDecimal(value)));
      data.getChartValueGroups().add(chocolate);
      MonupleChartValueGroupBean strawberry = new MonupleChartValueGroupBean();
      strawberry.setGroupName("Strawberry");
      IntStream.of(0, 0, 0, 59, 182, 391, 415, 261, 75, 31, 0, 0)
          .forEach(value -> strawberry.getValues().add(new BigDecimal(value)));
      data.getChartValueGroups().add(strawberry);
      // Put the chart data in the chart field
      getChartBox().getFieldByClass(HelloScoutChartField.class).getChart().setData(data);
      
      //getChartField().getChart().setData(data);
    }
  }
}
 This code throws an IllegalArgumentException shown below:
 
 
 
java.lang.IllegalArgumentException: No factory found for model null/HelloScoutChartField (org.eclipse.scout.apps.helloscout.client.helloworld.HelloWorldForm$MainBox$ChartBox$HelloScoutChartField)
	at org.eclipse.scout.rt.ui.html.json.MainJsonObjectFactory.createJsonAdapter(MainJsonObjectFactory.java:59)
	at org.eclipse.scout.rt.ui.html.UiSession.newJsonAdapter(UiSession.java:1093)
	at org.eclipse.scout.rt.ui.html.UiSession.createJsonAdapter(UiSession.java:1079)
	at org.eclipse.scout.rt.ui.html.UiSession.getOrCreateJsonAdapter(UiSession.java:1074)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.attachAdapter(AbstractJsonAdapter.java:207)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.createAdapter(JsonAdapterProperty.java:110)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.createAdapters(JsonAdapterProperty.java:94)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.createAdapters(JsonAdapterProperty.java:85)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.attachChildAdapters(JsonAdapterProperty.java:150)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonPropertyObserver.attachChildAdapters(AbstractJsonPropertyObserver.java:119)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonFormField.attachChildAdapters(JsonFormField.java:254)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.init(AbstractJsonAdapter.java:103)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonPropertyObserver.init(AbstractJsonPropertyObserver.java:53)
	at org.eclipse.scout.rt.ui.html.UiSession.newJsonAdapter(UiSession.java:1094)
	at org.eclipse.scout.rt.ui.html.UiSession.createJsonAdapter(UiSession.java:1079)
	at org.eclipse.scout.rt.ui.html.UiSession.getOrCreateJsonAdapter(UiSession.java:1074)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.attachAdapter(AbstractJsonAdapter.java:207)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.createAdapter(JsonAdapterProperty.java:110)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.createAdapters(JsonAdapterProperty.java:94)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.createAdapters(JsonAdapterProperty.java:85)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterProperty.attachChildAdapters(JsonAdapterProperty.java:150)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonPropertyObserver.attachChildAdapters(AbstractJsonPropertyObserver.java:119)
	at org.eclipse.scout.rt.ui.html.json.form.fields.JsonFormField.attachChildAdapters(JsonFormField.java:254)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.init(AbstractJsonAdapter.java:103)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonPropertyObserver.init(AbstractJsonPropertyObserver.java:53)
	at org.eclipse.scout.rt.ui.html.UiSession.newJsonAdapter(UiSession.java:1094)
	at org.eclipse.scout.rt.ui.html.UiSession.createJsonAdapter(UiSession.java:1079)
	at org.eclipse.scout.rt.ui.html.UiSession.getOrCreateJsonAdapter(UiSession.java:1074)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.attachAdapter(AbstractJsonAdapter.java:207)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.attachAdapter(AbstractJsonAdapter.java:196)
	at org.eclipse.scout.rt.ui.html.json.form.JsonForm.attachChildAdapters(JsonForm.java:156)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.init(AbstractJsonAdapter.java:103)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonPropertyObserver.init(AbstractJsonPropertyObserver.java:53)
	at org.eclipse.scout.rt.ui.html.json.form.JsonForm.init(JsonForm.java:72)
	at org.eclipse.scout.rt.ui.html.UiSession.newJsonAdapter(UiSession.java:1094)
	at org.eclipse.scout.rt.ui.html.UiSession.createJsonAdapter(UiSession.java:1079)
	at org.eclipse.scout.rt.ui.html.UiSession.getOrCreateJsonAdapter(UiSession.java:1074)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.attachGlobalAdapter(AbstractJsonAdapter.java:312)
	at org.eclipse.scout.rt.ui.html.json.AbstractJsonAdapter.attachGlobalAdapter(AbstractJsonAdapter.java:302)
	at org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline.attachNode(JsonOutline.java:132)
	at org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline.handleModelPageChanged(JsonOutline.java:281)
	at org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline.handleModelOtherTreeEvent(JsonOutline.java:266)
	at org.eclipse.scout.rt.ui.html.json.tree.JsonTree.processBufferedEvent(JsonTree.java:578)
	at org.eclipse.scout.rt.ui.html.json.tree.JsonTree.processBufferedEvents(JsonTree.java:521)
	at org.eclipse.scout.rt.ui.html.json.JsonResponse.fireProcessBufferedEvents(JsonResponse.java:354)
	at org.eclipse.scout.rt.ui.html.json.JsonResponse.toJson(JsonResponse.java:287)
	at org.eclipse.scout.rt.ui.html.UiSession.responseToJsonInternal(UiSession.java:834)
	at org.eclipse.scout.rt.ui.html.UiSession.lambda$6(UiSession.java:852)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:227)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxMandatory(TransactionProcessor.java:156)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.runTxRequired(TransactionProcessor.java:139)
	at org.eclipse.scout.rt.platform.transaction.TransactionProcessor.intercept(TransactionProcessor.java:78)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.context.RunContext.call(RunContext.java:158)
	at org.eclipse.scout.rt.platform.context.RunContextRunner.intercept(RunContextRunner.java:38)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.job.internal.CallableChainExceptionHandler.intercept(CallableChainExceptionHandler.java:33)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain$Chain.continueChain(CallableChain.java:222)
	at org.eclipse.scout.rt.platform.chain.callable.CallableChain.call(CallableChain.java:170)
	at org.eclipse.scout.rt.platform.job.internal.JobFutureTask.lambda$0(JobFutureTask.java:106)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.eclipse.scout.rt.platform.job.internal.JobFutureTask.run(JobFutureTask.java:175)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
	at org.eclipse.scout.rt.platform.job.internal.NamedThreadFactory$1.run(NamedThreadFactory.java:63)
 How do I get around this problem?
 
 Thanks,
 
 JD
 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | 
 
 
 Current Time: Fri Oct 31 05:19:29 EDT 2025 
 Powered by FUDForum . Page generated in 0.05408 seconds |