Hi,
Is it possible to use different colors on column charts?
I’m trying to change the color of the expenditure column such that if the value is above the budget value, the column turns to red, but if it remains under the expenditure, it stays green.
My jpql query
select b.name, b.budget, b.parentId, b.expense from ppm$Projects b order by b.name
java.lang.ClassCastException: com.haulmont.cuba.core.entity.KeyValueEntity cannot be cast to com.company.ppm.entity.Projects
at com.company.ppm.web.dashboards.Projectdashboard.init(Projectdashboard.java:51)
at com.haulmont.cuba.gui.WindowManager.init(WindowManager.java:1247)
at com.haulmont.cuba.gui.WindowManager.initWrapperFrame(WindowManager.java:1236)
at com.haulmont.cuba.gui.WindowManager.createWindow(WindowManager.java:581)
at com.haulmont.cuba.gui.WindowManager.openWindow(WindowManager.java:750)
at com.haulmont.cuba.web.WebWindowManager.openWindow(WebWindowManager.java:158)
at com.haulmont.cuba.gui.config.MenuCommand$ScreenCommand.run(MenuCommand.java:181)
at com.haulmont.cuba.gui.config.MenuCommand.execute(MenuCommand.java:76)
at com.haulmont.cuba.web.sys.MenuBuilder.lambda$createMenuCommandExecutor$0(MenuBuilder.java:197)
at com.haulmont.cuba.web.gui.components.mainwindow.WebAppMenu$MenuItemImpl.lambda$setCommand$2434f46b$1(WebAppMenu.java:351)
Probably your budgetDs is a ValueCollectionDatasource containing KeyValueEntity, but you inject it as a CollectionDatasource containing Projects.
Try to change the field declaration to CollectionDatasource<KeyValueEntity, Object> and use getValue() method to get information from KeyValueEntity fields:
for (KeyValueEntity item : budgetDs.getItems()) {
Map<String, Object> dataItem = new HashMap<>();
dataItem.put("expenditure", item.getValue("expenditure"));
// ...
}