Jump to content

BIRT Developer Center Download


Photo
- - - - -

Charting a selection of Fields


  • Please log in to reply
5 replies to this topic

#1 robilco

robilco

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 18 February 2013 - 03:46 AM

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

#2 robilco

robilco

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 18 February 2013 - 05:36 AM

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


One solution I've found is the following:
1) Add a Grid to my Report
2) Bind my data set to the grid
3) Add an onRender Script to the chart - Caching the rows I'm interested in, via reportContext.setGlobalVariable
4) Add a chart to the grid - Chart on slice data 'null'
5) Add an onRender script to the chart, programmaitcally inserting data, as outlined in section 3.1 here: http://www.birt-exch...-on-subqueries/

This is not ideal as its a little too complicated for end users IMO

I'm still looking for a more simple solution

#3 robilco

robilco

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 19 February 2013 - 02:56 AM

I've found another (less complex solution)

1) Create a Scripted Data Source
2) Create a Scripted Data Set with output columns: categoryName (String) and dataValue (Decimal)
3) Add a Grid to my Report
4) Bind my data set to the grid
5) Add an onRender Script to the chart - Caching the data in 2 arrays
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");
6) Create 2 Scripts on the Scripted data Set
i) On the open
recordCount =0;
ii) On the fetch:
if ( recordCount < dataNamesArray.length ) {
  row[1] = dataNamesArray[recordCount];
  row[2] = dataValuesArray[recordCount];
  recordCount++;
  return true;
}
return false;
7) Add my Chart to the report, select Scripted Data Set as data binding and 2 columns as axis

#4 Hans_vd

Hans_vd

    Junior Member

  • Members
  • 629 posts

Posted 21 February 2013 - 06:46 AM

Hi Robilco, Just a week ago I wrote about columns to rows transformation on our company blog (http://enterprisesma...-birt-data-set/). And I posted it on devshare too (http://www.birt-exch...-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

#5 robilco

robilco

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 21 February 2013 - 06:59 AM

Hi Robilco,

Just a week ago I wrote about columns to rows transformation on our company blog (http://enterprisesma...-birt-data-set/). And I posted it on devshare too (http://www.birt-exch...-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


Fire ahead Hans :)

#6 Hans_vd

Hans_vd

    Junior Member

  • Members
  • 629 posts

Posted 21 February 2013 - 07:02 AM

Great!!
Thanks

Update: It's here! And there!

Edited by Hans_vd, 22 February 2013 - 01:16 AM.