package demo.area;
import org.zkoss.chart.Charts;
import org.zkoss.chart.Legend;
import org.zkoss.chart.YAxis;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Window;
public class AreaInvertedComposer extends SelectorComposer<Window> {
@Wire
Charts chart;
public void doAfterCompose(Window comp) throws Exception {
super.doAfterCompose(comp);
chart.setModel(AreaInvertedData.getCategoryModel());
chart.getSubtitle().setStyle("position: 'absolute'; right: '0px'; bottom: '10px'");
Legend legend = chart.getLegend();
legend.setLayout("vertical");
legend.setAlign("right");
legend.setVerticalAlign("top");
legend.setX(-150);
legend.setY(100);
legend.setFloating(true);
legend.setBorderWidth(1);
YAxis yAxis = chart.getYAxis();
yAxis.setTitle("Number of units");
yAxis.getLabels().setFormat("{value}");
yAxis.setMin(0);
chart.getPlotOptions().getArea().setFillOpacity(0.5);
}
}
package demo.area;
import org.zkoss.chart.model.CategoryModel;
import org.zkoss.chart.model.DefaultCategoryModel;
public class AreaInvertedData {
private final static CategoryModel model;
static {
model = new DefaultCategoryModel();
model.setValue("John", "Monday", new Integer(3));
model.setValue("John", "Tuesday", new Integer(4));
model.setValue("John", "Wednesday", new Integer(3));
model.setValue("John", "Thursday", new Integer(5));
model.setValue("John", "Friday", new Integer(4));
model.setValue("John", "Saturday", new Integer(10));
model.setValue("John", "Sunday", new Integer(12));
model.setValue("Jane", "Monday", new Integer(1));
model.setValue("Jane", "Tuesday", new Integer(3));
model.setValue("Jane", "Wednesday", new Integer(4));
model.setValue("Jane", "Thursday", new Integer(3));
model.setValue("Jane", "Friday", new Integer(3));
model.setValue("Jane", "Saturday", new Integer(5));
model.setValue("Jane", "Sunday", new Integer(4));
}
public static CategoryModel getCategoryModel() {
return model;
}
}