Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Multiple graphs per report
Multiple graphs per report [message #884642] Mon, 11 June 2012 14:43 Go to next message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
I am trying to figure out how to have multiple charts per report. Let me start with a simple example. Say I have a table in a database called Book, a table called BookType and another table called Price. Books can have and will have multiple Book types and multiple prices. For each Book and Book Type I want the price of the book over time, since prices constantly change. So the x axis would be the date timestamp, the y axis would be the price of the book and the y series grouping would be a group by book name and book type. At the moment I have all the books and book types on the same graph. The end user has suggested I break the graph up by (book name, book type). This would mean I have to have a graph for each book name, book type group. The only idea I had was to put the graph in a table. If I do this I don't see how I could set the query for the graph to only show the book name and book type for that row. Are there any ways of doing this? Maybe a different way that I cannot think of?
Re: Multiple graphs per report [message #884680 is a reply to message #884642] Mon, 11 June 2012 15:40 Go to previous messageGo to next message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
Ok so what I've done so far is follow the grouping tutorial and I've managed to group by book name, book type and book category. I now have 3 grouping clauses in the table. Now I try to make sure I design the report correctly. The following links were helpful: http://www.eclipse.org/forums/index.php/t/203719/ and http://www.eclipse.org/birt/phoenix/tutorial/basic/basic06.php#city_group
Re: Multiple graphs per report [message #884728 is a reply to message #884680] Mon, 11 June 2012 17:26 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

So you have it working?

Jason

On 6/11/2012 11:40 AM, Olly Mising name wrote:
> Ok so what I've done so far is follow the grouping tutorial and I've
> managed to group by book name, book type and book category. I now have 3
> grouping clauses in the table. Now I try to make sure I design the
> report correctly. The following links were helpful:
> http://www.eclipse.org/forums/index.php/t/203719/ and
> http://www.eclipse.org/birt/phoenix/tutorial/basic/basic06.php#city_group
Re: Multiple graphs per report [message #884760 is a reply to message #884728] Mon, 11 June 2012 19:12 Go to previous messageGo to next message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
Yes it is working.
Re: Multiple graphs per report [message #884766 is a reply to message #884728] Mon, 11 June 2012 19:34 Go to previous messageGo to next message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
Is there a way to add a threshold line to each chart that depends on the book name and book type? I have a table in the database that stores thresholds for the book names and book types grouping and I would like my scatter plot to display a threshold line since I'm only displaying the values that lie above the threshold.
Re: Multiple graphs per report [message #884835 is a reply to message #884766] Mon, 11 June 2012 23:21 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Do you want a marker line or just to hide all points below a certain value?

Jason

On 6/11/2012 3:34 PM, Olly Mising name wrote:
> Is there a way to add a threshold line to each chart that depends on the
> book name and book type? I have a table in the database that stores
> thresholds for the book names and book types grouping and I would like
> my scatter plot to display a threshold line since I'm only displaying
> the values that lie above the threshold.
Re: Multiple graphs per report [message #885069 is a reply to message #884835] Tue, 12 June 2012 12:09 Go to previous messageGo to next message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
The query is only retrieving the values above the threshold so I just need the marker line so that the person can know what the value of threshold is.
Re: Multiple graphs per report [message #885182 is a reply to message #885069] Tue, 12 June 2012 15:04 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You can place a marker line on the chart and then sets its value
dynamically. I am attaching an example that does this based on a
parameter. You can convert it to look somewhere else for the value. If
you want it based on some other column add a hidden table at the top of
the report and using script persist a global variable with the value and
then get the value in chart script. These links may be useful as well:

explanation on attached:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1158-setting-marker-line-based-on-date-parameter/

http://www.birt-exchange.org/org/forum/index.php/topic/25461-dynamic-marker-line-in-barchart-different-for-each-group/


Jason



On 6/12/2012 8:09 AM, Olly Mising name wrote:
> The query is only retrieving the values above the threshold so I just
> need the marker line so that the person can know what the value of
> threshold is.
Re: Multiple graphs per report [message #885286 is a reply to message #885182] Tue, 12 June 2012 18:40 Go to previous messageGo to next message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
Ok so here is what I've got. I want to have a min threshold and a max threshold for each graph. Each graph is in the group footer. I can add 2 detail rows, 1 for max_threshold and 1 for min_threshold. In the onPrepare method of the table that contains the charts and all the other stuff I can set
reportContext.setPersistentGlobalVariable("MAX_THRESHOLD", "");
reportContext.setPersistentGlobalVariable("MIN_THRESHOLD", "");
each of those I can set in the appropriate detail row to
reportContext.setPersistentGlobalVariable("MAX_THRESHOLD", this.getValue());
Now since I have 2 markers in each graph, how can I identify the markers and set their values? This is the part I am struggling with. Is there somewhere I can access the scripting API's to know which methods to call? I haven't found them anywhere.
Re: Multiple graphs per report [message #885300 is a reply to message #885182] Tue, 12 June 2012 19:15 Go to previous messageGo to next message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
So this is what my script looks like and it works.
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
function beforeDrawMarkerLine( axis, markerLine, context) 
{
	target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("MAX_THRESHOLD")
	markerLine.setValue(NumberDataElementImpl.create(target));
	markerLine.getLabel().getCaption().setValue("Max Threshsold " + target);
}

Now I would like to add a 2nd marker for the min threshold. How do I do that?
Re: Multiple graphs per report [message #885909 is a reply to message #885300] Wed, 13 June 2012 21:09 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You should be able to add multiple marker lines in the chart builder.
That event will be called for each marker that is int he report.

Jason

On 6/12/2012 3:15 PM, Olly Mising name wrote:
> So this is what my script looks like and it works.
> importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
> function beforeDrawMarkerLine( axis, markerLine, context) {
> target =
> context.getExternalContext().getScriptable().getPersistentGlobalVariable("MAX_THRESHOLD")
>
> markerLine.setValue(NumberDataElementImpl.create(target));
> markerLine.getLabel().getCaption().setValue("Max Threshsold " + target);
> }
> Now I would like to add a 2nd marker for the min threshold. How do I do
> that?
Re: Multiple graphs per report [message #886203 is a reply to message #885909] Thu, 14 June 2012 12:37 Go to previous message
Olly   is currently offline Olly Friend
Messages: 61
Registered: June 2010
Location: Florida
Member
Thank you. I was able to do it by adding 2 more global variables. One is a counter and the other is the other value. I put an if statement to determine which line to set.
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
function beforeDrawMarkerLine( axis, markerLine, context) 
{
	target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("COUNTER");
	if(target != 0)
	{
		target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("MAX_THRESHOLD");
		markerLine.setValue(NumberDataElementImpl.create(target));
		markerLine.getLabel().getCaption().setValue("Max Threshsold " + target);
		context.getExternalContext().getScriptable().setPersistentGlobalVariable("COUNTER", "0");
	}
	else
	{
		target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("MIN_THRESHOLD");
		markerLine.setValue(NumberDataElementImpl.create(target));
		markerLine.getLabel().getCaption().setValue("Min Threshsold " + target);
	}
}
Previous Topic:replacing string with parameter
Next Topic:NPE in ObjectWriter.write using BIRT 2.6
Goto Forum:
  


Current Time: Thu Mar 28 09:54:33 GMT 2024

Powered by FUDForum. Page generated in 0.03877 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top