X-Axis and Data Range

  • Drake

    I have implemented a 3dbar graph as a representation of Hits/Day the problem seems to be at present that the graph has far too much data to display in a limited space (ie the dates are replaced with ... rather than actual dates).

    The JSP code follows:

    <cewolf:chart id="dateHits" type="verticalbar3d" xaxislabel="Date" yaxislabel="Hits" showlegend="false">
    <cewolf:producer id="dateHitsProducer" />
    <cewolf:colorpaint color="#FFFFFF" />

    <cewolf:img chartid="dateHits" renderer="cewolf" border="0"
    width="800" height="500" />

    Unless there is a taglib that tells the graph to plot only every ten x values or to scale the domain (if i have missed this i do deserve a royal kick).

    I *think* the way to get around this is to implement a post processor and get access to the jfree object and change the scaling on the xaxis at present i have no post processor in the code at all:


    • rionheart

      You'll definitely need a ChartPostProcessor to do that sort of customization, though I've never encountered ellipses in place of an axis label before... it's very possible you have some other problem.  Have you tried setting the width of your chart *very* wide and see if the problem persists? 

      Usually, if there is not enough room along the x-axis to draw the labels without overlapping, the chart will automatically choose to a larger time interval, like every 2 days or every week, at which to draw labels.  It should choose the smallest interval that will allow the labels to fit without overlapping each other.

      I haven't used bar graphs at all, but at least with timeseries line charts, I know of no way to explicity skip over every N x-values.  I suppose you could filter out this data from inside your DatasetProducer.  If the labels are all that you're having a problem with, it's also might be helpful to read up on org.jfree.chart.axis.TickUnits. 

      As a little code example, I do something like this in my ChartPostProcessor:

      TickUnits tickIntervals = (TickUnits)DateAxis.createStandardDateTickUnits();
      tickIntervals.add( new DateTickUnit( DateTickUnit.DAY,2 ) );
      tickIntervals.add( new DateTickUnit( DateTickUnit.DAY,3 ) );
      DateAxis xAxis = (DateAxis)plot.getDomainAxis();

      This is for an xyline chart, so it may or may not apply, but it essentially adds additional intervals at which x-axis ticks (and labels) can be drawn... every 2 days and every 3 days in this example.

      Hope this helps.

    • Drake

      Thanks very much am chasing this up currently. Will post findings in here as soon as progress is made.