HELP! can't set subCategory LabelPositions

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jack Omin
Posts: 3
Joined: Mon Aug 02, 2004 4:58 pm

HELP! can't set subCategory LabelPositions

Post by Jack Omin » Mon Aug 02, 2004 5:24 pm

I use a 3D BarChart (with vertical orientation) with a subcategory axis.
I need vertical labels for sub-categories and horizontal labels for primary categories, but calling the method setCategoryLabelPositions on the SubCategoryAxis object, only affects the primary axis! How can I fix it?
Any help would be highly appreciated.

Jack Omin
Posts: 3
Joined: Mon Aug 02, 2004 4:58 pm

Post by Jack Omin » Wed Aug 04, 2004 3:57 pm

I think a list of the code which creates the chart may be helpful:

Code: Select all

    private JFreeChart createChart(final CategoryDataset dataset) {
        
        final JFreeChart chart = ChartFactory.createBarChart3D(
            "T1-T2 Donor",      // chart title
            "Periodo",               // domain axis label
            "Numero disattivazioni",  // range axis label
            dataset,                  // data
            PlotOrientation.VERTICAL, // orientation
            true,                     // include legend
            true,                     // tooltips
            false                     // urls
        );

        final CategoryPlot plot = chart.getCategoryPlot();
        final BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
        renderer.setDrawBarOutline(false);
        renderer.setItemLabelsVisible(true);
        
        SubCategoryAxis domainAxis = new SubCategoryAxis("Quindicina / mese");
        domainAxis.setCategoryMargin(0.05);
        domainAxis.addSubCategory("Prima quindicina");
        domainAxis.addSubCategory("Seconda quindicina");
        
/****************************************************************************
 * 		THE FOLLOWING STATEMENT DOES NOT WORK PROPERLY!!!
 ****************************************************************************/
        domainAxis.SetCategoryLabelPositions(CategoryLabelPositions.UP_90);
        
        plot.setDomainAxis(domainAxis);
        plot.setFixedLegendItems(createLegendItems());

        return chart;

    }
Can you see any error?
Please, it is very important for us to have a readable chart!
Regards

Jack Omin
Posts: 3
Joined: Mon Aug 02, 2004 4:58 pm

Post by Jack Omin » Mon Aug 09, 2004 3:49 pm

For those interested in this topic, I've just submitted a bug: [ 1005988 ]
Thank you anyway.

molson
Posts: 2
Joined: Wed Oct 26, 2005 9:06 pm

Post by molson » Mon Dec 12, 2005 8:06 pm

Is there a solution to this? I'd like to angle my sub category labels and not my category labels.

Alan - Blue
Posts: 5
Joined: Wed Nov 15, 2006 5:03 pm

Post by Alan - Blue » Wed Nov 15, 2006 5:05 pm

know its a bit late, but only started using jfree chart and managed to solve this using font manipulation.

Code: Select all

      domainAxis.setSubLabelFont((java.awt.Font)domainAxis.getSubLabelFont().deriveFont(1, new java.awt.geom.AffineTransform().getRotateInstance(Math.PI / 2.5)));

where domain axis is my subcategory axis

Just need to move the position of the category axis labels down a bit as currently they overlap

Locked