Jump to content
We've recently updated our Privacy Statement, available here ×

PieChart Sorting of Legend


jh86

Recommended Posts

hi,

i've got a short question. i've created a report with a piechart inside. for the keyexpression i used the days of a week ( "monday", "tuesday", etc.). now, when i enable the legend, these keys are in a unsorted order, but it would be nice if i could modify that order. first i thought they are ordered alphabetically, because they are strings, but they aren't ordered in that way.

then i found the examples in the ireport ultimate guide, where the countries in the legend are ordered alphabetically. now my question is, how can i control the ordering? i found out, that if i use numbers for the key expression, they are sorted ascending. but how can i affect the ordering of strings?

thank you for your help.

sincerely, jh

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You can modiy your query and create a new column called something like "Order_". For this column you can do a case statement

case when table.day = 'Monday' then 1

          when table.day = 'Tuesday' then 2

and so on.

Then include this new column in the "ORDER BY" statement of your query.

Hope this helps!

Link to comment
Share on other sites

  • 1 month later...

I'm running into the exact same problem.  Ordering of the sql is not solving the problem of apparent random assignment of keyExpressions to slices of the pie chart.

And to be perfectly clear, the legend always follows the series for coloring of pie slices.  The problem is that my keyExpression is assigned to an apparently random slice (0,1,2,3,etc). 

Things I've tried

1.  Ordering sql

2. <sortField name="slice_title"/>

 

I'm using an mysql database from a servlet call in Jboss and exporting the report as html. 

 

Thanks for any assistance!



Post Edited by orson at 07/31/2009 08:06
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...