Jump to content
We've recently updated our Privacy Statement, available here ×

csagar

Members
  • Posts

    25
  • Joined

  • Last visited

csagar's Achievements

Explorer

Explorer (4/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. problem solved..... following two lines in the customizer solved our problem... ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); BarRenderer.setDefaultBarPainter((BarPainter)new StandardBarPainter()); Hope it helps someone who faces the same problem :) Happy coding,Happy sharing !! Sagar
  2. hello friends, how to set the distance between Y [range] axis and first bar on X axis ? The distance goes on increasing as the no of bars increases. Please see attached PDF file .I have given customizer code being used in code section. In customizer I'm using BarRenderer- renderer.setItemMargin(0.0); but it doesn't seem to help. [May be I'm taking a different meaning of it :) ] or How to do it using iReport 3.0.0 ? Thanks, Sagar Code:import java.awt.Color;import java.awt.GradientPaint;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.List;import net.sf.jasperreports.engine.JRAbstractChartCustomizer;import net.sf.jasperreports.engine.JRChart;import org.apache.log4j.Logger;import org.apache.log4j.xml.DOMConfigurator;import org.jfree.chart.JFreeChart;import org.jfree.chart.axis.Axis;import org.jfree.chart.axis.CategoryAxis;import org.jfree.chart.axis.CategoryTick;import org.jfree.chart.axis.DateAxis;import org.jfree.chart.axis.DateTickUnit;import org.jfree.chart.axis.TickUnits;import org.jfree.chart.plot.CategoryPlot;import org.jfree.chart.plot.Marker;import org.jfree.chart.plot.ValueMarker;import org.jfree.chart.renderer.category.BarRenderer;import org.jfree.data.Range;import org.jfree.ui.RectangleAnchor;import org.jfree.ui.TextAnchor;public class BarSingleChartCustomizer extends JRAbstractChartCustomizer { //private final String logFilePath ="F:\\NSN\\src\\EclipseWorkspace\\CustmizerDemo\\src\\properties\\Logger.xml"; private int no_of_colmns; private int chartWidth; private double barWidth; double maxVal; double minVal; double belowMinVal; double aboveMaxVal; double isAllZero;// to see if all the values are zero in that case change aboveMaxVal=5,beloMinVal=0; private Range curRange; Marker target ; public void customize(JFreeChart chart, JRChart current_chart){ //DOMConfigurator.configure(logFilePath); //Logger logger = Logger.getLogger(BarGroupChartCustomizer.class); //GradientPaint gpStyle = new GradientPaint( 0.0f, 0.0f,Color.getHSBColor(146,4,55), 0.0f, 0.0f, new Color(0, 0, 64) ); //logger.info("~~~~~~~~~~~~~~~~~~~~~~ see below this ~~~~~~~~~~~~~~~~~~~~"); //System.out.println("~~~~~~~~~~~~~~~~~~~~~~ see below this ~~~~~~~~~~~~~~~~~~~~"); //################################################################################# //get the plot for bar graph CategoryPlot barplot = chart.getCategoryPlot(); //get the renderer for current plot BarRenderer renderer = (BarRenderer) barplot.getRenderer(); //################################################################################# //get range of the axis curRange=renderer.findRangeBounds(barplot.getDataset()); //set the range of values barplot.getRangeAxis().setRange(curRange.getLowerBound(), (curRange.getUpperBound()+(curRange.getCentralValue()/2))); // get the number of columns List tempLst=new ArrayList(); tempLst=barplot.getCategories(); no_of_colmns=tempLst.size(); //logger.info("No_of_colmns------------>"+no_of_colmns+"**************"); // System.out.println("No_of_colmns------------>"+no_of_colmns+"**************"); //set the paint for the series for (int i=0;i<no_of_colmns;i++) { renderer.setSeriesPaint(i,new Color(144,4,55)); } //set no shadow required //renderer.setShadowVisible(false); //get max,min value for Y axis // ******************************* IMP ********************************* //to get this value , when the variable is defined its evaluation time should be defined to Report. Otherwise it returns no value. This has to be done at maxVal=(Double)this.getVariableValue("maxVal"); minVal=(Double)this.getVariableValue("minVal"); System.out.println("minVal====="+minVal); System.out.println("maxVal====="+maxVal); if(new Double(minVal)==null || minVal==0) { belowMinVal=0; } else{ belowMinVal=minVal*new Double(0.8); } aboveMaxVal=maxVal*new Double(1.1); //set it false if range has to be decided at runtime barplot.getRangeAxis().setAutoRange(false); //check if 0<lower bound<=10 so that -ve value is not passed to the setRange method if(minVal>0 && ((belowMinVal)>=10)) { System.out.println("min"+belowMinVal); System.out.println("max"+aboveMaxVal); barplot.getRangeAxis().setRange(belowMinVal,aboveMaxVal); } else if(minVal>0 && minVal<10) { System.out.println("min"+belowMinVal); System.out.println("max"+aboveMaxVal); barplot.getRangeAxis().setRange(belowMinVal,aboveMaxVal); } else //if minVal=0 { System.out.println("min"+belowMinVal); System.out.println("max"+aboveMaxVal); barplot.getRangeAxis().setRange(0,aboveMaxVal); } //or if all the values are zero, set aboveMaxVal=5 and belowMinVal=0 isAllZero=(Double)this.getVariableValue("isAllZero"); if(isAllZero==0.0 && new Double(isAllZero)!=null) { barplot.getRangeAxis().setRange(0,5); } //set the width of the chrt dynamically //imp : this is calculated by actually observing chart appearnce for different no of values. So don't change renderer.setItemMargin(0.0); if(no_of_colmns>=5) { chartWidth=no_of_colmns*80; current_chart.setWidth(chartWidth); } else { chartWidth=325; current_chart.setWidth(chartWidth); } System.out.println("Chart Width = "+chartWidth); //set bar width barWidth=(double)40/(chartWidth+(chartWidth*0.33)); System.out.println("%Width of a bar = "+barWidth); renderer.setMaximumBarWidth(barWidth); //set distance between y axis and first bar on x-axis renderer.setItemMargin(0.0); } }
  3. Hi Lucian , Thanks for the reply. I will try this now. Sagar
  4. i have reolved the issue :) by applying some crude logic.... not by changing the order of display in cross tab so question still remains--- how to disable/change order of data in cross tab ?
  5. or you can say I want 'date field ' in cross tab to appear in the same way [and in the same order ] as it appears on the bar chart's x axis
  6. Hi, I need to create a report having both crosstab and bar chart. I fire the query by applying order by clause on a date field - d.inDate . d.inDate- type- date ofMonth- type- string [it is of the form --- Jan2009] my query - select ROUND(avg(ParameterValue),2) as parameterValue, concat(substring(MONTHNAME(d.InDate),1,3),YEAR(d.InDate)) as ofMonth, d.CircleId as circleId, v.CircleName as circleName, d.Area, v.ParameterName as parameterName,d.inDate as inDate from Data_Daily d, CircleParamCat_View v where d.CircleId = $P{circleId} and v.ParameterName = 'Network Quality Index (NQI)' and d.Area = $P{area} and d.InDate between $P{fromDate} and $P{toDate} and d.ParameterId=v.ParameterId and d.CircleId=v.CircleId group by ofMonth order by d.inDate Bar chart- I need to show data on x axis of bar chart in date wise order. I use $F{ofMonth} as Category Expression. Data is shown in the correct order , as you can see it in order in crosstab.PNG [green circle] CrossTab : However when I use the same field $F{ofMonth} the order is changed . Please see order in crosstab.PNG [red circle] So I tried to change the order by using cross tab properties as shown in custom comparator expression.JPG. But that didn't help me out. *** I can't use inDate cross tab as its in a different format. So I'm using I have attached 3 files- 1.order in crosstab.PNG - it shows the actual report that is generated. 2.custom comparator expression.JPG - way I used to change the order of ofMonth in Crosstab 3. jrxml source To make long story short , please help me either to change the order in cross tab or to disable the ordering that is done by default. Thanks, Sagar Code:select ROUND(avg(ParameterValue),2) as parameterValue, concat(substring(MONTHNAME(d.InDate),1,3),YEAR(d.InDate)) as ofMonth, d.CircleId as circleId, v.CircleName as circleName, d.Area, v.ParameterName as parameterName,d.inDate as inDatefrom Data_Daily d, CircleParamCat_View v where d.CircleId = $P{circleId}and v.ParameterName = 'Network Quality Index (NQI)'and d.Area = $P{area}and d.InDate between $P{fromDate} and $P{toDate}and d.ParameterId=v.ParameterIdand d.CircleId=v.CircleIdgroup by ofMonthorder by d.inDate
  7. Hi Lucian. Nice to see your reply. I followed your suggestion. Color quality is improved , but problem of image distortion is still there. Also, I have not applied any gradient to the bars.Still the color of the bars has gradient. Please see the screenshot of the bar rendered . This is being shown in liferay portal. Thanks, Sagar Post Edited by csagar at 06/05/2009 04:07
  8. hey, this what my problem is..... when I export to HTML images get distorted. Please refer to the links below-- http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=53480 and please see the attached image. Or see attached image. If you don't mind, may I know how your solution can help me ? How to use your patch ? Thanks in advance, Sagar
  9. Hi Nicholas, Thanks for your reply. I am using attached jar in my classpath.It has one class called 'chart theme.class'. However, I could not find any chart theme jar . Am I clear? Or were you referring to something else ? I will be thankfull if you could elaborate 'chart theme jar' thing in more detail.... like location of that jar if its within attached jar, specific classes in that jar, defult themes , and other things that you find important to solve this problem. Thanks , Sagar.
  10. Thanks for ur reply. Please visit the link given below- http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=57847 My problem- I have to deploy my application on a web server so I need to export my reports as HTML. When a chart is rendered its rendered as .png image. This image is very much distorted.I referred to your post @- http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=30573 There you have mentioned about using 300 DPI or more for better quality of image. For your referrence I have attached the screenshot of the rendered report. You can see that the lines ,legends are distorted. Also the colors are not looking that good.As mentioned in your post I thought changing the resolution would help me. If you could provide a better solution I will be thankful to you. Thanks , Sagar Post Edited by csagar at 06/03/2009 15:28
  11. hi, I'm facing same problem. I also want to chnge that resolution Maybe through code. But I could not locate this constant. Could you please tell me the name of the class file where you found it out ??Thanks in advance!! csagar
  12. Hi, I have problem regarding quality of images[of bar chart and line charts] being rendered. I'm using iReport 3.0.0. When I genrate the report and export it on simple HTML page it looks like -" simple html.png" But when I deploy my appplication on Liferay portal server it looks like - "on liferay.png" If you notice- simple html.png on liferay.png no graient in colors of bars gradient no shadow shadow of the bars labels on bars less distoted labels on bars more distorted horizontal tick lines --- visible not visible I have set the render option to SVG. I want it to be like "simple html.png". What could be the reason. I have checked that there is no style that that liferay portal is apllying over the report. Also even if it does [no chance], how can an image rendered by jasper engine be modified ?? @Jasper Project Owners- i this following link talks about the same problem... http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=30573 There it has been mentioned that we can set the rendering scale to 300 dpi or so. I tried to search that option in iReport 3.0.0 However I could not find any such option. Is there any api available which can set the dpi scale size of the image being rendered ? If anyone has any idea , please reply as soon as possible. Thanks in advance, Sagar
  13. Hi, I am facing the same problem. The images and values displayed as the labels on bars are very distorted .I need to export the chart in HTML format. I have tried changing the property from 'px' to 'pt' .But it didn't help. I get the same quality of image in both the cases. Also tried by changing the render type from Default to SVG . But all efforts in vain. if you have any success in above mentioned solution please let me know. I need to implement as soon as possible. Thanks in advance.
  14. Friends, I have trying hard to resolve this issue, but no success so far. I generate a report in ireport 3.0.0. One of the dynamic text fields have this property rotation="Left" --- it rotaes the text by 90 degrees so it appears vertical. When I execute my report in iReport's JRViewer Preview I can see the vertical text. But if I select - Build-->HTML Preview , the text appears horizontal. To my surprise , that rotation="Left" tag is not available in the HTML's source. I have attached my html and jrxml files. In jrxml file you can find this tag - rotation="Left" The CircleName1 to CircleName12 should appear in a vertical manner , i.e, rotated by 90 degrees... but as you can see it appears horizontal. What could be the problem ? Thanks in advance . Sagar Post Edited by csagar at 05/05/2009 10:13
  15. It worked man !! I changed the type of CellNameCount to Integer and it worked. That was the problem. It was working with Ireport [with cellNameCount as Long] but was not working with liferay, so it confused me . Apologies for uploading older log file :| Thanks a lot once again !! :)
×
×
  • Create New...