Pollux Us Posted June 27, 2014 Share Posted June 27, 2014 Hi,I'm new to JasperReports, here is my problem :I have one table SALE with three columns price [bigDecimal], id_product [integer], the_date [Date]. My query :SELECT sum(price), the_dateFROM SALEWHERE id_product = $P{my_parameter}GROUP BY the_date[/code]The query works, but i want to get four datasets (one for each case of my_parameter). I would like to build a lineChart with 4 lines.For each line :Category : $F{the_date}Value : $F{sum(price)}Series : $P{key_parameter} Line 1 => Query 1 => my_parameter = 1Line 2 => Query 2 => my_parameter = 2Line 3 => Query 3 => my_parameter = 3Line 4 => Query 4 => my_parameter = 4 I want the four line in the same time on my chart (At the moment i just get one line).Is this possible ? If this is possible can u explain me how to do this please ?Thanks for help in advance ! PS : I apologise for my rought english. Link to comment Share on other sites More sharing options...
Pollux Us Posted July 2, 2014 Author Share Posted July 2, 2014 Hi,I found how to do this, if someone is interested, but i'm not sure it's the best way. In my java code i created a TreeMap<Date,List<BigDecimal>>I initialized this TreeMap by the Date i want with a list of 0 for each product :(Date)List(0) <=> product 1List(1) <=> product 2List(2) <=> product 3List(3) <=> product 402-July-2014000001-july-20140000then i created jdbc connection and i executed all my requests from my java code :Request 1 :SELECT SUM(price), the_dateFROM SALEWHERE id_product = 1AND the_date > TO_DATE('31/05/2014', 'DD/MM/YYYY')AND the_date < TO_DATE('03/07/2014', 'DD/MM/YYYY')GROUP BY the_date</pre>[/code]Request 2 :SELECT SUM(price), the_dateFROM SALEWHERE id_product = 2AND the_date > TO_DATE('31/05/2014', 'DD/MM/YYYY')AND the_date < TO_DATE('03/07/2014', 'DD/MM/YYYY')GROUP BY the_date[/code]Request 3 :SELECT SUM(price), the_dateFROM SALEWHERE id_product = 3AND the_date > TO_DATE('31/05/2014', 'DD/MM/YYYY')AND the_date < TO_DATE('03/07/2014', 'DD/MM/YYYY')GROUP BY the_date[/code] Request 4 :SELECT SUM(price), the_dateFROM SALEWHERE id_product = 4AND the_date > TO_DATE('31/05/2014', 'DD/MM/YYYY')AND the_date < TO_DATE('03/07/2014', 'DD/MM/YYYY')GROUP BY the_date[/code]then i got the results and filled my TreeMap :(Date)List(0) <=> product 1List(1) <=> product 2List(2) <=> product 3List(3) <=> product 402-July-20141000180001-july-2014150200060With this TreeMap i created an array of bean, then a JRDataSource, i passed my JRDataSource to my report in my java code and it's works. Like i said before i'm think it's not the best solution, if someone have a better solution i would like to know what it is :) 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