Chart from SQLContainer

Is it possible to use a SQLContainer as a ContainerDataSeries source?

MySQL is:-
Select name x, count(*) y
from table
group by name;

When i run my app, it returns:-
ContainerDataSeries’ container should always have a property for ‘y’ values

Any examples?

Have you checked this

https://vaadin.com/docs/-/part/charts/java-api/charts-data.html#charts.data.containerseries

and namely: series.setYPropertyId(…) for setting the property used for ‘y’ values.

Thanks for the response.

Yes i did - for which i get the error (ContainerDataSeries’ container should always have a property for ‘y’ values)

I tried using an alias for the colums (x, y) and also tried the setYPropertyId as it states.

Do you have an example of how a simple DB Query can populate a chart?

Have you tried the same thing using BeanItemContainer instead of SQLContainer? Technically speaking the documentation does not state that there should be limitations regarding Container type. If you get it working with BeanItemContainer, that it is a hint that there could be a bug somewhere.

This is a wild guess, but your issue could be related to this one: https://github.com/vaadin/framework/issues/7288

I don’t think its a bug. I just need a simple example of a SQLContainer being used to populate a chart. Can’t find a good example anywhere!

Does anyone have a simple example of a SQLContainer (with basic select x, y from table) to ContainerDataSeries?