Jump to content
Changes to the Jaspersoft community edition download ×

Bar chart adding label horizontal axis


svenn

Recommended Posts

Is there a way to add a label to the horizontal axis of a bar chart? You can use the "Value access label expression" to add one to the vertical axis but I cannot see the equivalent on the horizontal axis.

 

For example my chart displays “Total distance†on the vertical axis and I want to display “Vehicle name†under all my vehicle points on the horizontal axis.

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

In your Chart Properties - Data you have four items that you can set:

 

 

Series Expression: set to "1" if you only have one data series, otherwise set to a series value (eg. $F{SalesPerson} )

 

 

Category Expression: the base value grouping (eg. $F{Month} ). These values are displayed on the category axis. It's a good thing to also set the "Category Axis Label Font" and "Category Axis Tick Label Font" chart properties. I use values of Arial 10 and Arial 5 respectively.

 

 

Value Expression: the individual values (eg $F{SalesAmount} ). These values are displayed on the value axis. It's a good thing to also set the "Value Axis Label Font" and "Value Axis Tick Label Font" chart properties. I use values of Arial 10 and Arial 5 respectively.

 

 

Label Expression: The text to display at the end of each bar (eg. new java.lang.Integer(new java.lang.Double($F{SalesAmount}.doubleValue()/1000000).intValue()).toString() + "M" will display sales amounts as millions). Labels are not displayed unless the "Show Labels" chart property is set to true.

 

 

Also note that there appears to be an issue with the Category Series dialog box. It doesn't seem to update changes all the time. It's often simpler to edit the xml source.

Link to comment
Share on other sites

i'm looking for the pattern for

the date format inside of the chart.

i want the category expession to be date, but it will show "2007-06-28 00:00:00.0".

that is too long for me, so that's why i want to change the format.

http://www.jfree.org/jfreechart/images/DualAxisDemo1.png

like the "category" on this chart. the best is to be diagonal, so it can show the whole date. i have no idea how to do it...any help?

Link to comment
Share on other sites

Kelly, this should be opened in a new thread. The simple answer is to use simpledateformat:

 

 

new SimpleDateFormat("dd/MM/yyyy").format($F{yourdatefield})

 

 

or preformat the date as a string in your source query like this oracle example:

 

 

select to_char(myDateField,'DD/MM/YYYY') as formattedDate ....

Post edited by: jmurray, at: 2007/07/01 22:07

Link to comment
Share on other sites

Hi,

 

now i have a problem with crosstab. i'm using iReport.

i can make a crosstab no problem, but it only show the result when there is only one record.

 

if there are more than one record, it will show:

Error filling print... Error incrementing crosstab dataset

net.sf.jasperreports.engine.JRRuntimeException: Error incrementing crosstab dataset

at net.sf.jasperreports.engine.fill.JRFillCrosstab$JRFillCrosstabDataset.customIncrement(JRFillCrosstab.java:671)

at net.sf.jasperreports.engine.fill.JRFillElementDataset.increment(JRFillElementDataset.java:169)

at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:152)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:652)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:252)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:117)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:763)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:669)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234)

at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:942)

at java.lang.Thread.run(Unknown Source)

Caused by: net.sf.jasperreports.engine.JRException: Crosstab data has already been processed.

at net.sf.jasperreports.crosstabs.fill.calculation.BucketingService.addData(BucketingService.java:295)

at net.sf.jasperreports.engine.fill.JRFillCrosstab$JRFillCrosstabDataset.customIncrement(JRFillCrosstab.java:667)

... 12 more

Print was not filled. Try using an EmptyDataSource...

 

 

do you why this happened?

thanks a lot.

Post edited by: kelly, at: 2007/07/09 19:06

Link to comment
Share on other sites

Hi,

 

now i have a problem with crosstab. i'm using iReport.

i can make a crosstab no problem, but it only show the result when there is only one record.

 

if there are more than one record, it will show:

"Error filling print... Error incrementing crosstab dataset"

"Caused by: net.sf.jasperreports.engine.JRException: Crosstab data has already been processed. at net.sf.jasperreports.corsstabs.fill.calculation.BucketingService.addData(BucketingService.java:295).....Print was not filled."

 

do you why this happened?

thanks a lot.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...