Oops Null Pointer

Java programming related

Monthly Archives: May 2010

GXT Charts cutting off the y-axis labels

I was having issues with GXT charts deeply embedded in a hierarchy (chart -> ContentPanel -> Portlet -> Portal -> TabPanel -> Window) where the y axis labels where truncated for long strings.

Oringinally I was adding spaces to the labels but causes OFC to add about 10-15 extra steps when using a bar chart will all values less than zero.
So instead I add the chart, set the chart model, remove the chart, then add it again before laying out the panel.

Actually this is a bug in the OFC source. Here is the explanation and the fix.

You need to patch and recompile the swf used for the charts – and below I have provided the way to do it and attached the fixed open-flash-chart.swf file itself

This bug in OFC 2 is mentioned in a few other places:here and here

Here are the details of the issue and the fix:

GXT uses a patched version of OFC2: “2 Ichor Patched by DZ”.
This version has a bug that YAxis labels > 1,000,000 get cut of. If you resize the container of the chart then the labels get fixed.

The latest version of OFC (trunk) is missing some DZ patches (e.g. tooltips show if value is “”) and also potentially not the full font range for unicode.

The GXT version of DZ’s OFC is [B]not[/B] the same as the source code of this version from DZ’s website. The version from his site has another bug – the tooltips do not disappear on mouse out.

Here is how to build a version that fixes the tooltip problem and the truncation issue

Building from source: (See also this link)

Download FlashDevelop – install

  • best location is C:\OFC\FlashDevelop otherwise you will have to edit the path in FullFont.xml and PartialFont.xml in the \obj fir of DZ’s OFC source

Get and install flex sdk 3

  • Get Flex sdk v3
  • Unzip flex sdk
  • Add the bin flex bin dir to your path
  • Copy msvcr71.dllto bin dir of flex

Get source code for DZ’s OFChere

Fix bugs!

  • main.as – Move the line this.set_the_stage() to above the this.find_data() line
  • tooltip.as – The hide method is broken – either uncomment the tween line or manually add a call to hideAway
  • edit the build.bat file and change XAxisLabels-NoUnicodeRange.as and XAxisLabels-UnicodeRange.as to use underscores instead of dashes
  • edit the build.bat file and REM out the line that copies the SWF to a xampp dir

Compile and deploy

  • cd to the open-flash-chart main dir (has the main.as file)
  • from the cmd line run build.bat
  • Rename the open-flash-chart-full-embedded-font.swf to open-flash-chart.swf
  • Copy into the war\lib\gxt\charts dir replacing the existing version

Clear you browser cache or else the new swf will not be picked up.

For a link to the bug report and the swf file see here
Email me / comment if you need more info.

Time stamps in ant

Just putting this here so I don’t forget this neat trick to get timestamps in ant

<macrodef name="ShowTimestamp">
  <sequential>
    <tstamp>
      <format property="current.time" pattern="dd/MM/yyyy HH:mm:ss.SSS"/>
    </tstamp>
    <echo message="${current.time}"/>
  </sequential>
</macrodef>

Call with <ShowTimestamp/>

See the original discussion