Jump to content
JasperReports Library 7.0 is now available ×

Get Incrementer from Chart Customizer


thangalin

Recommended Posts

Hi,

/**
 * Draws a (smooth) Bezier line between consecutive data points on a chart.
 * This is especially useful for Time Series plots.
 */
public class BezierLineCustomizer
  extends JRAbstractChartCustomizer {
 
  public BezierLineCustomizer() {
  }

  /**
   * Initializes the chart customizer.
   * @param chartFiller Ignored.
   * @param chart Contains the
   */
  @Override
  public void init( JRBaseFiller chartFiller, JRFillChart chart ) {
    super.init( chartFiller, chart );

    JRTimeSeriesDataset dataset = (JRTimeSeriesDataset)chart.getDataset();
    dataset.setTimePeriod( org.jfree.data.time.Day.class );

    JRFillVariable trendAverage = chartFiller.getVariable( RunningAverageIncrementer.IREPORT_VARIABLE );
    JRIncrementer incrementer = trendAverage.getIncrementer();
   
    if( incrementer instanceof RunningAverageIncrementer ) {
      ((RunningAverageIncrementer)incrementer).setSetSize( 30 );
    }
  } // ... etc. ...

 The bold line in the code above does not compile.

Is there another way to get the JRFillVariable instance from a subclass of JRAbstractChartCustomizer?

Thanks!

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Another way to get the incrementer:

  private JRIncrementer getIncrementer( JRBaseFiller chartFiller ) {
    JRVariable[] variables = chartFiller.getMainDataset().getVariables();
    JRIncrementer result = null;
   
    for( JRVariable var : variables ) {
      if( var instanceof JRFillVariable ) {
        result = ((JRFillVariable)var).getIncrementer();

        break;
      }
    }
   
    return result;
  }



Post Edited by thangalin at 03/24/2010 19:30
Link to comment
Share on other sites

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