📄 simplechartengine.java
字号:
}
return ChartFactory.createStackedBarChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
CategoryModelToCategoryDataset((CategoryModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** stackedbar3d chart */
private class StackedBar3d extends StackedBar {
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof CategoryModel)) {
throw new UiException("model must be a org.zkoss.zul.CategoryModel");
}
return ChartFactory.createStackedBarChart3D(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
CategoryModelToCategoryDataset((CategoryModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** stackedarea chart */
//note: cutting area coordinate is not correct.
private class StackedArea extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof CategoryItemEntity) {
area.setAttribute("entity", "DATA");
decodeCategoryInfo(area, (CategoryItemEntity)info);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity) info);
} else if (info instanceof TickLabelEntity) {
area.setAttribute("entity", "CATEGORY");
Integer seq = (Integer)chart.getAttribute("TICK_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("TICK_SEQ", seq);
decodeTickLabelInfo(area, (TickLabelEntity) info, chart);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (model instanceof CategoryModel) {
return ChartFactory.createStackedAreaChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
CategoryModelToCategoryDataset((CategoryModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
} else if (model instanceof XYModel) {
return ChartFactory.createStackedXYAreaChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
XYModelToTableXYDataset((XYModel) model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
} else {
throw new UiException("model must be a org.zkoss.zul.CategoryModel or a org.zkoss.zul.XYModel");
}
}
}
/** waterfall chart */
//note: cuttin area corrdinate is not correct.
private class Waterfall extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof CategoryItemEntity) {
area.setAttribute("entity", "DATA");
decodeCategoryInfo(area, (CategoryItemEntity)info);
} else if (info instanceof TickLabelEntity) {
area.setAttribute("entity", "CATEGORY");
Integer seq = (Integer)chart.getAttribute("TICK_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("TICK_SEQ", seq);
decodeTickLabelInfo(area, (TickLabelEntity) info, chart);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof CategoryModel)) {
throw new UiException("model must be a org.zkoss.zul.CategoryModel");
}
return ChartFactory.createWaterfallChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
CategoryModelToCategoryDataset((CategoryModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** polar chart */
private class Polar extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof XYModel)) {
throw new UiException("model must be a org.zkoss.zul.XYModel");
}
return ChartFactory.createPolarChart(
chart.getTitle(),
XYModelToXYDataset((XYModel)model),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** scatter chart */
private class Scatter extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity)info);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof XYModel)) {
throw new UiException("model must be a org.zkoss.zul.XYModel");
}
return ChartFactory.createScatterPlot(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
XYModelToXYDataset((XYModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** timeseries chart */
private class TimeSeries extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity) info);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof XYModel)) {
throw new UiException("model must be a org.zkoss.zul.XYModel");
}
return ChartFactory.createTimeSeriesChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
XYModelToTimeDataset((XYModel)model, chart),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** steparea chart */
private class StepArea extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity)info);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof XYModel)) {
throw new UiException("model must be a org.zkoss.zul.XYModel");
}
return ChartFactory.createXYStepAreaChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
XYModelToXYDataset((XYModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** step chart */
private class Step extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity)info);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof XYModel)) {
throw new UiException("model must be a org.zkoss.zul.XYModel");
}
return ChartFactory.createXYStepChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
XYModelToXYDataset((XYModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** histogram */
private class Histogram extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity)info);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof XYModel)) {
throw new UiException("model must be a org.zkoss.zul.XYModel");
}
return ChartFactory.createHistogram(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
(IntervalXYDataset)XYModelToXYDataset((XYModel)model),
getOrientation(chart.getOrient()),
chart.isShowLegend(),
chart.isShowTooltiptext(), true);
}
}
/** candlestick */
private class Candlestick extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity)info);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof HiLoModel)) {
throw new UiException("model must be a org.zkoss.zul.HiLoModel");
}
return ChartFactory.createCandlestickChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
HiLoModelToOHLCDataset((HiLoModel)model),
chart.isShowLegend());
}
}
/** highlow */
private class Highlow extends ChartImpl {
public void render(Chart chart, Area area, ChartEntity info) {
if (info instanceof LegendItemEntity) {
area.setAttribute("entity", "LEGEND");
Integer seq = (Integer)chart.getAttribute("LEGEND_SEQ");
seq = seq == null ? new Integer(0) : new Integer(seq.intValue()+1);
chart.setAttribute("LEGEND_SEQ", seq);
decodeLegendInfo(area, (LegendItemEntity)info, chart);
} else if (info instanceof XYItemEntity) {
area.setAttribute("entity", "DATA");
decodeXYInfo(area, (XYItemEntity)info);
} else {
area.setAttribute("entity", "TITLE");
if (chart.isShowTooltiptext()) {
area.setTooltiptext(chart.getTitle());
}
}
}
public JFreeChart createChart(Chart chart) {
ChartModel model = (ChartModel) chart.getModel();
if (!(model instanceof HiLoModel)) {
throw new UiException("model must be a org.zkoss.zul.HiLoModel");
}
return ChartFactory.createHighLowChart(
chart.getTitle(),
chart.getXAxis(),
chart.getYAxis(),
HiLoModelToOHLCDataset((HiLoModel)model),
chart.isShowLegend());
}
}
private PlotOrientation getOrientation(String orient) {
return "horizontal".equals(orient) ?
PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -