Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Creating a Stacked Bar chart using a script
ShlomiW
Hi all,
I'm trying to create a dynamic Stacked Bar chart.
I have found an example that shows how to create a simple bar chart using a script in the "beforeFactory",
but I can't figure out how make it display as a stacked bar.
meaning which part of the Birt API is controlling that "Optional Y Series Grouping" setting.
I have attached a sample report.
When you view it in HTML you see 3 parts:
1. a table that displays all the data that I got in the dataset
2. a Stacked bar chart that I created using Birt eclipse and the dataset from item 1 (hard coded), this chart is using the "PRODUCTCODE" column as the "Optional Y Series Grouping" to group the data.
3. a bar chart that I create dynamically using the dataset from item 1.
comment: This is not a real-life example just a sample report that I created as a test.
What I'm trying to do, is to create exactly the same chart as in item 2 but dynamically. The problem is that I cannot find neither an example nor the API calls to set the "Optional Y Series Grouping" of that chart.
Your help will be greatly appreciated,
Shlomi
Find more posts tagged with
Comments
kclark
I haven't test it yet but <a class='bbc_url' href='
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.birt.chart.doc.isv/chart/api/org/eclipse/birt/chart/api/ChartEngine.html'>looking
at the chart API's</a> it looks like setGrouping() is what you're wanting.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
setGrouping
void setGrouping(SeriesGrouping value)
Sets the value of the 'Grouping' containment reference.
Parameters:
value - the new value of the 'Grouping' containment reference.
See Also:
getGrouping()
</pre>
ShlomiW
Hi all,<br />
<br />
Sorry kclark but you must have misunderstand me because that dose not help me.<br />
<br />
Still I have found <a class='bbc_url' href='
http://www.birt-exchange.org/org/forum/index.php/topic/15007-how-to-access-optional-y-series-grouping/page__s__b6a57d2f3cff3776707ef08b27df907c'>this
post</a> and from thier I understand that I need to add the following lines to my code:<br />
<br />
To make the chart displayed as a Stacked Bar<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>bs1.setStacked(true);</pre>
<br />
Creating a new query with the datarow that will be used for the "Optional Y Series Grouping"<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>grQuery = QueryImpl.create( "row[\"cat2\"]" );</pre>
<br />
add that new query to the "SeriesDefinitionImpl" element<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>sdY.setQuery(grQuery);</pre>
<br />
I have also added the report example with the new lines.<br />
<br />
Hope that will help other people that will have the same issue.<br />
Have a great day<br />
SHlomi
vba
<p>Very nice example! Thanks a lot! I found such an example of chart creation from scripting.</p>
nehak
<p>very nice example</p>