gzsoham Posted April 12, 2010 Share Posted April 12, 2010 I have a line chart in the report. Each point in the chart is marked with a shape (isShowShapes is true). By default Jasper Report assigns different shapes to each set of axis. I want to apply same shape to all of them (colors will be different). How can that be achieved? Link to comment Share on other sites More sharing options...
lucianc Posted April 20, 2010 Share Posted April 20, 2010 You can use a chart customizer for that. It would do something like the following. Consult the JFreeChart APIs for more information on their classes.Regards,LucianCode:XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) ((XYPlot) chart.getPlot()).getRenderer();Shape firstShape = renderer.getSeriesShape(0);renderer.setSeriesShape(1, firstShape);//etc Link to comment Share on other sites More sharing options...
cinglez Posted August 23, 2011 Share Posted August 23, 2011 Hi. Is there a way to customize the size? I mean, my chart creates squares as shapes, but they are too big. How can I make them smaller? I am using this code: public void customize( JFreeChart jFreeChart, JRChart jrChart ) { XYPlot xyPlot = ( XYPlot )jFreeChart.getPlot(); XYSplineRenderer splineRenderer = new XYSplineRenderer(); splineRenderer.setSeriesShapesVisible( 1, false ); splineRenderer.setSeriesLinesVisible( 1, false ); splineRenderer.setSeriesVisibleInLegend( 1, Boolean.FALSE ); splineRenderer.setBaseItemLabelsVisible(true); splineRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); splineRenderer.setSeriesStroke( 0, new BasicStroke( 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f ) ); //splineRenderer.setSeriesPaint(0, new Color(0, 1, 165 )); splineRenderer.setSeriesPaint( 0, new Color( 255, 140, 0 ) ); xyPlot.setDataset( 1, xyPlot.getDataset(0) ); XYItemRenderer defaultRenderer = new XYLineAndShapeRenderer(); defaultRenderer.setSeriesVisible( 0, Boolean.FALSE ); defaultRenderer.setSeriesVisibleInLegend( 0, Boolean.FALSE ); xyPlot.setRenderer( 1, defaultRenderer ); xyPlot.setRenderer( 0, splineRenderer ); }} Thanks in advance Link to comment Share on other sites More sharing options...
szaharia Posted August 24, 2011 Share Posted August 24, 2011 Hi,Try this one:HTH,sanda Code:XYDataset xyDataset = xyPlot.getDataset();if(xyDataset != null){ for(int i = 0; i < xyDataset.getSeriesCount(); i++) { splineRenderer.getSeriesShape(i).getBounds().setSize(your_width, your_height); }} Link to comment Share on other sites More sharing options...
mdrake Posted March 12, 2012 Share Posted March 12, 2012 I had a similar need. I had better luck using renderer.lookupSeriesShape(0), since the Shape returned by renderer.getSeriesShape(0) can be null. 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