Home
Analytics
Manage the start marker with script in Gantt Chart
unknown
Hi
For this example, is it possible to define a different start marker for each value in the series like :
if getValue() is "shipped" : start marker is triangle
else : start marker is square
Best regards
Find more posts tagged with
Comments
mwilliams
Try this script:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawMarker( marker, dph, icsc )
{
if (dph.getSeriesDisplayValue() == "Shipped"){
marker.setType(MarkerType.TRIANGLE_LITERAL);
}
else{
marker.setType(MarkerType.BOX_LITERAL);
}
}
</pre>
mwilliams
If you wanted to be able to set both, you'd do this, instead:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawSeries( series, isr, icsc )
{
if (series.getSeriesIdentifier() == "Shipped"){
series.getStartMarker().setType(MarkerType.TRIANGLE_LITERAL);
series.getEndMarker().setType(MarkerType.CIRCLE_LITERAL);
}
else if (series.getSeriesIdentifier() == "decline"){
series.getStartMarker().setType(MarkerType.BOX_LITERAL);
series.getEndMarker().setType(MarkerType.DIAMOND_LITERAL);
}
}
</pre>
gyuksel
Hi mwilliams,
I am new to BIRT. Having different series markers is just what I am trying to do.The script you have written seems quite promising. However I do not know how or where to place it in my design file.
Can you please explain how to use it in a gantt chart? Of course I would appreciate if you could upload a simple design file.
Best regards
gyuksel
Hi all,
I have found it! Apparently I missed the script view of the design file.
Solution: In Eclipse, when you open a design file there are some tabs at the bottom. You must click on the "Script" tab and write your script there.
However I have another issue..
Now I want to put different markers for different task status information in the series data in a gantt chart.
For example ,
if row[Status] ="In Progress" then marker will be triangle
if row[Status] ="Cancelled" then marker will be square
How can I access dataset row through the script above? Is this possible at all?
Thanks in advance!
mwilliams
I'm not sure I'm understanding your question. What is different about this question than the one answered above? Let me know. Thanks!
gyuksel
Hi mwilliams,<br />
<br />
In the first question I did not have any idea where to write script in BIRT design view. The second question is about how to access dataset rows in a script. I want to give different markers for the series in a Gantt diagram according to Status (row[Status]) information in the dataset.<br />
<br />
I am not sure if the function beforeDrawSeries is the right one for this purpose but just to make for my question clear, for example can I write something like that:<br />
<br />
function beforeDrawSeries( series, isr, icsc )<br />
{<br />
<br />
//if row[Status] ="In Progress" then marker will be triangle<br />
//if row[Status] ="Cancelled" then marker will be square<br />
<br />
} <br />
<br />
As far as I tried, I could not acces dataset rows. How can I do that? <br />
<br />
I hope this is clear now. <br />
<br />
Thanks!<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="101161" data-time="1337696746" data-date="22 May 2012 - 07:25 AM"><p>
I'm not sure I'm understanding your question. What is different about this question than the one answered above? Let me know. Thanks!<br /></p></blockquote>
mwilliams
Sorry, I meant the question in which vkober asked how to show a different marker when the status was "Shipped" or "Decline". If you look at the first two responses by me, in here, you'll see script that will show how to change the marker based on the "status". This script assumes you have used the status field as the optional grouping for the chart. Let me know what the difference is between what you're trying to do and that, but as far as I can tell, the only difference is that you'll write "Cancelled" instead of "decline". As for accessing fields not included in the chart, you typically can't do this unless you pass them in through a global variable or something. Hopefully this answers your question
gyuksel
Sorry for delay... I was out of the office for a while.
The difference is row[Status] is not used for grouping. I do not want to group the series by Status but I just want to give different markers according to Status. Is this possible? In the script, I want to read row[Status] from the dataset but I can not do that so far. I would appreciate if you give some hints on that.
Thanks in advance!
mwilliams
Can you set up a report using the sample database, showing how you want it set up and describe what you want it to look like? Thanks!
gyuksel
Hi,
I attached the report design file markers.rptdesign
The aim is configuring series markers according to row[Status].
In the script I use following:
function beforeDrawSeries( series, isr, icsc )
{
importPackage( Packages.org.eclipse.birt.chart.model.type );
importPackage( Packages.org.eclipse.birt.chart.model.type.impl );
importPackage( Packages.org.eclipse.birt.chart.model.attribute );
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
if (series.getSeriesIdentifier() == "Shipped"){
series.getStartMarker().setType(MarkerType.TRIANGLE_LITERAL);
series.getEndMarker().setType(MarkerType.CIRCLE_LITERAL);
}
else if (series.getSeriesIdentifier() == "Cancelled"){
series.getStartMarker().setType(MarkerType.BOX_LITERAL);
series.getEndMarker().setType(MarkerType.DIAMOND_LITERAL);
}
}
This is working because row[Status] is defined as Optional Y Series Grouping. However I do not want to use this grouping as it is changing the order and the color of the series.
It seems like series.getSeriesIdentifier() returns row data defined as Optional Y Series Grouping in Gantt Chart(row[Status] in this case).
How can I reach row[Status] if it is not configured as Optional Y Series Grouping? I think the general question is if there is a way to access dataset other than series.getSeriesIdentifier()?
I hope it is clear now.
Thanks!
mwilliams
Take a look at this edited version of your report. In the onFetch script of the dataSet, I set persistentGlobalVariables named after each order, so they can be recalled order by order in the chart. Then, in the chart script, you'll see where I checked the PGV and changed the marker to be what I want for each status type. Notice that I set the default marker types in the chart for the start and end markers, so I was able to check that type and set the appropriate start and end marker, since I don't think you can determine whether the current marker you're checking is the start or end if they're the same. I left the task label there, so you could see that it was indeed accurate. Let me know if you have questions.
gyuksel
Hi mwilliams,<br />
<br />
This is exactly what I was trying to do.<br />
<br />
Thanks for your help!
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="104958" data-time="1340251795" data-date="20 June 2012 - 09:09 PM"><p>
Take a look at this edited version of your report. In the onFetch script of the dataSet, I set persistentGlobalVariables named after each order, so they can be recalled order by order in the chart. Then, in the chart script, you'll see where I checked the PGV and changed the marker to be what I want for each status type. Notice that I set the default marker types in the chart for the start and end markers, so I was able to check that type and set the appropriate start and end marker, since I don't think you can determine whether the current marker you're checking is the start or end if they're the same. I left the task label there, so you could see that it was indeed accurate. Let me know if you have questions.<br /></p></blockquote>
mwilliams
You're very welcome. Let us know whenever you have questions!