Jump to content
Changes to the Jaspersoft community edition download ×

Same shape in line chart


gzsoham

Recommended Posts

 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

  • 2 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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,

Lucian

Code:
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) ((XYPlot) chart.getPlot()).getRenderer();Shape firstShape = renderer.getSeriesShape(0);renderer.setSeriesShape(1, firstShape);//etc
Link to comment
Share on other sites

  • 1 year later...

 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

  • 6 months later...

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...