Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

jasper reports - Need to create count variable in iReport

I need to find the count of a field in iReport. For example i need to create a variable called "CallCount" which have count of "CallType" field. So i need to use "CallType" field in Category section of Piechart and "CallCount" variable as measure. So that pie chart will show the call types and its call counts. Please help me on this....

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If using the community charts (JFreeCharts), here is how you would do this.

You need to add a group to the report. Right click on the root object in the Report Inspector window. Click 'Add Report Group'. Then add a group with the field you're interested in. You don't have to add the header/footer bands.

This also creates the variable for you. It should be named something like 'GROUP_NAME_GROUP_COUNT'

Drag a new chart onto the summary band. (I believe it has to be in a summary band, although I could be wrong). Set the unique identifier (Key Expression) to '$F{CallType}' and the numeric value (Value Expression) to '$V{GROUP_NAME_GROUP_COUNT}')

If this doesn't work then try creating the variable manually. Add a variable, name it 'CallCount'. Set the class to 'java.lang.Integer', calculation to 'Count', and Reset Type to 'Group'. The reset group should match the group you created earlier. The Variable Expression should be the field you're interested in. In this case 'CallType'. Set the numeric value to 'CallType'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...