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)
Charting a selection of Fields
robilco
Hi All,
I'm looking for the best way to generate a pie chart based on a selection of fields in the Data Set.
My Data Set has 15 or so Columns - I want to select 6 of these columns from which to generate a Pie Chart.
What is the best (and most simple) way to do this?
Cheers,
Ronan
Find more posts tagged with
Comments
robilco
<blockquote class='ipsBlockquote' data-author="'robilco'" data-cid="114294" data-time="1361187994" data-date="18 February 2013 - 04:46 AM"><p>
Hi All,<br />
<br />
I'm looking for the best way to generate a pie chart based on a selection of fields in the Data Set.<br />
<br />
My Data Set has 15 or so Columns - I want to select 6 of these columns from which to generate a Pie Chart.<br />
<br />
What is the best (and most simple) way to do this?<br />
<br />
Cheers,<br />
Ronan<br /></p></blockquote>
<br />
One solution I've found is the following:<br />
1) Add a Grid to my Report<br />
2) Bind my data set to the grid<br />
3) Add an onRender Script to the chart - Caching the rows I'm interested in, via reportContext.setGlobalVariable<br />
4) Add a chart to the grid - Chart on slice data 'null'<br />
5) Add an onRender script to the chart, programmaitcally inserting data, as outlined in section 3.1 here: <a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/928-report-with-table-and-chart-from-multiple-data-sources-based-on-subqueries/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/928-report-with-table-and-chart-from-multiple-data-sources-based-on-subqueries/</a><br
/>
<br />
This is not ideal as its a little too complicated for end users IMO<br />
<br />
I'm still looking for a more simple solution
robilco
I've found another (less complex solution)<br />
<br />
1) Create a Scripted Data Source<br />
2) Create a Scripted Data Set with output columns: categoryName (String) and dataValue (Decimal)<br />
3) Add a Grid to my Report<br />
4) Bind my data set to the grid<br />
5) Add an onRender Script to the chart - Caching the data in 2 arrays<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
dataValuesArray = new Array(row["ER_Base_Pay_Total"],row["ER_Incentive_Total"],row["ER_Benefits_Total"],row["Calculated_Grant_Value_ISO"],row["Calculated_Grant_Value_RSU"],row["Calculated_Grant_Value_NSO"],row["ER_Allowances_Total"])
dataNamesArray = new Array("Base Pay","Benefits","Incentive","SO","RSU","NSO","Allowances");</pre>
6) Create 2 Scripts on the Scripted data Set<br />
i) On the open <pre class='_prettyXprint _lang-auto _linenums:0'>recordCount =0;</pre>
ii) On the fetch:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>if ( recordCount < dataNamesArray.length ) {
row[1] = dataNamesArray[recordCount];
row[2] = dataValuesArray[recordCount];
recordCount++;
return true;
}
return false;
</pre>
7) Add my Chart to the report, select Scripted Data Set as data binding and 2 columns as axis
Hans_vd
Hi Robilco,
Just a week ago I wrote about columns to rows transformation on our company blog (
http://enterprisesmartapps.wordpress.com/2013/02/18/columns-to-rows-in-birt-data-set/)
. And I posted it on devshare too (
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1594-columns-to-rows-in-birt-data-set/)
My approach differs from yours, but I like how you did it.
Would you mind if I write a "Columns to Rows PART 2" article on our blog, based on your solution and put it on devshare? I'd be happy to mention that you are the one who sorted out this approach.
Regards
Hans
robilco
<blockquote class='ipsBlockquote' data-author="'Hans_vd'" data-cid="114426" data-time="1361457980" data-date="21 February 2013 - 07:46 AM"><p>
Hi Robilco,<br />
<br />
Just a week ago I wrote about columns to rows transformation on our company blog (<a class='bbc_url' href='
http://enterprisesmartapps.wordpress.com/2013/02/18/columns-to-rows-in-birt-data-set/'>http://enterprisesmartapps.wordpress.com/2013/02/18/columns-to-rows-in-birt-data-set/</a>)
. And I posted it on devshare too (<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1594-columns-to-rows-in-birt-data-set/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1594-columns-to-rows-in-birt-data-set/</a>)<br
/>
<br />
My approach differs from yours, but I like how you did it.<br />
Would you mind if I write a "Columns to Rows PART 2" article on our blog, based on your solution and put it on devshare? I'd be happy to mention that you are the one who sorted out this approach.<br />
<br />
Regards<br />
Hans<br /></p></blockquote>
<br />
Fire ahead Hans
Hans_vd
Great!!<br />
Thanks<br />
<br />
Update: It's <a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1596-columns-to-rows-in-birt-data-set--part-2/'>here</a>!
; And <a class='bbc_url' href='
http://enterprisesmartapps.wordpress.com/2013/02/22/birt-columns-to-rows-in-data-set-part-2/'>there</a>!
;