Jasper report line chart with two date type axis -
hello !
i need create report attachment shows jasper reports.
i've tried line chart. result : line chart expects 2 number type field axises.
i've tried time series. result : time series expect 1 number , 1 date type field axises.
i have use dates, need chart type can handle dates.
any suggestion how can solve ? i've tried google @ least 10 hour. i'm desperated.
thanks !
i think i've solved problem. i've written customizer class :
package com.test; import java.text.dateformat; import java.text.simpledateformat; import net.sf.jasperreports.engine.jrchart; import net.sf.jasperreports.engine.jrchartcustomizer; import org.jfree.chart.jfreechart; import org.jfree.chart.axis.dateaxis; import org.jfree.chart.axis.datetickunit; import org.jfree.chart.plot.xyplot; public class trendcustomizer implements jrchartcustomizer { public void customize(jfreechart chart, jrchart jasperchart) { dateaxis xaxis = new dateaxis(); dateaxis yaxis = new dateaxis(); datetickunit unit = null; unit = new datetickunit(datetickunit.month, 6); dateformat chartformatter = new simpledateformat("yyyy.mm.dd"); xaxis.setdateformatoverride(chartformatter); xaxis.settickunit(unit); yaxis.setdateformatoverride(chartformatter); yaxis.settickunit(unit); ((xyplot)chart.getplot()).setdomainaxis(xaxis); ((xyplot)chart.getplot()).setrangeaxis(yaxis); } }
Comments
Post a Comment