Jump to content
We've recently updated our Privacy Statement, available here ×

timestamp using 15 minute intervals


jmolina

Recommended Posts

hi everyone,

im using ireport 3.0....does anyone know if it's possible to break up a time series graph of a half/whole day into intervals of 15 minutes? the choices i get jump from 1 min tick marks to 1 hour.  Basically, i have a really big table that spans from 9am to 8pm and i want to create a chart that spans that whole time using 15 minute intervals but all i get is 1 minute and 1 hour intervals...the minutes graph is too big and the hours graph is too small to show any detail.

i just want to know if i'm trying to do the impossible with ireport. does it have that feature?

also, can this be done using a timestamp on the category axis in a line graph?

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

jmolina,

 

Let's assume you have 1000 data points between 9:00 and 20:00. There are two separate issues to consider. One is the resolution of the points that get plotted. Separately is the way the axis is formatted. Think of it this way:

 

1) Do you want to see 1000 points in the chart, but have a nicely formatted axis at the bottom? (probably showing hourly intervals)

2) Or alternatively do you want to see 44 points in the chart representing the summary data for each 15 minute interval. The time axis could have exactly 44 points or it could have fewer (as in number 1).

 

Both are reasonable. I tend to prefer the first.

 

Could you attach a CSV or spreadsheet with some sample data? It could help in creating a sample report.

 

Regards,
Matt

Link to comment
Share on other sites

hey,

I attached a file called mockdata.csv so you can see what i mean.  I edited the data of course but basically the field called "flag" is either a 1 or 0.  if its a 1, then i got an error and the "date/time" field marks the time of every "transaction #" on the "slot #"

im trying to calculate the percentage of time elapsed from start time to end time that i didnt recieve an error, so you will see from the data that it will be mostly 100%. 

since the original is so big, i want to do intervals of 15 minutes but really i want to know if i can break up the graph that way.

p.s.

i've been tinkering around with this as we speak, and i keep getting an error that says:

1. Syntax error on token "(", ; expected
                value = (java.lang.Number)(if (((java.lang.Long)field_error_flag.getValue()).equals(0))//$JR_EXPR_ID=10$
                                          ^
2. Syntax error on token ")", delete this token
});//$JR_EXPR_ID=10$
 ^
3. Syntax error on token "(", ; expected
                value = (java.lang.Number)(if (((java.lang.Long)field_error_flag.getOldValue()).equals(0))//$JR_EXPR_ID=10$
                                          ^
4. Syntax error on token ")", delete this token
});//$JR_EXPR_ID=10$
 ^
5. Syntax error on token "(", ; expected
                value = (java.lang.Number)(if (((java.lang.Long)field_error_flag.getValue()).equals(0))//$JR_EXPR_ID=10$
                                          ^
6. Syntax error on token ")", delete this token
});//$JR_EXPR_ID=10$
 ^
6 errors

 

How can i get rid of that???

 

Link to comment
Share on other sites

I'll pack a few different items into this post. First, the expression I gave earlier is a ternary expression. It does a test; if that test is true then it returns the string "some value" but if the test is false then it returns the string "some other value". But it doesn't need to use strings. You could do ( some test ) ? ( new Integer(7) ) : ( new Integer(42) ).  That's more parentheses than you need... but they should make the 3 pieces clearer.

 

Second, a feature that is much under-utilized in the choice of Groovy as the report expression langauge. It's much nicer than the default choice (Java) for most users. Maybe I'll write a web log about that one. If you think to look for it, it's easy to change the report "Language" to "Groovy". But why would you think of looking for it?

 

Finally, there's the original question. How can you get the Time Series chart to show the data points grouped into 15 minute intervals? The main idea here is that you need to ignore the chart and just get the data grouped and calculated. Then return to thinking about the chart to graph the data.

 

This is a pretty common question, and it's something that I've been wanting to write about for a while. So I spent a little longer on this example than I normally would. The attached reports show how to think about the problem. They assume that you've setup a CSV data source based on your sample file. The first report, mockdata1.jrxml, shows all of the data points graphed. That's useful in many cases... but it's not what you're looking for.

 

The second report, mockdata2.jrxml, show the results after creating a group. I called the group 15MinInterval, but I didn't bother to do a good calculation. I just divided milliseconds by 1000000. So I think I got 16.6 minute intervals. Also, I assumed that your data was sorted by the timestamp. It isn't. Therefore the groups don't work quite as they should. I should add sorting. It's important to sort before grouping. This can be done in either the SQL query or in the report. But if you overlook these issues, the chart is now roughly what you're looking for.

 

The final report, mockdata3.jrxml, is slightly cleaned up. All three of the reports use Groovy rather than Java. For anyone trying these samples in the future, don't be surprised by that.

 

Regards,
Matt

Link to comment
Share on other sites

I ran into another issue that is similar but the solution for the last problem doesnt seem to apply here.

 

I have another table with 200 entries and i want to plot a line chart that calculates percent of time that "flag" is 0.  That graph comes out beautifully because it calculates the percentage as it plots each point (progressively)...Now, the problem is that now I want to create another line chart that shows the percentage every 40 entries.

 

In other words, the first chart plotted 200 points, the new chart should only have 5 points.

 

I created a group called interval40 that takes the total amount of entries and divides by 40.

 

for example:    new java.lang.Integer(  ($V{REPORT_COUNT}.intValue()) /40 )

 

I set the reset type to group and reset group to interval40 but when i execute, the chart only plots the last entry. It returns just one plot point...I'm not sure what I'm doing wrong.  Does anyone have any ideas??



Post Edited by jmolina at 06/22/2009 21:40



Post Edited by jmolina at 06/22/2009 21:40
Link to comment
Share on other sites

  • 7 months later...

I also had a related prolem similar to the last comment.

I want to label every 'N' points. The posted solution works well when there is only one series in the chart.
if there are two series, then I get only one point plotted.

My work around was to plot only the 'N' points, but it's not really what is needed.

Is there a way to do this?

Link to comment
Share on other sites

Actually - I found my problem - I had set the chart to use Reset type=Group, rather than Increment Group. Changing that got the series working in groups.

But I realize that this isn't really what I wanted - the grouping causes every Nth point to be plotted - each time there is a group break.
I actually want all points plotted, but have the axis labelled only on group breaks (so it's not too cluttered when there are many points).
This corresponds to Matt's first  suggestion earlier.

I tried setting the x-axis label using a ternay expression to set the label to a value or blank, but that didn't work.

Is there a way, on a line chart, to have all points plotted, but only a subset labelled?

Thanks



Post Edited by rfisher_vela at 02/02/2010 16:23
Link to comment
Share on other sites

Re: jmolina' post: -

I had some troubles trying to do the same thing (see my comments after yours). It worked when I set only the Increment Group. My expression used division with intValue sent to the entire result:
( $F{report_dt}.getTime() / $P{chart_interval} ).intValue()
So you might try:
( $V{REPORT_COUNT} /40 ).intValue()
Also, if you're not using Groovy as the expression language, change it to use Groovy - it seems to work better for these expressions.



Post Edited by rfisher_vela at 02/02/2010 16:22
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...