Casting from String to number

0

Hey all,

i get some problems when i try to create a xylinechart in jasperreports.

Is it better if i create timeseries charts or xylinecharts.

I want to explain my behaviour:

I connect to a database from i build reports. at last i need to create charts for this dynamic reports.

All reports depend on time, so i try to use x-axis as time axis and y-axis should be the value axis.

The problem is that my time in database is as string so i cannot create these charts.

can anybody help me how to realise these reports?

Thanks

 

Code:
<field name="DESCRIPTION" class="java.lang.String" />
<field name="HALFHOUR" class="java.lang.String" />
<field name="VALUEA" class="java.lang.Double" />
----
<xyLineChart>
        <chart evaluationTime="Report">
          <reportElement x="0" y="0" width="555" height="350" />
        </chart>
        <xyDataset>
          <dataset incrementType="None" />
          <xySeries>
            <seriesExpression><![CDATA[$F{DESCRIPTION}]]></seriesExpression>
            <xValueExpression><![CDATA[$F{HALFHOUR}]]></xValueExpression>
            <yValueExpression><![CDATA[$F{VALUEA}]]></yValueExpression>
          </xySeries>
        </xyDataset>
        <linePlot>
          <plot />
        </linePlot>
      </xyLineChart></td></tr></tbody></table>
mkeym's picture
12
Joined: Jun 14 2010 - 7:54am
Last seen: 4 years 6 months ago

4 Answers:

0
http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html Use a variable. Assign the variable to something like: (new java.text.SimpleDateFormat( "HH:mm:ss" )).parse( $F{HALFHOUR} ) You should then be able to use the variable in the time series. If not, you might have to convert it to a java.util.Date or equivalent.
thangalin's picture
240
Joined: Apr 21 2008 - 4:34am
Last seen: 6 years 8 months ago
0
Thank you for help, but when i try this i get this message: Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.jfree.chart.ChartFactory.setChartTheme(Lorg/jfree/chart/ChartTheme;)
mkeym's picture
12
Joined: Jun 14 2010 - 7:54am
Last seen: 4 years 6 months ago
0
Code:
<timeSeriesChart>
				<chart>
					<reportElement x="157" y="107" width="250" height="222"/>
					<chartTitle/>
					<chartSubtitle/>
					<chartLegend/>
				</chart>
				<timeSeriesDataset timePeriod="Milisecond">
					<timeSeries>
						<seriesExpression><![CDATA[$F{DESCRIPTION}]]></seriesExpression>
						<timePeriodExpression><![CDATA[(new java.text.SimpleDateFormat("HH:mm")).parse($F{HALFHOUR})]]></timePeriodExpression>
						<valueExpression><![CDATA[$F{VALUEA}]]></valueExpression>
					</timeSeries>
				</timeSeriesDataset>
				<timeSeriesPlot>
					<plot/>
					<timeAxisFormat>
						<axisFormat>
							<labelFont/>
							<tickLabelFont/>
						</axisFormat>
					</timeAxisFormat>
					<valueAxisFormat>
						<axisFormat>
							<labelFont/>
							<tickLabelFont/>
						</axisFormat>
					</valueAxisFormat>
				</timeSeriesPlot>
			</timeSeriesChart>


Post Edited by mkeym at 06/26/2010 12:50
mkeym's picture
12
Joined: Jun 14 2010 - 7:54am
Last seen: 4 years 6 months ago
0

...



Post Edited by mkeym at 06/26/2010 16:03
mkeym's picture
12
Joined: Jun 14 2010 - 7:54am
Last seen: 4 years 6 months ago
Feedback