I created this report to answer the Question from Jaspersoft Community .
1) Create a report with parameters. (I have used P_CITY and P_COUNTRY as parameters and the SQL Code I have used is as below)
2) This Query will take either P_COUNTRY as a parameter input and will display Country level data or P_CITY as parameter value and display city level data.
3) Now create a Variable which will display Country Names when P_COUNTRY is selected as the parameter and will display City names when P_CITY is selected as parameter.
4) Now create a Chart with this newly created variable as Category Field.
5) The Report design of my report looks like this.
6) Now when we preview the report, we needto provide teh parameter value. For teh purpose of this tutorial I added “Rio de Janeiro” as the value for P_CITY Parameter and left P_COUNTRY as Null.
7) The Result is as follows. (Check the X-axis and Y axis carefully)
8) Now P_CITY is kept Null and P_Country is updated as “Brazil”
9) The Result is as follows.
This is one way to Dynamically change the X-Axis values as per the parameter selection.
The above report is free for your download
Hope this helps you all!!!! For more information on Jaspersoft keep loked in 🙂