pbadger Posted March 12, 2010 Share Posted March 12, 2010 We use xml datasource for our iReports. I'm using iReport 3.7.1I'm trying to create my first Chart. The only samples/examples/tutorials I can find on creating charts use SQL and I'm having a very difficult time tyring to translate that to using an xml file.Basically, what I would like to do is this. I'll use the AddressBook for my example to keep it simple. <grin><addressbook> <lastupdate>2009-10-31</lastupdate> <person> <name>ETHAN</name> <phone type="mobile">+1 (415) 111-1111</phone> <phone type="home">+1 (415) 111-1112</phone> <phone type="work">+1 (415) 111-1113</phone> <phone type="fax">+1 (415) 111-1114</phone> </person> <person> <name>CALEB</name> <phone type="mobile">+1 (415) 222-2222</phone> <phone type="home">+1 (415) 222-2223</phone> </person> <person> <name>WILLIAM</name> <phone type="work">+1 (415) 333-3333</phone> <phone type="mobile">+1 (415) 333-3334</phone> </person></addressbook> Now, I can get this to work with the <name> in the detail band and the <phone type> and <phone> in a list element.Conceptually, I'd like to follow this up with a chart in the summary section showing the number of phone numbers of each type. So I added this information to my xml file like so.<addressbook> <lastupdate>2009-10-31</lastupdate> <person> <name>ETHAN</name> <phone type="mobile">+1 (415) 111-1111</phone> <phone type="home">+1 (415) 111-1112</phone> <phone type="work">+1 (415) 111-1113</phone> <phone type="fax">+1 (415) 111-1114</phone> </person> <person> <name>CALEB</name> <phone type="mobile">+1 (415) 222-2222</phone> <phone type="home">+1 (415) 222-2223</phone> </person> <person> <name>WILLIAM</name> <phone type="work">+1 (415) 333-3333</phone> <phone type="mobile">+1 (415) 333-3334</phone> </person> <chart> <phone_grp>mobile</phone_grp> <phone_grp_sum>3</phone_grp_sum> </chart> <chart> <phone_grp>work</phone_grp> <phone_grp_sum>2</phone_grp_sum> </chart> <chart> <phone_grp>home</phone_grp> <phone_grp_sum>2</phone_grp_sum> </chart> <chart> <phone_grp>fax</phone_grp> <phone_grp_sum>1</phone_grp_sum> </chart></addressbook>After adding this into the xml file, the original detail band of the report still works.I created a subdataset, pointing to the same xml file and defining only the 2 fields phone_grp and phone_grp_sum (which is an integer)I used the Pie Wizard to create a pie chart in the summary band. Chose the subdataset. Set phone_grp as my unique identifier and phone_grp_sum as my numberic value.Run the report, the detail band works fine. No chart. Not Cool!If I create a report with only a chart in it looking at this very file and these very fields, I get a pie chart. Cool!For some reason, I'm missing something in trying to run this in the same report.I suspect it has something to do with the Chart Details - Connection / Datasource Expression. When I look at this after the Wizard creates the chart, in the Dataset run section I see Sub dataset "dataset2" (which is correct), but I also see Connection/Datasour Expression is set to "Don't use connection or datasource"That doesn't look right, why would it default to that when I've told it the subdataset? So I change it to "Use datasource expression" and this is automatically set to new net.sf.jasperreports.engine.JREmptyDataSource(1)Empty Data Source??????I'm stumped. I'm self taught in iReport and I don't have a manual. I've been scouring this site looking for clues, but I have no idea what I need to set this to so the report can see the data from the subdataset.Can someone please help me? Please?????I've tried so many things that at this point I'm dangerously close to that old joke about the definition of insanity is doing the same thing over and over and expecting a different outcome.I would really appreciate any help anyone can give me!Thanks in advance!!!Patrice Link to comment Share on other sites More sharing options...
pbadger Posted March 12, 2010 Author Share Posted March 12, 2010 I should add that I've tried this in versions 3.0.0 3.5.0 & 3.7.1 Patrice Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now