Multiple graphs per report [message #884642] |
Mon, 11 June 2012 14:43 |
|
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 #884766 is a reply to message #884728] |
Mon, 11 June 2012 19:34 |
|
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 |
|
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 #885286 is a reply to message #885182] |
Tue, 12 June 2012 18:40 |
|
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 |
|
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 |
|
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 |
|
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);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04622 seconds