RotatedAxisLabels

2003-12-10
2013-01-13
  • Jon Wynacht
    Jon Wynacht
    2003-12-10

    Hi,

    I am trying to use this ChartPostProcessor in my app and have configured it in the following way:

    <jsp:useBean id="labelRotation" scope="request" class="de.laures.cewolf.cpp.RotatedAxisLabels"/>

    <cewolf:chart
                  id="line"
                  title="Supplier Performance Report"
                  type="verticalbar"
                  xaxislabel="ASIC"
                  yaxislabel="Score">
                  <cewolf:data>
                    <cewolf:producer id="vendorPerf"/>
                  </cewolf:data>
                  <cewolf:chartpostprocessor id="labelRotation">
                      <cewolf:param name="rotate_at" value='<%= new Integer(90) %>'/>
                  </cewolf:chartpostprocessor>
                </cewolf:chart>
                <p>
                <cewolf:img chartid="line" renderer="cewolf" width="400" height="300" border="0"/>

    But it doesn't seem to do anything. Doesn't even throw an error. I've cruised through the messages in this forum and can't seem to find anything about this.

    Anybody have advice or know what the problem is?

    Thanks,

    Jon

     
    • Kristina Tripp
      Kristina Tripp
      2003-12-17

      If haven't tried it the way you mentioned but I've rotated the axis lables via the chart post processor

      ValueAxis rangeAxis = plot.getRangeAxis();
      rangeAxis.setLabelAngle(Math.PI/2.0);

      This sets it horizontally.
      If you do a secondary axis and want to set it horizontally
      you need to do

      rangeAxis.setLabelAngle(-Math.PI/2.0);

      Hope this is what you where looking for.

      - Kristina

       
    • violstar
      violstar
      2005-04-07

      I had the exact same problem and spent lots of time to debug the library.  The solution was as easy as the following.  In the chartpostprocessor tag try the following:

      <cewolf:chartpostprocessor id="labelRotation">
      <cewolf:param name="rotate_at" value='<%= new Integer(90) %>'></cewolf:param>
      </cewolf:chartpostprocessor>

      As simple as that and it fixed my problem.

       
    • It didnt quite fix my problem I had a line chart and had to set the number equal or less to the number of lines in my chart else it wont rotate.
      It looks like an error in the code to me.

       
    • worker1983
      worker1983
      2005-08-09

      Hi all,

      i have exactly the same problem. I want to rotate the X-Axis, so the labels are vertical.

      I try it on the way like Jon, and use the tip from violstar. But nothing happen.

      Also i try to use the code from Kristina, but its throw an error:
      cannot resolve symbol symbol : class ValueAxis location: class
      cannot resolve symbol symbol : variable plot location: class

      It's seems to be a misconfiguration problem on my JSP site.

      Can anyone tell us how we can rotat the labels? Thx.

      --sorry about my english :)  --

       
      • andychief
        andychief
        2005-10-28

        Hello All
        <%@page import="org.jfree.chart.axis.CategoryAxis"%>
        <%@page import="org.jfree.chart.axis.CategoryLabelPositions"%>

        <%
        ChartPostProcessor axisRange = new ChartPostProcessor() {
        public void processChart(Object chart, Map params) {
                  CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
                  NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis();
                      valueAxis.setAutoRangeIncludesZero(false);
                    valueAxis.setAutoRangeMinimumSize(10000);
                  CategoryAxis domainAxis = plot.getDomainAxis();
                // Set label orientation
                domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
             }
          };
          pageContext.setAttribute("axisRange", axisRange);

        %>

        <cewolf:chartpostprocessor id="axisRange">
             </cewolf:chartpostprocessor>

        Here are the three pieces you need and let me know if you still have problems.

        thanks

         
    • DonM
      DonM
      2006-01-30

      There seems to be confusion about the purpose of the rotate_at parameter.  When you supply a value of 90, it does not mean rotate 90 degrees. It means that if your Dataset contains at least 90 categories, the label will be rotated.  If you want the label always rotated, supply a value of zero. Please review the source for the RotatedAxisLabels class and you will see what it was intended to do.  If you want to rotate the labels other than UP_90 or STANDARD, you will need to write your own ChartPostProcessor.