org.moxieapps.gwt.highcharts.client
Class Configurable<T>

java.lang.Object
  extended by org.moxieapps.gwt.highcharts.client.Configurable<T>
Direct Known Subclasses:
Animation, Axis, AxisTitle, BaseGaugePart, Button, ChartSubtitle, ChartTitle, Color, ColorAxis, Credits, DataGrouping, DateTimeLabelFormats, Drilldown, Exporting, Frame, Frame.FramePanel, Global, Highcharts.Options, LabelItem, Labels, Lang, Legend, Loading, MapNavigation, Marker, Navigation, Navigator, NoData, Options3D, Pane, PaneBackground, PlotBand, PlotBandLabel, PlotLine, PlotLineLabel, PlotOptions, Point, Position, RangeSelector, RangeSelector.Button, ResetZoomButton, Scrollbar, Series, Style, Theme, ToolTip, TreemapPlotOptions.Level, Zone

public abstract class Configurable<T>
extends Object

A common base class that any of the objects which support configuration options will extend to allow the caller to set the options on them. Provides a convenient setOption(String, Object) method that will allow for a configuration option to be set at any level.

Since:
1.0.0
Author:
squinn@moxiegroup.com (Shawn Quinn)

Constructor Summary
Configurable()
           
 
Method Summary
 com.google.gwt.json.client.JSONObject getOptions()
          Retrieve all of the options that have been configured for this instance as a JSONObject.
 T setOption(String path, Object value)
          Set an option on the object at any level, using "/" characters to designate which level of option you'd like to set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configurable

public Configurable()
Method Detail

setOption

public T setOption(String path,
                   Object value)
Set an option on the object at any level, using "/" characters to designate which level of option you'd like to set. E.g., the following code:

 Chart chart = new Chart();
 chart.setOption("/chart/type", "spline");
 chart.setOption("/chart/marginRight", 10);
 chart.setOption("/title/text", "Nice Chart");
 
Would result in initializing HighCharts like the following:

 new HighCharts.Chart({
     chart: {
         type: "spline",
         marginRight: 10
     },
     title: {
         text: "Nice Chart"
     }
 });
 
Note that the beginning "/" is optional, so chart.setOption("/thing", "piglet") is equivalent to chart.setOption("thing", "piglet").

For details on available options see the Highcharts reference.

Note that, when possible, you'll ideally want to use one of the available type specific setter methods instead of this general method. E.g. instead of doing this:


 series.setOption("type", "spline");
 
Do this instead:

 series.setType(Series.Type.SPLINE);
 

Parameters:
path - The path to the option to set (e.g. "/title/text");
value - The value to set for the option (can be a String, Number, Boolean, or JSONObject)
Returns:
A reference to this Configurable instance for convenient method chaining.

getOptions

public com.google.gwt.json.client.JSONObject getOptions()
Retrieve all of the options that have been configured for this instance as a JSONObject.

Returns:
A JSONObject representing all of the configuration options that have been set on the instance (will be null if no options have been set)


Copyright © 2015. All Rights Reserved.