Olly Messages: 60 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?
Olly Messages: 60 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.
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.
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:
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.
Olly Messages: 60 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
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.
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?
Olly Messages: 60 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.