在iReport中创建饼图(4.6.0)

问题描述:

我需要帮助,使用 iReport 4.6在我的查询( SQL )中使用 GROUP BY 时只显示一个.0。

I need help making only one (complete) Pie Chart show up when using GROUP BY in my query (SQL) using iReport 4.6.0.

我需要使用 iReport (4.6.0;我使用的是独立版本,而不是NetBeans插件)从 SQL 数据库提取的数据。基本上,我试图创建一个饼图,在数据库中的男性百分比是多少百分比是女性。

I need to create a report using iReport (4.6.0; I am using the standalone version, not the NetBeans Plug-in) using data pulled from an SQL database. Basically, I'm trying to create a Pie Chart of what percentage of people in the DB are male and what percentage are female.

一开始我尝试做两个单独的查询以提取此信息:

At first I tried doing two separate queries to extract this information:

SELECT COUNT('person_id') FROM 'table' WHERE 'SEX' = 'M';
SELECT COUNT('person_id') FROM 'table' WHERE 'SEX' = 'F';

我试着将这两个查询都放入报表查询对话框中,但是 iReport 显然一次只处理一个查询。我还尝试使用 UNION

I tried putting both of these queries into the Report Query dialog box, but iReport apparently only handles one query at a time. I also tried using UNION.

然后我尝试(目前正在使用):

I then attempted (and am currently using):

SELECT COUNT('person_id') FROM 'table' GROUP BY 'sex'

这给了我有限的成功。它创建了我需要的图表,但也创建了额外的,多余的图表,只有部分数据。似乎每次 iReport 从查询中命中新的组时,除了来自先前组的任何数据之外,还创建了具有该组的数据的信息的新图表(即,在这种情况下,它创造了2个饼图,一个只显示女性成员的DB和一个显示男性和女性成员)。这个理论也通过在DB(M,F,U)中添加一个新类别来测试,看它是否会创建3个图表;它(首先是女性,第二次是男性和女性,第三次是男性,女性和未知)。

This has given me limited success. It creates the chart that I need, but also creates additional, superfluous charts with only part of the data. It appears that each time iReport hits a new "group" from the query, it creates a new chart with the information with that group's data in addition to any data from previous groups (ie. in this case, it created 2 Pie Charts, one which showed only the female members of the DB and one which showed both male and female members). This theory was also tested by adding a new category in the DB (M, F, U) to see whether it would create 3 charts; it does (first with just female, second with male and female, third with male, female, and unknown).

感兴趣的图表是最后一个,一个显示来自所有组的数据。你能帮我找出如何获得最后一个完整的饼图吗?

The chart which interests me is the last one, the one which shows the data from all the groups. Can you guys help me in figuring out how to get only that last, complete Pie Chart?

将图表放在标题或摘要带。确保其评估时间设置为报告。

Put the chart in the Title or the Summary band. Make sure its evaluation time is set to 'Report'.