prestinman Posted June 11, 2010 Share Posted June 11, 2010 Hello.I am creating a JasperReport with an XYBlock chart. Everything shows up fine except the gridlines on the chart. They only slightly appear if I set the foregroundAlpha(0.25f)...which makes me think that the gridlines are getting painted over. Does anyone know how to show the gridlines or move them to the front?I am using JFreeChart 1.0.12 and jasperReports 3.7.2 Any suggestion is appreciated. Thanks!Code: XYZDataset dataset = createDataset(sched); NumberAxis xAxis = new NumberAxis(""); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setTickUnit(new NumberTickUnit(12.0)); xAxis.setNumberFormatOverride(new DayGraphNumberFormat()); NumberAxis yAxis = new NumberAxis(""); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setTickUnit(new NumberTickUnit(1.0)); yAxis.setNumberFormatOverride(new WeekDayNumberFormat()); yAxis.setAutoRangeIncludesZero(false); yAxis.setInverted(true); XYBlockRenderer renderer = new XYBlockRenderer(); LookupPaintScale paintScale = new LookupPaintScale(0.0,1.0,Color.black); paintScale.add(0.0,new Color(216,220,166)); paintScale.add(1.0,Color.green); renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset,yAxis,xAxis,renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setForegroundAlpha(0.25f); plot.setDomainGridlinePaint(Color.BLUE); plot.setDomainGridlinesVisible(true); plot.setDomainGridlineStroke(new BasicStroke(1.0f)); plot.setRangeGridlinePaint(Color.BLUE); plot.setRangeGridlinesVisible(true); plot.setRangeMinorGridlinesVisible(false); plot.setRangeGridlineStroke(new BasicStroke(1.0f)); plot.setAxisOffset(new RectangleInsets(5,5,5,5)); JFreeChart chart = new JFreeChart("",plot); chart.setBackgroundPaint(new Color(253,250,247)); chart.removeLegend(); Link to comment Share on other sites More sharing options...
lucianc Posted June 24, 2010 Share Posted June 24, 2010 Does it work if you render the chart on a Swing canvas? If not, my suggestion is to ask about this case on the JFreeChart forum as the problem would be in that code.Regards,Lucian 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