Jump to content
Changes to the Jaspersoft community edition download ×

Jaspersoft Studio - Plotting Percentile for a MongoDB Field


deepakgup

Recommended Posts

Hi Experts

I am new to Jaspersoft so kindly excuse me incase I ask very fundamental question.

Jaspersoft Version: 6.4

MongoDb: 3.4

Objective: I have stored some timeseries data in MongoDB. My target is to plot this data in a line graph. Further, for one of the "columns" I will also like to plot another line which essentially provides the 95% percentile trajectory.


Methodology Planned:
Create a Scriptlet (Custom Java Class) that will collect all the values in the source Column/field and will provide a percentile output.

Done so far:
1. I am successfull in using the Jasper studio to import and plot my timeseries data on a XY Graph.
2. Created following class be extending JRDefaultScriptlet:

package net.sf.jasperreports.engine.mymethods;import net.sf.jasperreports.engine.JRDefaultScriptlet;import net.sf.jasperreports.engine.JRScriptletException;import org.apache.commons.math3.stat.descriptive.rank.*;public class class1 extends JRDefaultScriptlet{        public static double[] u_list = new double [1000];    public static int counter = 0;                                public double percentile(double u_value, double u_percentile) throws JRScriptletException {            u_list[counter] = u_value;            org.apache.commons.math3.stat.descriptive.rank.Percentile test = new org.apache.commons.math3.stat.descriptive.rank.Percentile();            double x = test.evaluate(u_list, u_percentile);            return x;        }}[/code]


3. Mapped a new Y Series in the graph with the following paramteres:
 

$P{Scriptlet_2_SCRIPTLET}.percentile( (double) $F{Pre_Policy_BitRate}, (double) 95 )[/code]

 

Problem:
What I realised at the end of the excersize is that Jaspersoft re-instantiates the scriptlet class for every row of data. This really means that I never have more than one real value in my array. I was hoping that hte scriptlet would only create a single instance per report so that I can generate an array of numbers to feed my percentile method. Is this possible to acheive?

Regards
Deepak

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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