<?xml version="1.0" encoding="UTF-8"?>
<window apply="demo.charts3d.Column3DComposer">
<charts id="chart" type="column" title="Chart rotation demo"
subtitle="Test options by dragging the sliders below" />
<grid style="margin:50px; margin-top:20px" width="350px">
<columns>
<column align="center" hflex="7"></column>
<column hflex="15"></column>
<column hflex="3"></column>
</columns>
<rows>
<row>
<label>Alpha Angle</label>
<slider id="sliderA" minpos="0" maxpos="45" step="1" />
<label id="valA">15</label>
</row>
<row>
<label>Beta Angle </label>
<slider id="sliderB" minpos="0" maxpos="45" step="1" />
<label id="valB">15</label>
</row>
</rows>
</grid>
</window>
package demo.charts3d;
import org.zkoss.chart.Charts;
import org.zkoss.chart.options3D.Options3D;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Label;
import org.zkoss.zul.Slider;
import org.zkoss.zul.Window;
public class Column3DComposer extends SelectorComposer<Window> {
@Wire
Charts chart;
@Wire
Slider sliderA;
@Wire
Slider sliderB;
@Wire
Label valA;
@Wire
Label valB;
private boolean _animation = true;
public void doAfterCompose(Window comp) throws Exception {
super.doAfterCompose(comp);
chart.setMargin(75);
Options3D opt3d = chart.getChart().getOptions3D();
opt3d.setEnabled(true);
opt3d.setAlpha(15);
opt3d.setBeta(15);
opt3d.setDepth(50);
opt3d.setViewDistance(25);
chart.setAnimation(true);
chart.getPlotOptions().getColumn().setDepth(25);
chart.getSeries(0).setData(
new Double[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6,
148.5, 216.4, 194.1, 95.6, 54.4 });
initSlider();
}
public void initSlider() {
sliderA.setCurpos(15);
sliderB.setCurpos(15);
}
@Listen("onScroll = slider#sliderA")
public void updateValueA() {
if (_animation == true) {
chart.getSeries(0).setAnimation(false);
_animation = false;
}
int curPosA = sliderA.getCurpos();
chart.getChart().getOptions3D().setAlpha(curPosA);
valA.setValue(new Integer(curPosA).toString());
}
@Listen("onScroll = slider#sliderB")
public void updateValueB() {
if (_animation == true) {
chart.getSeries(0).setAnimation(false);
_animation = false;
}
int curPosB = sliderB.getCurpos();
chart.getChart().getOptions3D().setBeta(curPosB);
valB.setValue(new Integer(curPosB).toString());
}
}