1.主要实现思想:
利用ChartPostProcessor接口和<cewolf:chartpostprocessor>标签实现
2.JSP代码如下:
<%@ page import="de.laures.cewolf.ChartPostProcessor"%>
<%@ page import="org.jfree.chart.plot.CategoryPlot"%>
<%@ page import="org.jfree.chart.axis.CategoryLabelPositions"%>
<%@ page import="org.jfree.chart.JFreeChart"%>
<%@ page import="de.laures.cewolf.ChartPostProcessor"%>
<%@ page import="org.jfree.chart.plot.CategoryPlot"%>
<%@ page import="org.jfree.chart.axis.CategoryLabelPositions"%>
<%@ page import="org.jfree.chart.JFreeChart"%>
<%
ChartPostProcessor labelPosition = new ChartPostProcessor() {
public void processChart(Object chart, Map params) {
CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
}
};
pageContext.setAttribute("labelPosition", labelPosition);
%>
ChartPostProcessor labelPosition = new ChartPostProcessor() {
public void processChart(Object chart, Map params) {
CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
}
};
pageContext.setAttribute("labelPosition", labelPosition);
%>
<cewolf:chart id="pageChart2" title="日期柱状图" type="verticalBar" xaxislabel="时间" yaxislabel="数量">
<cewolf:data>
<cewolf:producer id="data1" />
</cewolf:data>
<cewolf:data>
<cewolf:producer id="data1" />
</cewolf:data>
<cewolf:chartpostprocessor id="labelPosition"></cewolf:chartpostprocessor> <!-- 加入此标签,以使X轴上的lable倾斜45度-->
</cewolf:chart>
<cewolf:img chartid="pageChart2" renderer="/adChart" width="500" height="500"/>
</cewolf:chart>
<cewolf:img chartid="pageChart2" renderer="/adChart" width="500" height="500"/>