I'm creating a pie chart in Jaspersoft Studio. I have two variables containing integer values. Using those two variables i want to create a pie chart. I tried adding two series and placing the pie chart in summary band but only one series is displaying. So, how am i supposed to create a pie chart from two variables instead of a column in database?
I still don't have the actual database so i'm using a sample database that comes with jasper studio. I only need two integers and a string so that's why I've used such a query.
In order to create a pie chart from two variables, I've create two series, put respective expression in both series, placed my pie chart in summary band and executed the code.
In your query, you are taking Accepted
and Rejected
as two separate fields and you need those two data need to be displayed your chart. If this is true, then try modifying your query like below,
SELECT count_value, status
FROM (SELECT COUNT(orderid) as count_value, 'Accepted' as status
FROM orders
WHERE shipcountry = 'Germany'
GROUP BY shipcountry)
UNION ALL
(SELECT COUNT(customerid) as count_value, 'Rejected' as status
FROM orders
WHERE shipcountry = 'Germany'
GROUP BY shipcountry)
Now you will have two fields which is count_value
and status
. In pie chart, provide status
field in series and count_value
in value.
Hope this should help you out.