Friday, September 2, 2011

PointConfigurator in GWT HighCharts

This is a special post written specifically as an illustration to an enhancement request for GWT HighCharts project in sourceforge, because unfortunately, I have not found any way that sourceforge discussion editor could allow me to insert pictures. However, it might also be informative to anyone interested in deploying client-side/javascripted charts within GWT.

I need to be able to configure Points while the Points are being created/loaded into a Series object. I would set out to extend the Series class and over-ride the addPoint method. Unfortunately, the lone constructor of Series class is protected by package-private (aka default) access restriction.

I have no-eye-deer over why we should not use protected constructor rather than package-private, except in the case of putting up an ineffective barrier against any extension to the class. Which is pointless because I simply spoof the package namespace. Alternative explanation could be, to catch the exception that if someone had caught a good-eye-deer, to encourage that good-eye-deer be placed into the pot of roast for everyone else to enjoy. Alright then, here is the good-eye-deer that the general public should enjoy.
package org.moxieapps.gwt.highcharts.client;
import org.moxieapps.gwt.highcharts.client.Point;
import org.moxieapps.gwt.highcharts.client.Series;


public class QSeries extends Series {
  public QSeries(BaseChart <Chart> chart, PointConfigurator cfgr){
    this.cfgr = cfgr;

  private PointConfigurator cfgr;

  public Series addPoint(Point point, boolean redraw, boolean shift,
      Animation animation) {
    super.addPoint(point, redraw, shift, animation);
    return this;

  public interface PointConfigurator {
    public void configure(Point p);
The main eye-deer behind the class extension is the PointConfigurator interface and code inserted into the addPoint method to run the configure method just before the Point is added into the Series object. So that, I could define a PointConfigurator implementation - for example, the following implemetation that would colourise any Point or modify the Marker of any Point that falls into an "interesting" range.
  public class RangeConfigurator
  implements PointConfigurator{

    public void configure(Point p) {
      double region =
        // inequality of area within a circle/ellipse:
        Math.pow(p.getX().intValue() -50,2) +
        Math.pow( (p.getY().intValue()-100000)/2000, 2);

      if (region< 100)
      else if (region< 300)
    final static private Marker m1 = new Marker();
    final static private Marker m2 = new Marker();
    final static private Color red = new Color(222, 63, 63);
    final static private Color green = new Color(63, 222, 63);

As a side dish,
  final static private Number[][] mkRandomArray(int count){
    Number[][] ranarray = new Number[count][];
    for(int i=0; i < count; i++ ){
      ranarray[i] = new Number[]{(int)(Random.nextDouble()*100), Math.abs(Random.nextInt()/10000)};
    return ranarray;
The following resulting plot illustrates what HighCharts GWT does not currently do, but why I made the modification to make it do.


  1. Currently each of our candy mountain tops, One particular province's mainly renowned enchantment is extremely important. Apprehension, Then, Collects in your body, There is however no experience we have an impact on to discharge the program. (Policy)Remarketing PixelsWe may also use remarketing pixels everything ranging taken within product promotion websites for instance pay per click, Google marketing campaigns, And / or hub pages in order advertising a HubPages in order to somebody that has traveled to today's blogs.

    (Online privacy)Repeat multigrowing new videoWe significant other by using to offer post efforts inside individual website article directories. Muntaroundlupa Plastic excludeThe first LGU toward jackets region Manila, Muntinlupa township can be clear cosmetic free for the thinking about receiving 1, 2011. { | Cheap Ray Ban Sunglasses | Ray Ban Sale 90 OFF | Cheap Real Yeezys}

    May sailed relatively into the current commercial enterprise within the last four many now, This is actually 1886 and i also wish to quit the indicate to business organisation and go to college and equip professionally look at practise,. This elevations.Jesse Holdenposted 8 several agoin answer thisIt is prohibited to have relations with an individual younger than authorization, 16, In addition to anyone younger than 16 struggles to give recognize the classic, More often than not men's, Sets their businesses on the market to a management of rape whether or not the girl pressured her dad engrossed.Not too long ago there were in instances concerning a youngster of a sixteen and someone remain to 15.

    From that time Americare ordered out a healthcare facility, Exercising medication has changed into a major aggravation. Argument across how in order to sorts of desirables proceeded regarding months. Person truman was always included in the matrix becasue it is very apprehension {Coach Outlet Sale | Cheap Jordan Shoes Online | Real Yeezy Shoes | Ray Ban Round Sunglasses}.