Menu

jfreechart/cewolf - clickable x-axis labels

Help
2006-08-24
2013-01-13
  • Jason Krottner

    Jason Krottner - 2006-08-24

    I've seen examples how how to make x-axis labels clickable with jfreechart (using TickLabelEntity - http://www.jfree.org/phpBB2/viewtopic.php?t=15863&highlight=ticklabelentity\). 

    However, I don't think this method applies to cewolf use.  Is there another way?

    Thanks,

    Jason

     
    • Zoltan Luspai

      Zoltan Luspai - 2006-08-27

      Jason,

      It is -almost- possible with cewolf, I've just added support for this in the head; however it is a bit complicated. What you'd need to do is:
      1. everything in this example up to the line "ChartRenderingInfo info = new ChartRenderingInfo()" would need to go into a ChartPostProcessor's processChart(...) method, which would prepare your chart as you wish.
      2. Now we need to get the ChartRenderingInfo object, which is only available in Cewolf when the page was rendered. To access this ChartRenderingInfo object previous ChartPosprocessor should implement the ChartImageRenderListener interface.
      This has an event handler method called after the image is rendered, and the ChartRenderingInfo can be get as:

      public void onImageRendered (RenderedImage renderedImage) {
                ChartRenderingInfo info = (ChartRenderingInfo) renderedImage.renderingInfo;
                ...
         }

      3. Inside this onImageRendered method you can create the links/tooltips on the x-axis labels. So put of the code which work on the ChartRenderingInfo here.
      4. The last problem to solve is that we need to use the JFree way to render the customized links, which is the missing last part:
      //write image map:
      ImageMapUtilities.writeImageMap(someWriter, "imageMap", info);

      The problem with Cewolf is that we can not use this directly, because the image is rendered lazyly in Cewolf; only when the browser pulls it or when the <cewolf:map> tag triggers it.
      So I had to modify the cewolf:map tag, now it has a new option to render links in JFreechart way, this is:
      <cewolf:img ....>
      <cewolf:map useJFreeChartMapGenerator="true" />
      </cewolf:img>

      But you'll need to check out the latest Cewolf sources from SVN, and build it yourself, because this feature has not been released yet!

      Regards,
      Zoltan

       
    • Jason Krottner

      Jason Krottner - 2006-08-29

      Thanks for your help Zoltan.

      Before you responded I managed to get this by doing the following:

      1. My ChartPostProcessor implemented the ChartImageRenderListener  interface (and public void onImageRendered (RenderedImage renderedImage).
      2. Modified ChartMapTag.java to handle a TickLabelEntity

       

Log in to post a comment.