flhs Posted July 24, 2007 Share Posted July 24, 2007 Hi AllI'm using ireport to design a bar chart, I want to show the value above each bar, but the value of the tallest bar only can be displayed half, and if the value reach four digits, they will cover each other. I didn't find any parameter about it, who can help me?The attachment is the issue pic. Regards!Samuel size=345]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/ireport1.GIF Link to comment Share on other sites More sharing options...
flhs Posted July 24, 2007 Author Share Posted July 24, 2007 The second pic: size=340]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/ireport2.GIF Link to comment Share on other sites More sharing options...
flhs Posted August 2, 2007 Author Share Posted August 2, 2007 Can anybody help me? Link to comment Share on other sites More sharing options...
mmflynn Posted August 2, 2007 Share Posted August 2, 2007 I can set you in the right direction, but unfortunately I do not have a specific solution for you. JFreeChart is the chart engine used by JasperReports. iReport does not expose all the capabilities of JFreeChart yet, so you need to write a chart customizer class to get the functionality you need, specifically rendering the value labels differently.These should get you started:Search this forum for JRChartCustomizer--this is what you need to implement in iReportI'm not positive, but I think this link will get you the methods you need: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/category/CategoryItemRenderer.htmlsetSeriesItemLabelFont(int, Font) and setBaseItemLabelFont(Font).And just as an example, this is what I did to make the pie chart labels smaller (credits--I used this forum to get started--thanks to jmaher plus JasperSoft support).Code:Getting it to compile was my big problem--I'm not a Java programmer, and it took me a while to figure out my classpath (yours will be different, but the point is that you need to include the paths to the jars that are included in the class, in my example, jasperreports, jfreechart including jcommon. ):[root@mycentos root]# CLASSPATH=$CLASSPATH:/opt/tomcat/webapps/jasperserver/WEB-INF/lib/jfreechart-1.0.1.jar:/opt/tomcat/webapps/jasperserver/WEB-INF/lib/jasperreports-ver:/opt/tomcat/webapps/jasperserver/WEB-INF/lib/jcommon-1.0.0.jar;.;export CLASSPATHI've pretty much exhausted what I can tell you. Good luck!!!Mary Link to comment Share on other sites More sharing options...
svenn Posted August 3, 2007 Share Posted August 3, 2007 I did something simular today. Here's my codeCode:Post edited by: svenn, at: 2007/08/02 20:00 Link to comment Share on other sites More sharing options...
flhs Posted August 3, 2007 Author Share Posted August 3, 2007 org.jfree.chart.renderer.category.BarRenderer.setBaseItemLabelFont(new Font("Arial",Font.BOLD,8)) thanks your reply ,but i find the method not exist. could you please tell me how to use this method. thanks very much Link to comment Share on other sites More sharing options...
svenn Posted August 3, 2007 Share Posted August 3, 2007 You can not refer to the method setBaseItemLabelFont directly. You need to get the render object using BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); You can then apply the setBaseItemLabelFont method to the render object. To get a better understanding you should look at the Jasper Reports API and JFreeChart API. Jasper Reports API http://jasperreports.sourceforge.net/api/index.html JFreeChart APIhttp://www.jfree.org/jfreechart/api/javadoc/index.html Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now