-
FEATURED COMPONENTS
First time here? Check out the FAQ!
am trying to use zkchart for my next project, i understand how i to choose the model of chart of type etc
but every example take data from hardcode line like this:
{
public class LineBasicData {private static final CategoryModel model;
static
{ model = new DefaultCategoryModel();
model.setValue("Tokyo", "Jan", 7);
model.setValue("Tokyo", "Feb", 6);
model.setValue("Tokyo", "Mar", 9);
model.setValue("Tokyo", "Apr", 14);
model.setValue("Tokyo", "May", 18);
model.setValue("Tokyo", "Jun", 21);
model.setValue("Tokyo", "Jul", 25);
model.setValue("Tokyo", "Aug", 26);
model.setValue("Tokyo", "Sep", 23);
model.setValue("Tokyo", "Oct", 18);
model.setValue("Tokyo", "Nov", 13);
model.setValue("Tokyo", "Dec", 9);
}
public static CategoryModel getCategoryModel() {
return model;
}
}}
any idea how can i fill that line from my database? is arraylist method is doable in here? sorry, am so newb in java
Since zkchart is also a component of ZK framework, it's better you should learn some basic of ZK via https://www.zkoss.org/documentation#Getting_Started including MVC, and event listening.
Basically, what you need to do are in MVC patter:
1. apply a controller(composer) in a zul
2. query data from a database and put it in a model in doAfterCompose()
3. assign the model object to Charts
public class MyComposer extends SelectorComposer<Component> {
@Wire
Charts chart;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
initData();
}
private void initData() {
//query data from a database
//set data to a model object
//chart.setModel(model)
}
}
ZK is a UI framework, so that you have to integrate other frameworks or library by yourselves. You can also check architecture of this example project: https://github.com/zkoss/zkessentials/tree/zk-jpa
If you still have problems, please post your code here.
Asked: 2021-11-25 22:18:24 +0800
Seen: 4 times
Last updated: Nov 29 '21