Jump to content
Changes to the Jaspersoft community edition download ×

Another Pie chart question


martinf

Recommended Posts

Hi

I read a lot about pie chart and still not able to do what I want.

My data look like:

 

name             apple       orange        cherry

Paul                3                 5                 7

Peter                5              6                   8

 

I do a report for each name and want to show a pie chart with pourcent of apple-orange-cherry for each people. I didn't find any example yet.

Thank you

 

Martin F

Link to comment
Share on other sites

  • Replies 13
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

A pie chart typically only measures a single dimension--in this case the three numbers you list--and the fruits associated with each number would be the label that goes with each number.  The PERSON is another dimension.  Do I understand you correctly that you would have a separate pie chart for each person, or are you somehow trying to fit all six numbers into a single pie chart?

 

Carl

Link to comment
Share on other sites

I have a database with 17000 differents names. I would like to have a pie chart for each one of them. So it's possible...? Question: how? In a pie chart, how many pourcent of the three differents fruits for Paul? Next person: another pie chart for Peter, etc. ? How to do that?

Link to comment
Share on other sites

I'm not an expert at charting yet either, but here's the challenge I see:  I think the pie chart expects that the slices are going to represent different values within a single column.  So if instead of  columns 'name', 'apple', 'orange', 'cherry' with 'name' being a unique value you arranged your table to have columns 'name', 'flavor', 'count', where the combination of name and flavor was your unique value, then I think it might be easier to chart.

I was able to transform your table from one format to the other with the SQL command I've pasted down in the "Code" section.  Naturally, you wouldn't need that "with pieinfo" bit at the top...you would start with "select * from" and everywhere you see "from pieinfo" you instead put whatever the name of your actual table is.

So far, so good, I can now print six detail lines instead of the original two (I've changed the amounts to be sure they're different enough from each other that I can tell if the pie charts look correct):

Name     Flavor    Count

Paul        Apple     1

Paul        Cherry     12

Paul        Orange    5

Peter       Apple       10

Peter       Cherry       3

Peter       Orange     8

Now what I do is I go to the root element for the report in the report inspector pane, right click and choose "Add report group".  I said that I wanted the group to be called "Group by Name" and I selected  "Group by the following report object" (which already had a default of NAME--aren't I lucky?).  I said that I wanted to create a group header and a group footer band.  In fact, I don't even need a detail band anymore, so delete that.  In the group header band, I drag my $F{NAME} field over.  Then I expand the size of my group footer band and drag a chart into it.  I choose pie chart, and it takes me into a wizard.  When it asks me to choose a unique identifier, I choose ${FLAVOR}.  When it asks me to choose a numeric value, I choose $F{COUNT}.

A screenshot of the resulting report...with two pie charts included...is attached.

Good luck!

Carl


 

 

Code:



Post Edited by cbarlow3 at 10/20/2010 20:53



Post Edited by cbarlow3 at 10/20/2010 20:53
Link to comment
Share on other sites

I should mention that my clumsy attempt at building a fake table of hardcoded values on the fly used a table called "CORE.ENV".  The method I used needed SOME kind of a table to be referenced, so I referenced a table on our system that I happen to know only has a single record.  There's no magic there, and I already suggested that you ignore the lines I used to return the hardcoded data as a common table expression, so I don't feel TOO guilty about resorting to such tricks, as they're not really part of the solution!

Carl

Link to comment
Share on other sites

If you get it working, let me know, but as long as you're building a dashboard-looking report, I'll put in a plug for the writings of Stephen Few, who wrote "Information Dashboard Design" and a few other books.  He rails against all things circular (including the ever-popular pie chart) in this amusing article: http://www.perceptualedge.com/articles/visual_business_intelligence/our_fascination_with_all_things_circular.pdf

Link to comment
Share on other sites

Thank you! I now have a pie chart with my fruits. But, the pie chart don't change when I have a new person. How the pie chart is suppose to know what is the name of the person above it? A parameter to add the the pie chart?

Thank you again

MartinF

Link to comment
Share on other sites

I think the options depend on which pie chart you choose and which version of iReport you're using.  I'm using iReport Pro 3.7.1.1.  I picked "Chart" (from the pallette--I dragged it into the group footer) and then "Pie", and I got a wizard, which never asked me the "Reset Type"...maybe it defaulted because I dragged it into the group footer.  In any case, right click on your chart in the design pane, and pick "Chart Data".  On the "Dataset" tab, I have an option called "Reset type".  If it says "Report", change it to "Group".  I also got it working with ChartsPro 3D Pie chart, which has slices that pull out and push back into the center each time you click them.  Fun to watch, but not especially useful! :)



Post Edited by cbarlow3 at 10/21/2010 14:29
Link to comment
Share on other sites

I'm with 3.7.5 version.

No change with the "Reset Type" option set to Group.

The pie chart don't change, it stick on the first person, even when I change page, other person name.

For a last time, would please tell what I could be missing?

MartinF

Link to comment
Share on other sites

Well, if it helps any, I notice (now) that when I selected a Reset Type of "Group", it automatically set my Reset Group to "Name Group" (the only group I've defined for this report.  I suppose it might not have done the same for you.  For what it's worth, I've pasted the entire jrxml that is working for me below, in hopes that you can find your needle in my haystack (I'm already regretting saying that).

Carl

Code:


Post Edited by cbarlow3 at 10/21/2010 22:40
Link to comment
Share on other sites

Hi

What's the calculation = "sum" in your file? I don't have this...

 

    </field>
    <variable name="GroupCount" class="java.math.BigDecimal" resetType="Group" resetGroup="Name Group" calculation="Sum">
        <variableExpression><![CDATA[$F{COUNT}]]></variableExpression>

 

Martin

Link to comment
Share on other sites

That's a mistake.  I created that back when I was experimenting with groups but before I had added the pie chart.  I just took the variable out and verified that my report still works.  I DO, however have another variable which I did NOT manually create, and which I cannot delete.  It's called "Name Group_COUNT", and it got created automatically when I first added the report group "Name Group".

Carl

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...