0

Kindly help me to create hierarchy of axis labels.

I need to create different products developed in different years. The hierarchy will go like

                          --\Year
                               |
                              +---Month
                                   |
                                   +---Product developed in a month and the quantity

| prod1 | Prod 2 | Prod3 | Prod1 | Prod2 | Prod1 | Prod4 |

|Jan |     Feb    |  Jan      |    Feb    |

|   Year 2008     |       Year 2009       |
user129260
  • 23
  • 1
  • 5
  • 1
    You can't expect anything to be serve as spoon feeding. at least try from your side and show some efforts, if you have any problem then you are welcome! – Shailesh Saxena Jun 24 '13 at 08:30
  • @Shailesh I had looked at http://www.roseindia.net/chartgraphs/stacked-bar-chart1.shtml However, the hierarchy isn't linked with the bars being shown. The Product1, Product2,Product3 have just been placed there. Moreover, I need to generate those hierarchy dynamically. – user129260 Jul 22 '13 at 10:31
  • @ShaileshSaxena: I was not allowed to write the complete code so I've added the link. Please help me. – user129260 Jul 22 '13 at 10:38
  • I couldn't understand your problem properly. Could you show some screen shot of your out put or if you can be more specific about your problem? It will be helpful to trace your problem. – Shailesh Saxena Jul 23 '13 at 05:24
  • @ShaileshSaxena : Currently I don't have that much reputation to add an image. But you can check at http://www.roseindia.net/chartgraphs/stackedbar-chart1.gif Here the values - Product1, product2 and product3 are in each of the months. My requirement is that these can be different values for each month and even the number of Products can also increase, say Product4 too for a particular month but not for other. – user129260 Jul 24 '13 at 05:17

1 Answers1

0

All it depends on how you are fetching values to add on chart. What all you need to do is keep result.addValue() and map.mapKeyToGroup() inside proper loop iteration and set domainAxis.addSubCategory() for all possible number of products. Whatever link you provided ( http://www.roseindia.net/chartgraphs/stacked-bar-chart1.shtml ) here values are added to chart manually. As I am not aware of how you are fetching the values to set in chart and what is your scenario.

These links may help you:

http://jfree.org/phpBB2/viewtopic.php?f=3&t=19521

Create barchart using jfreechart with bars of same category together

Community
  • 1
  • 1
Shailesh Saxena
  • 3,472
  • 2
  • 18
  • 28
  • My situation is that I have to show number of products produced each month of certain time period(in years). Each month, some new products can be introduced. I need to show the products and number of products produced in a particular month within all the years that user has chosen. So I need to show in a hierarchy as updated in the question above. – user129260 Jul 25 '13 at 10:04
  • I have a table in database which will contain all these values,i.e. the product name, its quantity produced, the month and the year it was produced. – user129260 Jul 25 '13 at 10:12