I want to add date in HH:MM:SS format to the x-开发者_JAVA技巧axis of XY-Line chart. I am using following code to do it:
<xValueExpression>![CDATA[new SimpleDateFormat("HH:mm:ss").format($F{time})]]</xValueExpression>
But it is giving error as can not convert from string to number. Because XY-Line chart takes number on X and Y axis.
So how to achieve this? Or there is any other way to achieve this?
I have found that it was easier to create charts from your java code (using JFreechart in my case), write the chart in an image and pass it to Jasper. In my case, I always use custom datasources and the charts are inputstream parameters. When you build the charts yourself you have full access to the JFreechart API.
I konw I'm too late but maybe somebody else would need this. You should use Line Chart
instead of XY-Line Chart
and than, you use DateFormat.getTimeInstance().format(new Date($F{time}))
. It worked by me.
精彩评论