From c15e57fc40cb1a41d75a236badf61c3623d7c245 Mon Sep 17 00:00:00 2001
From: Axel Uhl
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Animation extends Configurable
+ * chart.setAnimation(
+ * new Animation()
+ * .setDuration(100)
+ * .setEasing(Animation.Easing.LINEAR)
+ * );
+ *
+ *
+ * @param duration The duration of the animation in milliseconds.
+ * @return A reference to this {@link Animation} instance for convenient method chaining.
+ */
+ public Animation setDuration(Number duration) {
+ return this.setOption("duration", duration);
+ }
+
+ /**
+ * Convenience method for setting the 'easing' option of the animation. Equivalent to:
+ *
+ * animation.setOption("duration", 500);
+ *
+ * Note that more easing functions are available using
+ * jQuery plugins, in which case
+ * you'll want to use the {@link #setEasing(String)} method instead.
+ *
+ * @param easing The type of easing transition that you would like animations to use (the default is {@link Animation.Easing#SWING});
+ * @return A reference to this {@link Animation} instance for convenient method chaining.
+ */
+ public Animation setEasing(Easing easing) {
+ return this.setOption("easing", easing.toString());
+ }
+
+ /**
+ * Convenience method for setting the 'easing' option of the animation. Equivalent to:
+ *
+ * animation.setOption("easing", "linear");
+ *
+ * Note that this method is primarily intended to be used when you're using a
+ * jQuery plugin to support additional
+ * easing types. If you're just using standard jQuery easing types you'll want to use the
+ * {@link #setEasing(Animation.Easing)} method instead.
+ *
+ * @param easing The type of easing transition that you would like animations to use (the default is "swing");
+ * @return A reference to this {@link Animation} instance for convenient method chaining.
+ */
+ public Animation setEasing(String easing) {
+ return this.setOption("easing", easing);
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Axis.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Axis.java
new file mode 100755
index 00000000000..a0e2cbccc8a
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Axis.java
@@ -0,0 +1,1095 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.json.client.JSONObject;
+import com.google.gwt.json.client.JSONValue;
+
+/**
+ * The base class for both the X and Y axis types, which allows for general options to be set via
+ * the inherited {@link Configurable#setOption(String, Object)} method. But also exposes type
+ * specific methods that the caller is encouraged to use instead, such as
+ * {@link #setAllowDecimals(boolean)}, {@link #setAlternateGridColor(String)}, etc.
+ *
+ * Note that you won't normally work with this class directly, but instead one of it's sub-types
+ * such as {@link XAxis} or {@link YAxis}.
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public abstract class Axis
+ * animation.setOption("easing", "linear");
+ *
+ * Whether to allow decimals in this axis' ticks. When counting integers, like persons or
+ * hits on a web page, decimals must be avoided in the axis tick labels. Defaults to true.
+ *
+ * @param allowDecimals Whether to allow decimals in this axis' ticks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setAllowDecimals(boolean allowDecimals) {
+ return this.setOption("allowDecimals", allowDecimals);
+ }
+
+ /**
+ * Convenience method for setting the 'alternateGridColor' option for the axis. Equivalent to:
+ *
+ * axis.setOption("allowDecimals", false);
+ *
+ * When using an alternate grid color, a band is painted across the plot area between every
+ * other grid line. Defaults to null.
+ *
+ * @param alternateGridColor The color to use as the alternate grid color.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setAlternateGridColor(String alternateGridColor) {
+ return this.setOption("alternateGridColor", alternateGridColor);
+ }
+
+ /**
+ * Convenience method for setting the 'dateTimeLabelFormats' options of the axis. Equivalent to code like:
+ *
+ * axis.setOption("alternateGridColor", "#CC0000");
+ *
+ * For a datetime axis, the scale will automatically adjust to the appropriate unit. This configuration
+ * option sets the default string format representations used for each unit. For an overview of the
+ * replacement codes available see the javadoc on the {@link DateTimeLabelFormats} class. Defaults to:
+ *
+ * axis.setOption("/dateTimeLabelFormats/second", "%H:%M:%S");
+ * axis.setOption("/dateTimeLabelFormats/minute", "%H:%M");
+ *
+ *
+ * Example usage:
+ *
+ *
+ * @param dateTimeLabelFormats The formats to use for time series information on this axis.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setDateTimeLabelFormats(DateTimeLabelFormats dateTimeLabelFormats) {
+ return this.setOption("dateTimeLabelFormats", dateTimeLabelFormats != null ? dateTimeLabelFormats.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'endOnTick' option for the axis. Equivalent to:
+ *
+ * axis.setDateTimeLabelFormats(
+ * new DateTimeLabelFormats()
+ * .setHour("%I %p")
+ * .setMinute("%I:%M %p")
+ * );
+ *
+ * Whether to force the axis to end on a tick. Use this option with the maxPadding option to
+ * control the axis end. Defaults to false.
+ *
+ * @param endOnTick Whether to force the axis to end on a tick.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setEndOnTick(boolean endOnTick) {
+ return this.setOption("endOnTick", endOnTick);
+ }
+
+ // TODO: Add support for events
+
+ /**
+ * Set the minimum and maximum of the axes after render time using the default animation options.
+ * If the startOnTick and endOnTick options are true, the minimum and maximum values are rounded
+ * off to the nearest tick. To prevent this, these options can be set to false before calling this method.
+ *
+ * Also note that this method will use the default chart animation options when changing the extremes.
+ * To control the animation more specifically use the {@link #setExtremes(Number, Number, boolean, boolean)}
+ * or {@link #setExtremes(Number, Number, boolean, Animation)} method instead.
+ *
+ * @param min The new minimum value.
+ * @param max The new maximum value.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setExtremes(Number min, Number max) {
+ return this.setExtremes(min, max, true, true);
+ }
+
+ /**
+ * Set the minimum and maximum of the axes after render time, controlling the redraw and animation
+ * status. If the startOnTick and endOnTick options are true, the minimum and maximum values are
+ * rounded off to the nearest tick. To prevent this, these options can be set to false before calling this method.
+ *
+ * The gain more control over the animation used when the extremes are changed, use the
+ * {@link #setExtremes(Number, Number, boolean, Animation)} method instead.
+ *
+ * @param min The new minimum value.
+ * @param max The new maximum value.
+ * @param redraw 'true' to force the chart to redraw immediately, or 'false' to wait until the
+ * {@link Chart#redraw()} method is invoked.
+ * @param animation When 'true', the chart updating will be animated with default animation options.
+ * Note, use the {@link #setExtremes(Number, Number, boolean, Animation)} method
+ * for more control over the animation options.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setExtremes(Number min, Number max, boolean redraw, boolean animation) {
+ return setExtremes(min, max, redraw, animation ? new Animation() : null);
+ }
+
+ /**
+ * Set the minimum and maximum of the axes after render time, controlling the redraw and animation
+ * options. If the startOnTick and endOnTick options are true, the minimum and maximum values are
+ * rounded off to the nearest tick. To prevent this, these options can be set to false before calling this method.
+ *
+ * This method is intended to be used for callers that need tight control over the animation that
+ * will run when the chart extremes are applied. If you don't need tight control over the animation
+ * you can use the {@link #setExtremes(Number, Number)} or {@link #setExtremes(Number, Number, boolean, boolean)}
+ * method instead.
+ *
+ * @param min The new minimum value.
+ * @param max The new maximum value.
+ * @param redraw 'true' to force the chart to redraw immediately, or 'false' to wait until the
+ * {@link Chart#redraw()} method is invoked.
+ * @param animation Custom animation to use when the chart extremes are being updated.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setExtremes(Number min, Number max, boolean redraw, Animation animation) {
+ if (chart.isRendered()) {
+ // We'll update the axis live in the DOM if we've already been rendered
+ final JavaScriptObject nativeAxis = getNativeAxis();
+ if (nativeAxis != null) {
+ if (animation == null || animation.getOptions() == null) {
+ final boolean animationFlag = animation != null;
+ nativeSetExtremes(nativeAxis, min, max, redraw, animationFlag);
+ } else {
+ final JavaScriptObject animationOptions = animation.getOptions().getJavaScriptObject();
+ nativeSetExtremes(nativeAxis, min, max, redraw, animationOptions);
+ }
+ }
+ } else {
+ // If we're called before the chart has been rendered, then just track the min/max as a configuration option
+ this.setMin(min).setMax(max);
+ }
+ return getThis();
+ }
+
+ /**
+ * Return a non-null object that represents the current extremes for the axis. Note that if this method
+ * is invoked before the chart has been rendered, only the configured min/max values will be known.
+ *
+ * @return The current extremes for the axis.
+ */
+ public Extremes getExtremes() {
+
+ Extremes extremes = null;
+
+ if (chart.isRendered()) {
+ // If we've already been rendered, we can ask the running chart for it's actual extremes
+ final JavaScriptObject nativeAxis = getNativeAxis();
+ if (nativeAxis != null) {
+ final JavaScriptObject nativeExtremes = nativeGetExtremes(nativeAxis);
+ if (nativeExtremes != null) {
+ JSONObject jsonExtremes = new JSONObject(nativeExtremes);
+ extremes = new Extremes(
+ getNumberFromJSONObject(jsonExtremes, "dataMin"),
+ getNumberFromJSONObject(jsonExtremes, "dataMax"),
+ getNumberFromJSONObject(jsonExtremes, "min"),
+ getNumberFromJSONObject(jsonExtremes, "max")
+ );
+ }
+ }
+ }
+
+ // If we haven't been rendered (or for some reason we can't get to the native object), then
+ // all we know if whatever configuration options were set manually
+ if (extremes == null) {
+ extremes = new Extremes(null, null, this.min, this.max);
+ }
+ return extremes;
+ }
+
+ protected JavaScriptObject getNativeAxis() {
+ return chart.get(this.id);
+ }
+
+ // Save some typing in the getExtremes() method
+ private Number getNumberFromJSONObject(JSONObject jsonObject, String key) {
+ JSONValue jsonValue = jsonObject.get(key);
+ if (jsonValue.isNumber() != null) {
+ return jsonValue.isNumber().doubleValue();
+ }
+ return null;
+ }
+
+ /**
+ * Convenience method for setting the 'gridLineColor' option for the axis. Equivalent to:
+ *
+ * axis.setOption("endOnTick", true);
+ *
+ * Color of the grid lines extending the ticks across the plot area. Defaults to "#C0C0C0".
+ *
+ * @param gridLineColor Color of the grid lines extending the ticks across the plot area.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setGridLineColor(String gridLineColor) {
+ return this.setOption("gridLineColor", gridLineColor);
+ }
+
+ /**
+ * Convenience method for setting the 'gridLineDashStyle' axis option. Equivalent to:
+ *
+ * axis.setOption("gridLineColor", "#CCCCCC");
+ *
+ * The dash or dot style of the grid lines. Defaults to DashStyle.DOT. See this
+ * demonstration for a visible reference
+ * of the available dash styles.
+ *
+ * @param gridLineDashStyle Sets the dash or dot style of the grid lines, or null to return to the default.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setGridLineDashStyle(PlotLine.DashStyle gridLineDashStyle) {
+ return this.setOption("gridLineDashStyle", gridLineDashStyle != null ? gridLineDashStyle.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'gridLineWidth' option for the axis. Equivalent to:
+ *
+ * plotOptions.setOption("gridLineDashStyle", PlotOptions.DashStyle.LONG_DASH);
+ *
+ * The width of the grid lines extending the ticks across the plot area. Defaults to 0.
+ *
+ * @param gridLineWidth The new width of the grid lines extending the ticks across the plot area.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setGridLineWidth(Number gridLineWidth) {
+ return this.setOption("gridLineWidth", gridLineWidth);
+ }
+
+ /**
+ * Convenience method for setting the 'lineColor' option for the axis. Equivalent to:
+ *
+ * axis.setOption("gridLineWidth", 2);
+ *
+ * The color of the line marking the axis itself. Defaults to "#C0D0E0".
+ *
+ * @param lineColor The new color of the line marking the axis itself.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setLineColor(String lineColor) {
+ return this.setOption("lineColor", lineColor);
+ }
+
+ /**
+ * Convenience method for setting the 'lineWidth' option for the axis. Equivalent to:
+ *
+ * axis.setOption("lineColor", "#00CC00");
+ *
+ * The width of the line marking the axis itself. Defaults to 1.
+ *
+ * @param lineWidth The new width of the line marking the axis itself.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setLineWidth(Number lineWidth) {
+ return this.setOption("lineWidth", lineWidth);
+ }
+
+ /**
+ * Convenience method for setting the 'linkedTo' option for the axis. Equivalent to:
+ *
+ * axis.setOption("lineWidth", 2);
+ *
+ * Index of another axis that this axis is linked to. When an axis is linked to a master
+ * axis, it will take the same extremes as the master, but as assigned by
+ * {@link #setMin(Number)} or {@link #setMax(Number)} or
+ * by {@link #setExtremes(Number, Number)}. It can be used to show additional info, or
+ * to ease reading the chart by duplicating the scales. Defaults to null.
+ *
+ * @param linkedTo The index of another axis that this axis is linked to.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setLinkedTo(Number linkedTo) {
+ return this.setOption("linkedTo", linkedTo);
+ }
+
+ private Number max;
+
+ /**
+ * Convenience method for setting the 'max' option for the axis. Equivalent to:
+ *
+ * axis.setOption("linkedTo", 2);
+ *
+ * The maximum value of the axis. If null, the max value is automatically calculated. If
+ * the {@link #setEndOnTick(boolean)} option is true, the max value might be rounded up.
+ * The actual maximum value is also influenced by {@link Chart#setAlignTicks(boolean)}
+ * setting. Defaults to null.
+ *
+ * Note that this method will only affect the maximum value of the chart before it is rendered.
+ * To change the min/max value of the chart after render time use the {@link #setExtremes(Number, Number)}
+ * method instead.
+ *
+ * @param max The maximum value of the axis, or null to automatically calculate the maximum.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMax(Number max) {
+ this.max = max;
+ return this.setOption("max", max);
+ }
+
+ /**
+ * Convenience method for setting the 'maxPadding' option for the axis. Equivalent to:
+ *
+ * axis.setOption("max", 100);
+ *
+ * Padding of the max value relative to the length of the axis. A padding of 0.05 will make a
+ * 100px axis 5px longer. This is useful when you don't want the highest data value to appear
+ * on the edge of the plot area. When the axis' max option is set or a max extreme is set
+ * using {@link #setExtremes(Number, Number)}, the maxPadding will be ignored. Defaults to 0.01.
+ *
+ * @param maxPadding The new padding of the max value relative to the length of the axis.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMaxPadding(Number maxPadding) {
+ return this.setOption("maxPadding", maxPadding);
+ }
+
+ /**
+ * Convenience method for setting the 'maxZoom' option for the axis. Equivalent to:
+ *
+ * axis.setOption("maxPadding", 0.05);
+ *
+ * The maximum amount of zoom on this axis. The entire axis will not be allowed to span over
+ * a smaller interval than this. For example, for a datetime axis the main unit is milliseconds.
+ * If maxZoom is set to 3600000, you can't zoom in more than to one hour.
+ *
+ * @param maxZoom The new maximum amount of zoom on this axis.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMaxZoom(Number maxZoom) {
+ return this.setOption("maxZoom", maxZoom);
+ }
+
+ private Number min;
+
+ /**
+ * Convenience method for setting the 'max' option for the axis. Equivalent to:
+ *
+ * axis.setOption("maxZoom", 5);
+ *
+ * The minimum value of the axis. If null, the min value is automatically calculated. If
+ * the {@link #setStartOnTick(boolean)} option is true, the min value might be rounded down.
+ * Defaults to null.
+ *
+ * Note that this method will only affect the minimum value of the chart before it is rendered.
+ * To change the min/max value of the chart after render time use the {@link #setExtremes(Number, Number)}
+ * method instead.
+ *
+ * @param min The maximum value of the axis, or null to automatically calculate the maximum.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMin(Number min) {
+ this.min = min;
+ return this.setOption("min", min);
+ }
+
+ /**
+ * Convenience method for setting the 'minorGridLineColor' option for the axis. Equivalent to:
+ *
+ * axis.setOption("min", 10);
+ *
+ * Color of the minor, secondary grid lines. Defaults to #E0E0E0.
+ *
+ * @param minorGridLineColor The new color of the minor, secondary grid lines.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorGridLineColor(String minorGridLineColor) {
+ return this.setOption("minorGridLineColor", minorGridLineColor);
+ }
+
+ /**
+ * Convenience method for setting the 'minorGridLineDashStyle' axis option. Equivalent to:
+ *
+ * axis.setOption("minorGridLineColor", "#00CC00");
+ *
+ * The dash or dot style of the grid lines. Defaults to DashStyle.SOLID. See this
+ * demonstration for a visible reference
+ * of the available dash styles.
+ *
+ * @param minorGridLineDashStyle Sets the dash or dot style of the minor grid lines, or null to return to the default.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorGridLineDashStyle(PlotLine.DashStyle minorGridLineDashStyle) {
+ return this.setOption("minorGridLineDashStyle", minorGridLineDashStyle != null ? minorGridLineDashStyle.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'minorGridLineWidth' option for the axis. Equivalent to:
+ *
+ * plotOptions.setOption("minorGridLineDashStyle", PlotOptions.DashStyle.LONG_DASH);
+ *
+ * The width of the minor, secondary grid lines. Defaults to 1.
+ *
+ * @param minorGridLineWidth The new width of the minor, secondary grid lines.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorGridLineWidth(Number minorGridLineWidth) {
+ return this.setOption("minorGridLineWidth", minorGridLineWidth);
+ }
+
+ /**
+ * Convenience method for setting the 'minorTickColor' option for the axis. Equivalent to:
+ *
+ * axis.setOption("minorGridLineWidth", 2);
+ *
+ * Color for the minor tick marks. Defaults to #A0A0A0.
+ *
+ * @param minorTickColor The new color for the minor tick marks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorTickColor(String minorTickColor) {
+ return this.setOption("minorTickColor", minorTickColor);
+ }
+
+ /**
+ * Convenience method for setting the 'minorTickInterval' option for the axis. Equivalent to:
+ *
+ * axis.setOption("minorTickColor", "#00CC00");
+ *
+ * Tick interval in scale units for the minor ticks. If null, minor ticks are not shown. Defaults to null.
+ * Note that if you instead call the {@link #setMinorTickIntervalAuto()} method
+ * the minor tick interval is calculated as a fifth of the tickInterval.
+ *
+ * @param minorTickInterval The new tick interval in scale units for the minor ticks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorTickInterval(Number minorTickInterval) {
+ return this.setOption("minorTickInterval", minorTickInterval);
+ }
+
+ /**
+ * Convenience method for setting the 'minorTickInterval' option for the axis to auto. Equivalent to:
+ *
+ * axis.setOption("minorTickInterval", 2);
+ *
+ * Note, if you instead want to set the tick interval to a specific numeric value (or disable the
+ * ticks completely), you'll want to use the {@link #setMinorTickInterval(Number)} method.
+ *
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorTickIntervalAuto() {
+ return this.setOption("minorTickInterval", "auto");
+ }
+
+ /**
+ * Convenience method for setting the 'minorTickLength' option for the axis. Equivalent to:
+ *
+ * axis.setOption("minorTickInterval", "auto");
+ *
+ * The pixel length of the minor tick marks. Defaults to 2.
+ *
+ * @param minorTickLength The new pixel length of the minor tick marks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorTickLength(Number minorTickLength) {
+ return this.setOption("minorTickLength", minorTickLength);
+ }
+
+ /**
+ * Convenience method for setting the 'minorTickPosition' option for the axis. Equivalent to:
+ *
+ * axis.setOption("minorTickLength", 4);
+ *
+ * The position of the minor tick marks relative to the axis line. Defaults to {@link Axis.TickPosition#OUTSIDE}.
+ *
+ * @param minorTickPosition The new position of the minor tick marks relative to the axis line,
+ * or null to return to the default.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorTickPosition(TickPosition minorTickPosition) {
+ return this.setOption("minorTickPosition", minorTickPosition != null ? minorTickPosition.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'minorTickWidth' option for the axis. Equivalent to:
+ *
+ * axis.setOption("minorTickPosition", TickPosition.INSIDE);
+ *
+ * The pixel width of the minor tick mark. Defaults to 0.
+ *
+ * @param minorTickWidth The new pixel width of the minor tick mark.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinorTickWidth(Number minorTickWidth) {
+ return this.setOption("minorTickWidth", minorTickWidth);
+ }
+
+ /**
+ * Convenience method for setting the 'minPadding' option for the axis. Equivalent to:
+ *
+ * axis.setOption("minorTickWidth", 4);
+ *
+ * Padding of the min value relative to the length of the axis. A padding of 0.05 will make a
+ * 100px axis 5px longer. This is useful when you don't want the highest data value to appear
+ * on the edge of the plot area. When the axis' min option is set or a max extreme is set
+ * using {@link #setExtremes(Number, Number)}, the minPadding will be ignored. Defaults to 0.01.
+ *
+ * @param minPadding The new padding of the min value relative to the length of the axis.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setMinPadding(Number minPadding) {
+ return this.setOption("minPadding", minPadding);
+ }
+
+ /**
+ * Convenience method for setting the 'offset' option for the axis. Equivalent to:
+ *
+ * axis.setOption("minPadding", 0.05);
+ *
+ * The distance in pixels from the plot area to the axis line. A positive offset moves
+ * the axis with it's line, labels and ticks away from the plot area. This is typically
+ * used when two or more axes are displayed on the same side of the plot. Defaults to 0.
+ *
+ * @param offset The new distance in pixels from the plot area to the axis line.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setOffset(Number offset) {
+ return this.setOption("offset", offset);
+ }
+
+ /**
+ * Convenience method for setting the 'opposite' option for the axis. Equivalent to:
+ *
+ * axis.setOption("offset", 60);
+ *
+ * Whether to display the axis on the opposite side of the normal. The normal is on the
+ * left side for vertical axes and bottom for horizontal, so the opposite sides will be
+ * right and top respectively. This is typically used with dual or multiple axes. Defaults to false.
+ *
+ * @param opposite 'true' to display the axis on the opposite side of the normal, 'false'
+ * to show the axis on the normal side.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setOpposite(boolean opposite) {
+ return this.setOption("opposite", opposite);
+ }
+
+ /**
+ * Sets the 'plotLines' array for the axis. A plot line is a line stretching across the plot area,
+ * marking a specific value on one of the axes. Example usage:
+ *
+ * axis.setOption("opposite", true);
+ *
+ *
+ * @param plotLines One or more PlotLine instances that represent the options of each line to render
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setPlotLines(PlotLine... plotLines) {
+ return this.setOption("plotLines", plotLines);
+ }
+
+ /**
+ * Sets the 'plotBands' array for the axis. A plot band is a colored band stretching across the plot
+ * area marking an interval on the axis. Example usage:
+ *
+ * XAxis xAxis = chart.getXAxis()
+ * xAxis.getXAxis()
+ * .setPlotLines(
+ * xAxis.createPlotLine()
+ * .setColor("#CC0000")
+ * .setValue(40),
+ * xAxis.createPlotLine()
+ * .setColor("#009900")
+ * .setValue(60)
+ * )
+ * );
+ *
+ *
+ * @param plotBands One or more PlotBand instances that represent the options of each band to render
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setPlotBands(PlotBand... plotBands) {
+ return this.setOption("plotBands", plotBands);
+ }
+
+ /**
+ * Convenience method for setting the 'reversed' option for the axis. Equivalent to:
+ *
+ * XAxis xAxis = chart.getXAxis()
+ * .setPlotBands(
+ * xAxis.createPlotBand()
+ * .setColor("#CC0000")
+ * .setFrom(40)
+ * .setTo(80),
+ * xAxis.createPlotBand()
+ * .setColor("#009900")
+ * .setFrom(90)
+ * .setTo(120),
+ * )
+ * );
+ *
+ * Whether to reverse the axis so that the highest number is closest to origin. If the chart
+ * is inverted, the x axis is reversed by default. Defaults to false.
+ *
+ * @param reversed 'true' to reverse the axis so that the highest number is closest to origin, 'false'
+ * to show the axis in its default orientation.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setReversed(boolean reversed) {
+ return this.setOption("reversed", reversed);
+ }
+
+ /**
+ * Convenience method for setting the 'showFirstLabel' option for the axis. Equivalent to:
+ *
+ * axis.setOption("reversed", true);
+ *
+ * Whether to show the first tick label. Defaults to true.
+ *
+ * @param showFirstLabel 'true' to show the first tick label (the default), 'false' to hide it.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setShowFirstLabel(boolean showFirstLabel) {
+ return this.setOption("showFirstLabel", showFirstLabel);
+ }
+
+ /**
+ * Convenience method for setting the 'showLastLabel' option for the axis. Equivalent to:
+ *
+ * axis.setOption("showFirstLabel", false);
+ *
+ * Whether to show the last tick label. Defaults to false.
+ *
+ * @param showLastLabel 'true' to show the first tick label, 'false' to hide it (the default).
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setShowLastLabel(boolean showLastLabel) {
+ return this.setOption("showLastLabel", showLastLabel);
+ }
+
+ /**
+ * Convenience method for setting the 'startOfWeek' option for the axis. Equivalent to:
+ *
+ * axis.setOption("showLastLabel", true);
+ *
+ * For datetime axes, this decides where to put the tick between weeks. Defaults to 1 {@link Axis.WeekDay#MONDAY}.
+ *
+ * @param startOfWeek The day of the week where tick marks should be placed between weeks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setStartOfWeek(WeekDay startOfWeek) {
+ return this.setOption("startOfWeek", startOfWeek != null ? startOfWeek.toNumber() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'startOnTick' option for the axis. Equivalent to:
+ *
+ * axis.setOption("startOfWeek", WeekDay.SUNDAY);
+ *
+ * Whether to force the axis to start on a tick. Use this option with the
+ * {@link #setMaxPadding(Number)} option to control the axis start. Defaults to false.
+ *
+ * @param startOnTick 'true' to force the axis to start on a tick, 'false' for the default behavior.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setStartOnTick(boolean startOnTick) {
+ return this.setOption("startOnTick", startOnTick);
+ }
+
+ /**
+ * Convenience method for setting the 'tickColor' option for the axis. Equivalent to:
+ *
+ * axis.setOption("startOnTick", true);
+ *
+ * Color for the main tick marks. Defaults to #C0D0E0.
+ *
+ * @param tickColor The new color for the main tick marks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setTickColor(String tickColor) {
+ return this.setOption("tickColor", tickColor);
+ }
+
+ /**
+ * Convenience method for setting the 'tickInterval' option for the axis. Equivalent to:
+ *
+ * axis.setOption("tickColor", "#00CC00");
+ *
+ * The interval of the tick marks in axis units. When null, the tick interval is computed to
+ * approximately follow the tickPixelInterval on linear and datetime axes. On categorized axes, a
+ * null tickInterval will default to 1, one category. Note that datetime axes are based on milliseconds,
+ * so for example an interval of one day is expressed as 24 * 3600 * 1000. Defaults to null.
+ *
+ * @param tickInterval The interval of the tick marks in axis units, or null to follow the default interval logic.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setTickInterval(Number tickInterval) {
+ return this.setOption("tickInterval", tickInterval);
+ }
+
+ /**
+ * Convenience method for setting the 'tickLength' option for the axis. Equivalent to:
+ *
+ * axis.setOption("tickInterval", 5);
+ *
+ * The pixel length of the main tick marks. Defaults to 5.
+ *
+ * @param tickLength The new pixel length of the main tick marks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setTickLength(Number tickLength) {
+ return this.setOption("tickLength", tickLength);
+ }
+
+ /**
+ * Convenience method for setting the 'tickPixelInterval' option for the axis. Equivalent to:
+ *
+ * axis.setOption("tickLength", 20);
+ *
+ * If tickInterval is null (the default) this option sets the approximate pixel interval of the tick marks.
+ * Not applicable to categorized axis. Defaults to 72 for the Y axis and 100 for the X axis.
+ *
+ * @param tickPixelInterval The new approximate pixel interval of the tick marks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setTickPixelInterval(Number tickPixelInterval) {
+ return this.setOption("tickPixelInterval", tickPixelInterval);
+ }
+
+ /**
+ * Convenience method for setting the 'tickPosition' option for the axis. Equivalent to:
+ *
+ * axis.setOption("tickPixelInterval", 50);
+ *
+ * The position of the major tick marks relative to the axis line. Defaults to {@link Axis.TickPosition#OUTSIDE}.
+ *
+ * @param tickPosition The new position of the major tick marks relative to the axis line.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setTickPosition(TickPosition tickPosition) {
+ return this.setOption("tickPosition", tickPosition != null ? tickPosition.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'tickWidth' option for the axis. Equivalent to:
+ *
+ * axis.setOption("tickPosition", TickPosition.INSIDE);
+ *
+ * The pixel width of the major tick marks. Defaults to 1.
+ *
+ * @param tickWidth The new pixel width of the major tick marks.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setTickWidth(Number tickWidth) {
+ return this.setOption("tickWidth", tickWidth);
+ }
+
+ /**
+ * Convenience method for setting the 'title/text' axis option. Equivalent to:
+ *
+ * axis.setOption("tickWidth", 10);
+ *
+ * The actual text of the axis title. It can contain basic HTML text markup like
+ * <b>, <i> and spans with style. Defaults to null for the x-axis
+ * and "Y-values" for the y-axis.
+ *
+ * Note that for more control over the title, utilize the {@link #setAxisTitle(AxisTitle)}
+ * method instead.
+ *
+ * Also note that to hide an axis title completely, simply set the text to null.
+ *
+ * @param title Sets the title of axis, or null to hide the title.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setAxisTitleText(String title) {
+ return this.setOption("/title/text", title);
+ }
+
+ /**
+ * Convenience method for setting the 'title/text' axis option. Equivalent to:
+ *
+ * axis.setOption("/title/text", "A Fine Axis Indeed");
+ *
+ *
+ * Note that if you call this method it will overwrite any existing
+ * settings that have already been applied to the title (e.g. if you
+ * had previously called the {@link #setAxisTitleText(String)} method that change
+ * will get overwritten by this call.)
+ *
+ * Note that if you only want to change the text of the axis, you can simply
+ * use the {@link #setAxisTitleText(String)} method instead.
+ *
+ * @param title Sets the axis title options, or null to hide the title.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setAxisTitle(AxisTitle title) {
+ return this.setOption("/title", title != null ? title.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'type' axis option. Equivalent to:
+ *
+ * axis.setOption("/title/text", "A Fine Axis Indeed");
+ * axis.setOption("/title/align", AxisTitle.Align.HIGH);
+ *
+ * The type of axis. Can be one of "linear" or "datetime". In a datetime axis, the numbers are
+ * given in milliseconds, and tick marks are placed on appropriate values like full hours or days.
+ * Defaults to {@link Axis.Type#LINEAR}.
+ *
+ * @param type Sets the type of axis.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ */
+ public T setType(Type type) {
+ return this.setOption("type", type != null ? type.toString() : null);
+ }
+
+ /**
+ * Allows plot lines to be added to an axis after the chart is rendered. If you want to add
+ * plot lines to chart before it is rendered, please utilize the {@link #setPlotLines(PlotLine...)}
+ * method instead.
+ *
+ * @param plotLines One or more PlotLine instances that represent the options of each line to render
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ * @since 1.1.3
+ */
+ public T addPlotLines(PlotLine... plotLines) {
+ if (getNativeAxis() != null) {
+ for (PlotLine plotLine : plotLines) {
+ nativeAddPlotLine(getNativeAxis(), plotLine.getOptions().getJavaScriptObject());
+ }
+ } else {
+ setPlotLines(plotLines);
+ }
+ return getThis();
+ }
+
+ /**
+ * Allows plot bands to be added to an axis after the chart is rendered. If you want to add
+ * plot bands to chart before it is rendered, please utilize the {@link #setPlotBands(PlotBand...)}
+ * method instead.
+ *
+ * @param plotBands One or more PlotBand instances that represent the options of each band to render
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ * @since 1.1.3
+ */
+ public T addPlotBands(PlotBand... plotBands) {
+ if (getNativeAxis() != null) {
+ for (PlotBand plotBand : plotBands) {
+ nativeAddPlotBand(getNativeAxis(), plotBand.getOptions().getJavaScriptObject());
+ }
+ } else {
+ setPlotBands(plotBands);
+ }
+ return getThis();
+ }
+
+ /**
+ * Remove the given plot line from the chart after it has been rendered, automatically
+ * redrawing the chart after the plot line has been removed.
+ *
+ * @param plotLine The PlotLine instance to remove from the chart.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ * @since 1.1.3
+ */
+ public T removePlotLine(PlotLine plotLine) {
+ if (getNativeAxis() != null) {
+ nativeRemovePlotLine(getNativeAxis(), plotLine.getId());
+ } else {
+ // TODO: Add support for removing a plot line for the set before the chart is rendered
+ }
+ return getThis();
+ }
+
+ /**
+ * Remove the given plot band from the chart after it has been rendered, automatically
+ * redrawing the chart after the plot band has been removed.
+ *
+ * @param plotBand The PlotBand instance to remove from the chart.
+ * @return A reference to this {@link Axis} instance for convenient method chaining.
+ * @since 1.1.3
+ */
+ public T removePlotBand(PlotBand plotBand) {
+ if (getNativeAxis() != null) {
+ nativeRemovePlotBand(getNativeAxis(), plotBand.getId());
+ } else {
+ // TODO: Add support for removing a plot band for the set before the chart is rendered
+ }
+ return getThis();
+ }
+
+
+ // Handle the unchecked cast limitation with generics in one place
+ private T getThis() {
+ @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
+ final T instance = (T) this;
+ return instance;
+ }
+
+ private static native void nativeSetExtremes(JavaScriptObject axis, Number min, Number max, boolean redraw, boolean animation) /*-{
+ axis.setExtremes(min, max, redraw, animation);
+ }-*/;
+
+ private static native void nativeSetExtremes(JavaScriptObject axis, Number min, Number max, boolean redraw, JavaScriptObject animationOptions) /*-{
+ axis.setExtremes(min, max, redraw, animationOptions);
+ }-*/;
+
+ private static native JavaScriptObject nativeGetExtremes(JavaScriptObject axis) /*-{
+ return axis.getExtremes();
+ }-*/;
+
+ private native void nativeAddPlotLine(JavaScriptObject axis, JavaScriptObject plotLineOptions)/*-{
+ axis.addPlotLine(plotLineOptions);
+ }-*/;
+
+ private native void nativeAddPlotBand(JavaScriptObject axis, JavaScriptObject plotBandOptions)/*-{
+ axis.addPlotBand(plotBandOptions);
+ }-*/;
+
+ private native void nativeRemovePlotLine(JavaScriptObject axis, String id)/*-{
+ axis.removePlotLine(id);
+ }-*/;
+
+ private native void nativeRemovePlotBand(JavaScriptObject axis, String id)/*-{
+ axis.removePlotBand(id);
+ }-*/;
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/AxisTitle.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/AxisTitle.java
new file mode 100755
index 00000000000..5174a67791f
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/AxisTitle.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A configurable class that can be used to represent custom title options for an
+ * axis, which can then be set on a specific axis (via the {@link Axis#setAxisTitle(AxisTitle)} method.)
+ * Example usage:
+ *
+ * axis.setOption("type", Axis.Type.DATE_TIME);
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class AxisTitle extends Configurable
+ * chart.getXAxis().setAxisTitle(
+ * new AxisTitle()
+ * .setText("Sales by Month")
+ * .setAlign(AxisTitle.Align.MIDDLE)
+ * );
+ *
+ * Alignment of the title relative to the axis values. Possible values are "low", "middle" or "high".
+ * Defaults to {@link AxisTitle.Align#MIDDLE}.
+ *
+ * @param align The alignment of the title relative to the axis values.
+ * @return A reference to this {@link AxisTitle} instance for convenient method chaining.
+ */
+ public AxisTitle setAlign(Align align) {
+ return this.setOption("align", align != null ? align.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'margin' option of the title. Equivalent to:
+ *
+ * axisTitle.setOption("align", AxisTitle.Align.LOW);
+ *
+ * The pixel distance between the axis labels or line and the title. Defaults
+ * to 0 for horizontal axis, 10 for vertical axis.
+ *
+ * @param margin The pixel distance between the axis labels or line and the title.
+ * @return A reference to this {@link AxisTitle} instance for convenient method chaining.
+ */
+ public AxisTitle setMargin(Number margin) {
+ return this.setOption("margin", margin);
+ }
+
+ /**
+ * Convenience method for setting the 'margin' option of the title. Equivalent to:
+ *
+ * axisTitle.setOption("margin", 60);
+ *
+ * The rotation of the text in degrees. 0 is horizontal, 270 is vertical reading
+ * from bottom to top. Defaults to 0.
+ *
+ * @param rotation The rotation of the text in degrees.
+ * @return A reference to this {@link AxisTitle} instance for convenient method chaining.
+ */
+ public AxisTitle setRotation(Number rotation) {
+ return this.setOption("rotation", rotation);
+ }
+
+ /**
+ * Convenience method for setting the 'style' options of the axis title. Equivalent to:
+ *
+ * axisTitle.setOption("margin", 60);
+ *
+ * CSS styles for the title. When titles are rotated they are rendered using vector graphic techniques
+ * and not all styles are applicable. Most noteworthy, a bug in IE8 renders all rotated strings bold
+ * and italic. Defaults to:
+ *
+ * axisTitle.setOption("/style/fontWeight", "bold");
+ * axisTitle.setOption("/style/fontFamily", "serif");
+ * etc.
+ *
+ *
+ *
+ * @param style CSS styles for the axis title.
+ * @return A reference to this {@link AxisTitle} instance for convenient method chaining.
+ */
+ public AxisTitle setStyle(Style style) {
+ return this.setOption("style", style != null ? style.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'text' option of the title. Equivalent to:
+ *
+ * The actual text of the axis title. It can contain basic HTML text markup
+ * like <b>, <i> and spans with style. Defaults to null.
+ *
+ * Note to disable an axis title from being displayed completely, simply set the text
+ * to "null". (This can also be accomplished more simply by just setting the title
+ * text to null directly on the axis via the {@link Axis#setAxisTitleText(String)} method.)
+ *
+ * @param text The actual text of the axis title.
+ * @return A reference to this {@link AxisTitle} instance for convenient method chaining.
+ */
+ public AxisTitle setText(String text) {
+ return this.setOption("text", text);
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/BaseChart.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/BaseChart.java
new file mode 100755
index 00000000000..576ddd7ad34
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/BaseChart.java
@@ -0,0 +1,2356 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArray;
+import com.google.gwt.core.client.JsArrayString;
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.json.client.*;
+import com.google.gwt.user.client.ui.Widget;
+import org.moxieapps.gwt.highcharts.client.events.*;
+import org.moxieapps.gwt.highcharts.client.labels.AxisLabelsData;
+import org.moxieapps.gwt.highcharts.client.labels.DataLabelsData;
+import org.moxieapps.gwt.highcharts.client.labels.StackLabelsData;
+import org.moxieapps.gwt.highcharts.client.plotOptions.*;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * The common base class for both {@link Chart} types as well as {@link StockChart} types.
+ * You should not use this class directly, but instead create an instance of one of those
+ * sub types.
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @see Chart
+ * @see StockChart
+ * @since 1.0.0
+ */
+public abstract class BaseChart
+ * axisTitle.setOption("text", "Sales by Month");
+ *
+ * When using multiple axis, the ticks of two or more opposite axes will automatically be aligned
+ * by adding ticks to the axis or axes with the least ticks. This can be prevented by setting
+ * alignTicks to false. If the grid lines look messy, it's a good idea to hide them for the
+ * secondary axis by setting gridLineWidth to 0. Defaults to true.
+ *
+ * @param alignTicks The value to set as the 'alignTicks' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setAlignTicks(boolean alignTicks) {
+ return this.setOption("/chart/alignTicks", alignTicks);
+ }
+
+ /**
+ * Convenience method for setting the 'animation' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/alignTicks", false);
+ *
+ * Sets the overall animation for all chart updating. Animation can be disabled throughout
+ * the chart by setting it to false here. It can be overridden for each individual API
+ * method as a function parameter. The only animation not affected by this option is the
+ * initial series animation, see {@link org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions#setAnimation(boolean)} method for
+ * control over series animations that are added after the chart has been rendered.
+ *
+ * Note that more control over the animations is available by calling the
+ * {@link #setAnimation(Animation)} method instead.
+ *
+ *
+ * @param animation The value to set as the 'animation' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setAnimation(boolean animation) {
+ return this.setOption("/chart/animation", animation);
+ }
+
+ /**
+ * Convenience method for setting the 'animation' options of the chart. Equivalent to code like:
+ *
+ * chart.setOption("/chart/animation", true);
+ *
+ * Sets the overall animation for all chart updating. Animation can be disabled throughout
+ * the chart by setting it to false here. It can be overridden for each individual API
+ * method as a function parameter. The only animation not affected by this option is the
+ * initial series animation, see {@link org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions#setAnimation(Animation)} method for
+ * control over series animations that are added after the chart has been rendered.
+ *
+ * Note that this is intended for users that want to have finite control over the way animations
+ * behave. To simply enable/disable animations, you can use the {@link #setAnimation(boolean)}
+ * method instead.
+ *
+ *
+ * @param animation The custom animation to set as the default animation type for the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setAnimation(Animation animation) {
+ return this.setOption("/chart/animation", animation.getOptions());
+ }
+
+ /**
+ * Convenience method for setting the 'backgroundColor' option of the chart to an RGB hex value. Equivalent to:
+ *
+ * chart.setOption("/chart/animation/duration", 500);
+ * chart.setOption("/chart/animation/easing", "linear");
+ *
+ * The RGB background color for the outer chart area. Defaults to "#FFFFFF".
+ *
+ * Note that this method is intended for setting the color to a simple RBG hex value. If you instead
+ * want to set a color to include an alpha channel or a gradient, use the {@link #setBackgroundColor(Color)}
+ * version instead.
+ *
+ * @param backgroundColor The value to set as the 'backgroundColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setBackgroundColor(String backgroundColor) {
+ return this.setOption("/chart/backgroundColor", backgroundColor);
+ }
+
+ /**
+ * Convenience method for setting the 'backgroundColor' option of the chart, allowing for
+ * colors with opacity or gradients. Equivalent to:
+ *
+ * chart.setOption("/chart/backgroundColor", "#CCCCCC");
+ *
+ * The background color or gradient for the outer chart area. Defaults to "#FFFFFF".
+ *
+ * Note that this method is intended for setting the color to a gradient or color that includes
+ * an alpha channel. If you instead just want to set the color to a normal RGB hex value
+ * you can use the {@link #setBackgroundColor(String)} version instead.
+ *
+ * @param backgroundColor The color gradient or color with an alpha channel to set as the 'backgroundColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setBackgroundColor(Color backgroundColor) {
+ return this.setOption("/chart/backgroundColor", backgroundColor != null ? backgroundColor.getOptionValue() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'borderColor' option of the chart to an RGB hex value. Equivalent to:
+ *
+ * chart.setOption("/chart/backgroundColor", new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addStop(new Color(255, 255, 255))
+ * .addStop(new Color(200, 200, 255))
+ * );
+ *
+ * The RGB color of the outer chart border. The border is painted using vector graphic techniques to allow
+ * rounded corners. Defaults to "#4572A7".
+ *
+ * Note that this method is intended for setting the color to a simple RBG hex value. If you instead
+ * want to set a color to include an alpha channel or a gradient, use the {@link #setBorderColor(Color)}
+ * version instead.
+ *
+ * @param borderColor The value to set as the 'borderColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setBorderColor(String borderColor) {
+ return this.setOption("/chart/borderColor", borderColor);
+ }
+
+ /**
+ * Convenience method for setting the 'borderColor' option of the chart, allowing for
+ * colors with opacity or gradients. Equivalent to:
+ *
+ * chart.setOption("/chart/borderColor", "#CCCCCC");
+ *
+ * The color of the outer chart border. The border is painted using vector graphic techniques to allow
+ * rounded corners. Defaults to "#4572A7".
+ *
+ * Note that this method is intended for setting the color to a gradient or color that includes
+ * an alpha channel. If you instead just want to set the color to a normal RGB hex value
+ * you can use the {@link #setBorderColor(String)} version instead.
+ *
+ * @param borderColor The color gradient or color with an alpha channel to set as the 'borderColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setBorderColor(Color borderColor) {
+ return this.setOption("/chart/borderColor", borderColor != null ? borderColor.getOptionValue() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'borderRadius' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/borderColor", new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addStop(new Color(255, 255, 255))
+ * .addStop(new Color(200, 200, 255))
+ * );
+ *
+ * The corner radius of the outer chart border. Defaults to 5.
+ *
+ * @param borderRadius The corner radius of the outer chart border.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setBorderRadius(Number borderRadius) {
+ return this.setOption("/chart/borderRadius", borderRadius);
+ }
+
+ /**
+ * Convenience method for setting the 'borderWidth' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/borderRadius", 10);
+ *
+ * The pixel width of the outer chart border. The border is painted using vector graphic
+ * techniques to allow rounded corners. Defaults to 0.
+ *
+ * @param borderWidth The corner radius of the outer chart border.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setBorderWidth(Number borderWidth) {
+ return this.setOption("/chart/borderWidth", borderWidth);
+ }
+
+ /**
+ * Convenience method for setting the 'subtitle/text' chart option. Equivalent to:
+ *
+ * chart.setOption("/chart/borderWidth", 10);
+ *
+ * The actual text of the chart subtitle. It can contain basic HTML text markup like
+ * <b>, <i> and spans with style. Defaults to null.
+ *
+ * For more control over the title, utilize the {@link #setChartSubtitle(ChartSubtitle)}
+ * method instead.
+ *
+ * To hide the chart subtitle completely, simply set the text to null.
+ *
+ * Note that this method is intended for handling configuring the chart's sub title area before
+ * the chart has been rendered, and has no affect if you invoke the method after the chart has been
+ * drawn to the DOM. If you do want to change the sub title (or title) of the chart dynamically
+ * after it has already been rendered, you can use the {@link #setTitle(ChartTitle, ChartSubtitle)}
+ * method instead.
+ *
+ * @param subtitle Sets the subtitle of chart, or null to hide the subtitle.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setChartSubtitleText(String subtitle) {
+ return this.setOption("/subtitle/text", subtitle);
+ }
+
+ /**
+ * Convenience method for setting the 'subtitle' chart options. Equivalent to:
+ *
+ * chart.setOption("/subtitle/text", "Source: Wikipedia.com");
+ *
+ *
+ * When you call this method it will overwrite any existing
+ * settings that have already been applied to the subtitle (e.g. if you
+ * had previously called the {@link #setChartSubtitleText(String)} method that change
+ * will get overwritten by this call.)
+ *
+ * If you just want to change the text of the subtitle, you can simply
+ * use the {@link #setChartSubtitleText(String)} method instead.
+ *
+ * Note that this method is intended for handling configuring the chart's sub title area before
+ * the chart has been rendered, and has no affect if you invoke the method after the chart has been
+ * drawn to the DOM. If you do want to change the sub title (or title) of the chart dynamically
+ * after it has already been rendered, you can use the {@link #setTitle(ChartTitle, ChartSubtitle)}
+ * method instead.
+ *
+ * @param subtitle Sets the chart subtitle options, or null to hide the subtitle.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setChartSubtitle(ChartSubtitle subtitle) {
+ return this.setOption("/subtitle", subtitle != null ? subtitle.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'title/text' chart option. Equivalent to:
+ *
+ * chart.setOption("/subtitle/text", "Source: Wikipedia.com");
+ * chart.setOption("/subtitle/align", ChartTitle.Align.Left);
+ * etc...
+ *
+ * The actual text of the chart title. It can contain basic HTML text markup like
+ * <b>, <i> and spans with style. Defaults to "Chart title".
+ *
+ * For more control over the title, utilize the {@link #setChartTitle(ChartTitle)}
+ * method instead.
+ *
+ * To hide the chart title completely, simply set the text to null.
+ *
+ * Note that this method is intended for handling configuring the chart's title area before
+ * the chart has been rendered, and has no affect if you invoke the method after the chart has been
+ * drawn to the DOM. If you do want to change the title (or sub title) of the chart dynamically
+ * after it has already been rendered, you can use the {@link #setTitle(ChartTitle, ChartSubtitle)}
+ * method instead.
+ *
+ * @param title Sets the title of chart, or null to hide the title.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setChartTitleText(String title) {
+ return this.setOption("/title/text", title);
+ }
+
+ /**
+ * Convenience method for setting the 'title' chart options. Equivalent to:
+ *
+ * chart.setOption("/title/text", "Sales by Year");
+ *
+ *
+ * If you call this method it will overwrite any existing settings that have already
+ * been applied to the title (e.g. if you had previously called the
+ * {@link #setChartTitleText(String)} method that change will get overwritten by this call.)
+ *
+ * If you just want to change the text of the title, you can simply
+ * use the {@link #setChartTitleText(String)} method instead.
+ *
+ * Note that this method is intended for handling configuring the chart's title area before
+ * the chart has been rendered, and has no affect if you invoke the method after the chart has been
+ * drawn to the DOM. If you do want to change the title (or sub title) of the chart dynamically
+ * after it has already been rendered, you can use the {@link #setTitle(ChartTitle, ChartSubtitle)}
+ * method instead.
+ *
+ * @param title Sets the chart title options, or null to hide the title.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setChartTitle(ChartTitle title) {
+ return this.setOption("/title", title != null ? title.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'className' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/title/text", "Sales by Year");
+ * chart.setOption("/title/align", ChartTitle.Align.Left);
+ * etc...
+ *
+ * A CSS class name to apply to the charts container div, allowing unique CSS styling
+ * for each chart. Defaults to "".
+ *
+ * @param className A CSS class name to apply to the charts container div.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setClassName(String className) {
+ return this.setOption("/chart/className", className);
+ }
+
+ /**
+ * Sets the default colors for the chart's series. When all colors are used, new colors are pulled from the start again.
+ * Note that the colors for each series can be overridden via the {@link org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions#setColor(String)} mechanism.
+ *
+ * Default colors are: "#4572A7", "#AA4643", "#89A54E", "#80699B", "#3D96AE", "#DB843D", "#92A8CD", "#A47D7C", "#B5CA92"
+ *
+ * @param colors An array of colors to use as the defaults for each series.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setColors(String... colors) {
+ return this.setOption("/colors", colors);
+ }
+
+ /**
+ * Convenience method for setting the 'credits' options of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/className", "RedChart");
+ *
+ * Highchart by default puts a credits label in the lower right corner of the chart. This
+ * can be changed using these options.
+ *
+ * @param credits The options to apply to the credits area of the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setCredits(Credits credits) {
+ return this.setOption("/credits", credits != null ? credits.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'exporting' options of the chart. Equivalent to:
+ *
+ * chart.setOption("/credits/text", "Presented by Snoopy");
+ * chart.setOption("/credits/href", "http://www.peanuts.com/");
+ * etc..
+ *
+ * Note that the "exporting" module must be included in the page in order for the exporting
+ * options to apply. E.g.:
+ *
+ * <script type="text/javascript" src="js/modules/exporting.js"></script>
+ *
+ * @param exporting The options to apply to the exporting area of the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ * @see #setNavigation(Navigation)
+ * @since 1.1.0
+ */
+ public T setExporting(Exporting exporting) {
+ return this.setOption("/exporting", exporting != null ? exporting.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'height' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/exporting/enabled", true);
+ * chart.setOption("/exporting/width", 600);
+ * etc..
+ *
+ * An explicit height for the chart. By default the height is calculated from the offset
+ * height of the containing element. Defaults to null.
+ *
+ * @param height An explicit height for the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setHeight(Number height) {
+ return this.setOption("/chart/height", height);
+ }
+
+ /**
+ * Convenience method for setting the 'ignoreHiddenSeries' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/height", 300);
+ *
+ * If true, the axes will scale to the remaining visible series once one series is hidden.
+ * If false, hiding and showing a series will not affect the axes or the other series.
+ * For stacks, once one series within the stack is hidden, the rest of the stack will close
+ * in around it even if the axis is not affected. Defaults to true.
+ *
+ * @param ignoreHiddenSeries If true, the axes will scale to the remaining visible series
+ * once one series is hidden. If false, hiding and showing a series
+ * will not affect the axes or the other series.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setIgnoreHiddenSeries(boolean ignoreHiddenSeries) {
+ return this.setOption("/chart/ignoreHiddenSeries", ignoreHiddenSeries);
+ }
+
+ /**
+ * Convenience method for setting the 'inverted' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/ignoreHiddenSeries", false);
+ *
+ * Whether to invert the axes so that the x axis is horizontal and y axis is vertical. When true, the
+ * x axis is reversed by default. If a bar plot is present in the chart, it will be inverted automatically. Defaults to false.
+ *
+ * @param inverted Whether to invert the axes so that the x axis is horizontal and y axis is vertical.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setInverted(boolean inverted) {
+ return this.setOption("/chart/inverted", inverted);
+ }
+
+ /**
+ * Sets HTML labels that can be positioned anywhere in the chart area. Each label can contain
+ * HTML as well as CSS style properties that can be used to position the label anywhere in the
+ * chart area. See the {@link #setLabelsStyle(Style)} method to control the default style for
+ * each label.
+ *
+ *
+ * @param labelItems An array of LabelItem instances that contain the HTML of the label as well
+ * as a "style" object that can be used to position each label.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setLabelItems(LabelItem... labelItems) {
+ return this.setOption("/labels/items", labelItems);
+ }
+
+ /**
+ * Sets the default CSS style options that will be shared by all label items that are added to the
+ * chart via the {@link #setLabelItems(LabelItem...)} method. The default label style
+ * is simply:
+ *
+ * chart.setOption("/inverted", true);
+ *
+ *
+ *
+ * @param style Shared CSS styles for all label items.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setLabelsStyle(Style style) {
+ return this.setOption("/labels/style", style != null ? style.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'legend' options of the chart. Equivalent to:
+ *
+ * The legend is a box containing a symbol and name for each series item or point item in the chart.
+ *
+ * @param legend The options to apply to the legend of the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setLegend(Legend legend) {
+ return this.setOption("/legend", legend != null ? legend.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'loading' options of the chart. Equivalent to:
+ *
+ * chart.setOption("/legend/borderColor", "#CCCCCC");
+ * chart.setOption("/legend/layout", Legend.Layout.HORIZONTAL);
+ * etc..
+ *
+ * The loading options control the appearance of the loading screen that covers the plot area
+ * on chart operations. This screen only appears after an explicit call to
+ * {@link Chart#showLoading(String)}. It is a utility for developers to communicate to the end
+ * user that something is going on, for example while retrieving new data via a GWT remoting
+ * request. The "Loading..." text itself is not part of this configuration object, but part of
+ * the {@link Lang} object.
+ *
+ * @param loading The options to apply to the loading area of the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setLoading(Loading loading) {
+ return this.setOption("/loading", loading != null ? loading.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'margin' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/loading/showDuration", 150);
+ * chart.setOption("/loading/hideDuration", 60);
+ * etc..
+ *
+ * The margin between the outer edge of the chart and the plot area. Use the options
+ * {@link #setMarginTop(Number)}, {@link #setMarginRight(Number)}, {@link #setMarginBottom(Number)}, and
+ * {@link #setMarginLeft(Number)} for shorthand setting of one option.
+ *
+ * Since version 2.1, the margin is 0 by default. The actual space is dynamically calculated from
+ * the offset of axis labels, axis title, title, subtitle and legend in addition to the
+ * {@link #setSpacingTop(Number)}, {@link #setSpacingRight(Number)}, {@link #setSpacingBottom(Number)},
+ * and {@link #setSpacingLeft(Number)} options.
+ *
+ * @param marginTop The margin between the top outer edge of the chart and the plot area.
+ * @param marginRight The margin between the right outer edge of the chart and the plot area.
+ * @param marginBottom The margin between the bottom outer edge of the chart and the plot area.
+ * @param marginLeft The margin between the left outer edge of the chart and the plot area.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setMargin(Number marginTop, Number marginRight, Number marginBottom, Number marginLeft) {
+ JSONArray margins = new JSONArray();
+ margins.set(0, new JSONNumber(marginTop.doubleValue()));
+ margins.set(1, new JSONNumber(marginRight.doubleValue()));
+ margins.set(2, new JSONNumber(marginBottom.doubleValue()));
+ margins.set(3, new JSONNumber(marginLeft.doubleValue()));
+ return this.setOption("/chart/margin", margins);
+ }
+
+ /**
+ * Convenience method for setting the 'marginTop' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/margin", 0, 10, 0, 15);
+ *
+ * The margin between the top outer edge of the chart and the plot area. Use this to set a fixed
+ * pixel value for the margin as opposed to the default dynamic margin.
+ * See also {@link #setSpacingTop(Number)}. Defaults to null.
+ *
+ * @param marginTop The margin between the top outer edge of the chart and the plot area.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setMarginTop(Number marginTop) {
+ return this.setOption("/chart/marginTop", marginTop);
+ }
+
+ /**
+ * Convenience method for setting the 'marginRight' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/marginTop", 100);
+ *
+ * The margin between the right outer edge of the chart and the plot area. Use this to set
+ * a fixed pixel value for the margin as opposed to the default dynamic margin.
+ * See also {@link #setSpacingRight(Number)}. Defaults to null.
+ *
+ * @param marginRight The margin between the right outer edge of the chart and the plot area.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setMarginRight(Number marginRight) {
+ return this.setOption("/chart/marginRight", marginRight);
+ }
+
+ /**
+ * Convenience method for setting the 'marginBottom' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/marginRight", 100);
+ *
+ * The margin between the bottom outer edge of the chart and the plot area. Use this to set
+ * a fixed pixel value for the margin as opposed to the default dynamic margin.
+ * See also {@link #setSpacingBottom(Number)}. Defaults to null.
+ *
+ * @param marginBottom The margin between the bottom outer edge of the chart and the plot area.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setMarginBottom(Number marginBottom) {
+ return this.setOption("/chart/marginBottom", marginBottom);
+ }
+
+ /**
+ * Convenience method for setting the 'marginBottom' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/marginBottom", 100);
+ *
+ * The margin between the left outer edge of the chart and the plot area. Use this to set a
+ * fixed pixel value for the margin as opposed to the default dynamic margin.
+ * See also {@link #setSpacingLeft(Number)}. Defaults to null.
+ *
+ * @param marginLeft The margin between the left outer edge of the chart and the plot area.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setMarginLeft(Number marginLeft) {
+ return this.setOption("/chart/marginLeft", marginLeft);
+ }
+
+ /**
+ * Convenience method for setting the 'navigation' options of the chart, which represents
+ * a collection of options for buttons and menus appearing in the exporting module.
+ *
+ * Note that the "exporting" module must be included in the page in order for the
+ * exporting navigation options to apply. E.g.:
+ *
+ * <script type="text/javascript" src="js/modules/navigation.js"></script>
+ *
+ * @param navigation The options to apply to the exporting navigation area of the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ * @see #setExporting(Exporting)
+ * @since 1.1.0
+ */
+ public T setNavigation(Navigation navigation) {
+ return this.setOption("/navigation", navigation != null ? navigation.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'plotBackgroundColor' option of the chart to an RGB hex value. Equivalent to:
+ *
+ * chart.setOption("/chart/marginLeft", 100);
+ *
+ * The RGB background color for the plot area. Defaults to null.
+ *
+ * Note that this method is intended for setting the color to a simple RBG hex value. If you instead
+ * want to set a color to include an alpha channel or a gradient, use the {@link #setPlotBackgroundColor(Color)}
+ * version instead.
+ *
+ * @param plotBackgroundColor The value to set as the 'plotBackgroundColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setPlotBackgroundColor(String plotBackgroundColor) {
+ return this.setOption("/chart/plotBackgroundColor", plotBackgroundColor);
+ }
+
+ /**
+ * Convenience method for setting the 'plotBackgroundColor' option of the chart, allowing for
+ * colors with opacity or gradients. Equivalent to:
+ *
+ * chart.setOption("/chart/plotBackgroundColor", "#CCCCCC");
+ *
+ * The background color or gradient for the plot area. Defaults to null.
+ *
+ * Note that this method is intended for setting the color to a gradient or color that includes
+ * an alpha channel. If you instead just want to set the color to a normal RGB hex value
+ * you can use the {@link #setPlotBackgroundColor(String)} version instead.
+ *
+ * @param plotBackgroundColor The color gradient or color with an alpha channel to set as the 'plotBackgroundColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setPlotBackgroundColor(Color plotBackgroundColor) {
+ return this.setOption("/chart/plotBackgroundColor", plotBackgroundColor != null ? plotBackgroundColor.getOptionValue() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'plotBorderColor' option of the chart to an RGB hex value. Equivalent to:
+ *
+ * chart.setOption("/chart/plotBackgroundColor", new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addStop(new Color(255, 255, 255))
+ * .addStop(new Color(200, 200, 255))
+ * );
+ *
+ * The RGB color of the inner chart or plot area border. Defaults to "#C0C0C0".
+ *
+ * Note that this method is intended for setting the color to a simple RBG hex value. If you instead
+ * want to set a color to include an alpha channel or a gradient, use the {@link #setPlotBorderColor(Color)}
+ * version instead.
+ *
+ * @param plotBorderColor The value to set as the 'plotBorderColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setPlotBorderColor(String plotBorderColor) {
+ return this.setOption("/chart/plotBorderColor", plotBorderColor);
+ }
+
+ /**
+ * Convenience method for setting the 'plotBorderColor' option of the chart, allowing for
+ * colors with opacity or gradients. Equivalent to:
+ *
+ * chart.setOption("/chart/plotBorderColor", "#CCCCCC");
+ *
+ * The color (or gradient) of the inner chart or plot area border. Defaults to "#C0C0C0".
+ *
+ * Note that this method is intended for setting the color to a gradient or color that includes
+ * an alpha channel. If you instead just want to set the color to a normal RGB hex value
+ * you can use the {@link #setPlotBorderColor(String)} version instead.
+ *
+ * @param plotBorderColor The color gradient or color with an alpha channel to set as the 'plotBorderColor' option on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setPlotBorderColor(Color plotBorderColor) {
+ return this.setOption("/chart/plotBorderColor", plotBorderColor != null ? plotBorderColor.getOptionValue() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'plotBorderWidth' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/plotBorderColor", new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addStop(new Color(255, 255, 255))
+ * .addStop(new Color(200, 200, 255))
+ * );
+ *
+ * The pixel width of the plot area border. Defaults to 0.
+ *
+ * @param plotBorderWidth The pixel width of the plot area border.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setPlotBorderWidth(Number plotBorderWidth) {
+ return this.setOption("/chart/plotBorderWidth", plotBorderWidth);
+ }
+
+ /**
+ * Convenience method for setting the 'plotShadow' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/plotBorderWidth", 10);
+ *
+ * Whether to apply a drop shadow to the plot area. Requires that plotBackgroundColor be set. Defaults to false.
+ *
+ * @param plotShadow Whether to apply a drop shadow to the plot area.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setPlotShadow(boolean plotShadow) {
+ return this.setOption("/chart/plotShadow", plotShadow);
+ }
+
+ /**
+ * Convenience method for setting the 'reflow' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/plotShadow", false);
+ *
+ * Whether to reflow the chart to fit the width of the container div on resizing
+ * the window. Defaults to true.
+ *
+ * @param reflow If true, reflow the chart to fit the width of the container div on resizing
+ * the window.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setReflow(boolean reflow) {
+ return this.setOption("/chart/reflow", reflow);
+ }
+
+ /**
+ * Convenience method for setting the 'shadow' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/reflow", false);
+ *
+ * Whether to apply a drop shadow to the outer chart area. Requires that backgroundColor be set. Defaults to false.
+ *
+ * @param shadow If true, apply a drop shadow to the outer chart area.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setShadow(boolean shadow) {
+ return this.setOption("/chart/shadow", shadow);
+ }
+
+ /**
+ * Convenience method for setting the 'showAxes' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/shadow", true);
+ *
+ * Whether to show the axes initially. This only applies to empty charts where series are added
+ * dynamically, as axes are automatically added to cartesian series. Defaults to false.
+ *
+ * @param showAxes If true, show the axes initially (only applies to empty charts when the series
+ * are added dynamically).
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setShowAxes(boolean showAxes) {
+ return this.setOption("/chart/showAxes", showAxes);
+ }
+
+ /**
+ * Convenience method for setting the 'spacingTop' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/showAxes", true);
+ *
+ * The space between the top edge of the chart and the content (plot area, axis title and labels,
+ * title, subtitle or legend in top position). Defaults to 10.
+ *
+ * @param spacingTop The space between the top edge of the chart and the content.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSpacingTop(Number spacingTop) {
+ return this.setOption("/chart/spacingTop", spacingTop);
+ }
+
+ /**
+ * Convenience method for setting the 'spacingRight' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/spacingTop", 100);
+ *
+ * The space between the right edge of the chart and the content (plot area, axis title and labels,
+ * title, subtitle or legend in top position). Defaults to 10.
+ *
+ * @param spacingRight The space between the right edge of the chart and the content.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSpacingRight(Number spacingRight) {
+ return this.setOption("/chart/spacingRight", spacingRight);
+ }
+
+ /**
+ * Convenience method for setting the 'spacingBottom' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/spacingRight", 100);
+ *
+ * The space between the bottom edge of the chart and the content (plot area, axis title and labels,
+ * title, subtitle or legend in top position). Defaults to 15.
+ *
+ * @param spacingBottom The space between the bottom edge of the chart and the content.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSpacingBottom(Number spacingBottom) {
+ return this.setOption("/chart/spacingBottom", spacingBottom);
+ }
+
+ /**
+ * Convenience method for setting the 'spacingLeft' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/spacingBottom", 100);
+ *
+ * The space between the left edge of the chart and the content (plot area, axis title and labels,
+ * title, subtitle or legend in top position). Defaults to 10.
+ *
+ * @param spacingLeft The space between the left edge of the chart and the content.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSpacingLeft(Number spacingLeft) {
+ return this.setOption("/chart/spacingLeft", spacingLeft);
+ }
+
+ /**
+ * Convenience method for setting the 'style' options of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/spacingLeft", 100);
+ *
+ * Additional CSS styles to apply inline to the container div. Note that since the default
+ * font styles are applied in the renderer, it is ignorant of the individual chart options
+ * and must be set globally. Defaults to:
+ *
+ * chart.setOption("/chart/style/fontWeight", "bold");
+ * chart.setOption("/chart/style/fontFamily", "serif");
+ * etc.
+ *
+ *
+ *
+ * @param style An object containing the style properties to set on the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setStyle(Style style) {
+ return this.setOption("/chart/style", style != null ? style.getOptions() : null);
+ }
+
+ /**
+ * Sets the default symbols for the series point markers. When all symbols are used, new symbols
+ * are pulled from the start again. Note that the symbols for each series can be overridden via the
+ * {@link org.moxieapps.gwt.highcharts.client.plotOptions.Marker#setSymbol(org.moxieapps.gwt.highcharts.client.plotOptions.Marker.Symbol)} method
+ * (which can be set on the series via its plot options, see
+ * {@link Series#setPlotOptions(org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions)}).
+ *
+ * Default symbols are: Circle, Diamond, Square, Triangle, and Triangle-Down
+ *
+ * @param symbols An array of symbols to use as the default symbols for the series point markers.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSymbols(Marker.Symbol... symbols) {
+ JSONArray symbolsArray = null;
+ if (symbols != null) {
+ symbolsArray = new JSONArray();
+ for (int i = 0; i < symbols.length; i++) {
+ Marker.Symbol symbol = symbols[i];
+ symbolsArray.set(i, new JSONString(symbol.toString()));
+ }
+ }
+ return this.setOption("/symbols", symbolsArray);
+ }
+
+ /**
+ * Set a new title or subtitle for the chart. This method can be called after the chart is
+ * rendered in order to change the title of the chart dynamically.
+ *
+ * Note: this method is primarily intended to allow the chart's title or sub-title area to
+ * be modified dynamically, after the chart has already been rendered to the DOM. If you
+ * instead simply want to set the title or sub-title of the chart via normal configuration
+ * (before the chart has been rendered), then you can utilize the {@link #setChartTitleText(String)},
+ * {@link #setChartTitle(ChartTitle)}, {@link #setChartSubtitleText(String)} and
+ * {@link #setChartSubtitle(ChartSubtitle)} methods.
+ *
+ * @param chartTitle The new options for the main title area of the chart (including the text).
+ * @param chartSubtitle The new options for the main subtitle area of the chart (including the text).
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public T setTitle(ChartTitle chartTitle, ChartSubtitle chartSubtitle) {
+ if (isRendered()) {
+ nativeSetTitle(chart,
+ chartTitle != null ? chartTitle.getOptions().getJavaScriptObject() : null,
+ chartSubtitle != null ? chartSubtitle.getOptions().getJavaScriptObject() : null
+ );
+ } else {
+ this.setChartTitle(chartTitle);
+ this.setChartSubtitle(chartSubtitle);
+ }
+ return returnThis();
+ }
+
+ // We need to maintain a local reference to tooltip to deal with the formatter function
+ private ToolTip toolTip;
+
+ /**
+ * Convenience method for setting the 'tooltip' option of the chart. Equivalent to:
+ *
+ * The tooltip appears when the user hovers over a series or point.
+ *
+ * @param toolTip The options to apply to the tooltip of the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setToolTip(ToolTip toolTip) {
+ this.toolTip = toolTip;
+ return this.setOption("/tooltip", toolTip != null ? toolTip.getOptions() : null);
+ }
+
+ /**
+ * Sets the defaults series type for the chart (which controls the way the series will be rendered), using
+ * an enumeration type in order to ensure a correct value is passed. This is equivalent to
+ * setting the option manually with code like:
+ *
+ * chart.setOption("/tooltip/borderColor", "#CCCCCC");
+ * chart.setOption("/tooltip/shadow", true);
+ * etc..
+ *
+ * Note that if you don't set this explicitly the default series type is {@link Series.Type#LINE}.
+ *
+ * @param type One of the supported series types.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setType(Series.Type type) {
+ return this.setOption("/chart/type", type.toString());
+ }
+
+ /**
+ * Convenience method for setting the 'width' option of the chart. Equivalent to:
+ *
+ * chart.setOption("/chart/type", "line");
+ *
+ * An explicit width for the chart. By default the width is calculated from the offset
+ * width of the containing element. Defaults to null.
+ *
+ * @param width An explicit width for the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setWidth(Number width) {
+ return this.setOption("/chart/width", width);
+ }
+
+ /**
+ * Update the size of the chart to match the size of the container that this widget was inserted
+ * inside of.
+ *
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSizeToMatchContainer() {
+ return this.setSize(this.getOffsetWidth(), this.getOffsetHeight());
+ }
+
+ /**
+ * A helper method which can be used to conveniently set the width of the DOM element that contains
+ * the chart to "100%". Note that for more precise control over the size of the chart see the
+ * {@link #setSize(int, int)} and {@link #setSizeToMatchContainer()} methods.
+ *
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setWidth100() {
+ this.getElement().getStyle().setWidth(100, com.google.gwt.dom.client.Style.Unit.PCT);
+ return returnThis();
+ }
+
+ /**
+ * A helper method which can be used to conveniently set the height of the DOM element that contains
+ * the chart to "100%". Note that for more precise control over the size of the chart see the
+ * {@link #setSize(int, int)} and {@link #setSizeToMatchContainer()} methods.
+ *
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setHeight100() {
+ this.getElement().getStyle().setHeight(100, com.google.gwt.dom.client.Style.Unit.PCT);
+ return returnThis();
+ }
+
+ /**
+ * Updates the size of the chart to match the given width and height, using the default animation options.
+ * Note that if you simply want to set the size of the chart to match the container in which it was inserted,
+ * you can simply call the {@link #setSizeToMatchContainer()} method instead.
+ *
+ * @param width The new pixel width of the chart.
+ * @param height The new pixel height of the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSize(int width, int height) {
+ return this.setSize(width, height, true);
+ }
+
+ /**
+ * Updates the size of the chart to match the given width and height, explicitly setting whether or
+ * not the resize should be animated.
+ *
+ * @param width The new pixel width of the chart.
+ * @param height The new pixel height of the chart.
+ * @param animated When true, the resize will be animated with default animation options. The animation
+ * can also be configured by call the {@link #setSize(int, int, Animation)} method instead.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSize(int width, int height, boolean animated) {
+ return this.setSize(width, height, animated ? new Animation() : null);
+ }
+
+ /**
+ * Updates the size of the chart to match the given width and height, allowing for custom control
+ * over how the animation will be resized.
+ *
+ * @param width The new pixel width of the chart.
+ * @param height The new pixel height of the chart.
+ * @param animation The custom animation to use as the resize animation for the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSize(int width, int height, Animation animation) {
+
+ // Avoid monkeying with anything if we got bad values
+ if (width <= 0 || height <= 0) {
+ return returnThis();
+ }
+
+ if (isRendered()) {
+ // If we're already on the screen, then do the resize natively
+ if (animation == null || animation.getOptions() == null) {
+ nativeSetSize(chart, width, height, animation != null);
+ } else {
+ nativeSetSize(chart, width, height, animation.getOptions().getJavaScriptObject());
+ }
+ } else {
+ // In we're invoked before the chart is rendered, keep the width and height around in our configuration
+ setOption("/chart/width", width);
+ setOption("/chart/height", height);
+ }
+
+ return returnThis();
+
+ }
+
+ // Delegate responsibility for managing configuration options to an anonymous helper class
+ private Configurable configurable = new Configurable() {
+ };
+
+ /**
+ * General purpose method to set an arbitrary option on the chart at any level,
+ * using "/" characters to designate which level of option you'd like to set.
+ * E.g., the following code:
+ *
+ * chart.setOption("/chart/width", 800);
+ *
+ * Would result in initializing HighCharts like the following:
+ *
+ * Chart chart = new Chart();
+ * chart.setOption("/chart/type", "spline");
+ * chart.setOption("/chart/marginRight", 10);
+ * chart.setOption("/title/text", "Nice Chart");
+ *
+ * Note that the beginning "/" is optional, so
+ * new HighCharts.Chart({
+ * chart: {
+ * type: "spline",
+ * marginRight: 10
+ * },
+ * title: {
+ * text: "Nice Chart"
+ * }
+ * });
+ * 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:
+ *
+ * Do this instead:
+ *
+ * chart.setOption("/chart/type", "spline");
+ *
+ *
+ * @param path The path to the option to set (e.g. "/title/text");
+ * @param value The value to set for the option (can be a String, Number, Boolean, or JSONObject)
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setOption(String path, Object value) {
+ configurable.setOption(path, value);
+ return returnThis();
+ }
+
+ /**
+ * Retrieve all of the options that have been configured for this chart instance
+ * as a JSONObject.
+ *
+ * @return A JSONObject representing all of the configuration options
+ * that have been set on the instance (will be null if no options have been set)
+ *
+ * @since 1.1.3
+ */
+ public JSONObject getOptions() {
+ return configurable.getOptions();
+ }
+
+ // Helper method to avoid having to do the cast and warning handling in multiple places
+ private T returnThis() {
+ @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
+ T instance = (T) this;
+ return instance;
+ }
+
+ // We need to maintain a local reference to the plot options in order to handle the potential callback formatter functions
+ private AreaPlotOptions areaPlotOptions;
+ private AreaSplinePlotOptions areaSplinePlotOptions;
+ private BarPlotOptions barPlotOptions;
+ private ColumnPlotOptions columnPlotOptions;
+ private LinePlotOptions linePlotOptions;
+ private PiePlotOptions piePlotOptions;
+ private SeriesPlotOptions seriesPlotOptions;
+ private ScatterPlotOptions scatterPlotOptions;
+ private SplinePlotOptions splinePlotOptions;
+
+ /**
+ * Updates the options that all area type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param areaPlotOptions The options to set on the chart as the default settings for all area type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setAreaPlotOptions(AreaPlotOptions areaPlotOptions) {
+ this.areaPlotOptions = areaPlotOptions;
+ return areaPlotOptions != null && areaPlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/area", areaPlotOptions.getOptions()) :
+ returnThis();
+ }
+
+
+ /**
+ * Updates the options that all area spline type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param areaSplinePlotOptions The options to set on the chart as the default settings for all area spline type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setAreaSplinePlotOptions(AreaSplinePlotOptions areaSplinePlotOptions) {
+ this.areaSplinePlotOptions = areaSplinePlotOptions;
+ return areaSplinePlotOptions != null && areaSplinePlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/areaspline", areaSplinePlotOptions.getOptions()) :
+ returnThis();
+ }
+
+ /**
+ * Updates the options that all bar type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param barPlotOptions The options to set on the chart as the default settings for all bar type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setBarPlotOptions(BarPlotOptions barPlotOptions) {
+ this.barPlotOptions = barPlotOptions;
+ return barPlotOptions != null && barPlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/bar", barPlotOptions.getOptions()) :
+ returnThis();
+ }
+
+ /**
+ * Updates the options that all column type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param columnPlotOptions The options to set on the chart as the default settings for all column type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setColumnPlotOptions(ColumnPlotOptions columnPlotOptions) {
+ this.columnPlotOptions = columnPlotOptions;
+ return columnPlotOptions != null && columnPlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/column", columnPlotOptions.getOptions()) :
+ returnThis();
+ }
+
+ /**
+ * Updates the options that all line type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param linePlotOptions The options to set on the chart as the default settings for all line type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setLinePlotOptions(LinePlotOptions linePlotOptions) {
+ this.linePlotOptions = linePlotOptions;
+ return linePlotOptions != null && linePlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/line", linePlotOptions.getOptions()) :
+ returnThis();
+ }
+
+ /**
+ * Updates the options that all pie type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param piePlotOptions The options to set on the chart as the default settings for all pie type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setPiePlotOptions(PiePlotOptions piePlotOptions) {
+ this.piePlotOptions = piePlotOptions;
+ return piePlotOptions != null && piePlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/pie", piePlotOptions.getOptions()) :
+ returnThis();
+ }
+
+ /**
+ * Updates the general options that all series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that the general {@link SeriesPlotOptions} type only represents core options that area available for all series types.
+ * To control options that are more specific to each series type, use one of the more specific methods instead (e.g.
+ * {@link #setLinePlotOptions(org.moxieapps.gwt.highcharts.client.plotOptions.LinePlotOptions)},
+ * {@link #setAreaPlotOptions(org.moxieapps.gwt.highcharts.client.plotOptions.AreaPlotOptions)}, etc.)
+ *
+ * Also note that changing the general plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart, and therefore will not impact any of the series that are already
+ * rendered in the chart.
+ *
+ * @param seriesPlotOptions The options to set on the chart as the default settings for all series that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSeriesPlotOptions(SeriesPlotOptions seriesPlotOptions) {
+ this.seriesPlotOptions = seriesPlotOptions;
+ return seriesPlotOptions != null && seriesPlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/series", seriesPlotOptions.getOptions()) :
+ returnThis();
+ }
+
+ /**
+ * Updates the options that all scatter type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param scatterPlotOptions The options to set on the chart as the default settings for all scatter type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setScatterPlotOptions(ScatterPlotOptions scatterPlotOptions) {
+ this.scatterPlotOptions = scatterPlotOptions;
+ return scatterPlotOptions != null && scatterPlotOptions.getOptions() != null ?
+ this.setOption("/plotOptions/scatter", scatterPlotOptions.getOptions()) :
+ returnThis();
+ }
+
+ private ChartClickEventHandler chartClickEventHandler;
+
+ /**
+ * Set a callback handler that will be invoked whenever the user clicks on the plot background.
+ * Information where the user clicked can then be found through the {@link org.moxieapps.gwt.highcharts.client.events.ChartClickEvent} instance
+ * that is passed to the handler's {@link org.moxieapps.gwt.highcharts.client.events.ChartClickEventHandler#onClick(org.moxieapps.gwt.highcharts.client.events.ChartClickEvent)} method.
+ *
+ * @param chartClickEventHandler The handler that should be invoked whenever a click event occurs.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public T setClickEventHandler(ChartClickEventHandler chartClickEventHandler) {
+ this.chartClickEventHandler = chartClickEventHandler;
+ return returnThis();
+ }
+
+ private ChartLoadEventHandler chartLoadEventHandler;
+
+ /**
+ * Set a callback handler that will be invoked whenever the chart's loading event is fired.
+ *
+ * @param chartLoadEventHandler The handler that should be invoked whenever a load event occurs.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public T setLoadEventHandler(ChartLoadEventHandler chartLoadEventHandler) {
+ this.chartLoadEventHandler = chartLoadEventHandler;
+ return returnThis();
+ }
+
+ private ChartRedrawEventHandler chartRedrawEventHandler;
+
+ /**
+ * Set a callback handler that will be invoked whenever the chart's redraw event is fired.
+ *
+ * @param chartRedrawEventHandler The handler that should be invoked whenever a redraw event occurs.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public T setRedrawEventHandler(ChartRedrawEventHandler chartRedrawEventHandler) {
+ this.chartRedrawEventHandler = chartRedrawEventHandler;
+ return returnThis();
+ }
+
+ private ChartSelectionEventHandler chartSelectionEventHandler;
+
+ /**
+ * Set a callback handler that will be invoked whenever the chart's selection event is fired.
+ *
+ * @param chartSelectionEventHandler The handler that should be invoked whenever a selection event occurs.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public T setSelectionEventHandler(ChartSelectionEventHandler chartSelectionEventHandler) {
+ this.chartSelectionEventHandler = chartSelectionEventHandler;
+ return returnThis();
+ }
+
+ /**
+ * Updates the options that all spline type series within the chart will use by default. The settings can then
+ * be overridden for each individual series via the {@link Series#setPlotOptions(PlotOptions)} method.
+ *
+ * Note that changing the plot options on a chart that has already been rendered will only affect
+ * series that are subsequently added to the chart (and will not impact any of the series that are already
+ * rendered in the chart.)
+ *
+ * @param splinePlotOptions The options to set on the chart as the default settings for all spline type series
+ * that are part of this chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T setSplinePlotOptions(SplinePlotOptions splinePlotOptions) {
+ this.splinePlotOptions = splinePlotOptions;
+ return this.setOption("/plotOptions/spline", splinePlotOptions.getOptions());
+ }
+
+ // Purposefully not using the generic "List" interface here in order to optimize GWT performance.
+ private ArrayList
+ * chart.setType(Series.Type.SPLINE);
+ *
+ * Some event methods (such as {@link org.moxieapps.gwt.highcharts.client.events.SeriesClickEvent#getSeriesId()})
+ * return the unique id of a series, which can then be used in conjunction with this method to access
+ * the series instance associated with the event.
+ *
+ * @param seriesId The unique id of the series to try and find.
+ * @return The series associated with the given id, or null if no series exist with the given id
+ * @since 1.1.0
+ */
+ public Series getSeries(String seriesId) {
+ for (Series series : seriesList) {
+ if (series.getId().equals(seriesId)) {
+ return series;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return an array of all the {@link Series} instances that have been added to this chart (either before or
+ * after the chart was rendered), or an empty array if none have been added yet. Note that we're returning
+ * an array instead of a java.util.List as the generic interface types require a bit of a performance hit
+ * in GWT to use.
+ *
+ * @return An array of the Series instances currently within the chart, or an empty array if none have yet
+ * been added.
+ */
+ public Series[] getSeries() {
+ return seriesList.toArray(new Series[seriesList.size()]);
+ }
+
+ /**
+ * Remove the given series from the chart, automatically redrawing the chart after the series
+ * has been removed. See the {@link #removeSeries(Series, boolean)} method if you're performing
+ * multiple options on the chart at once and need tighter control over when the chart is redrawn.
+ *
+ * @param series The series instance to remove from the chart.
+ * @return 'true' if the series was a part of this chart and successfully removed, or 'false' if the
+ * given series was not a part of this chart and therefore couldn't be removed.
+ */
+ public boolean removeSeries(Series series) {
+ return removeSeries(series, true);
+ }
+
+ /**
+ * Remove the given series from the chart, explicitly controlling whether or not the chart will
+ * be redrawn after the series is removed.
+ *
+ * @param series The series instance to remove from the chart.
+ * @param redraw Whether to redraw the chart after the series is removed. When you're performing multiple
+ * options on the chart, it is highly recommended that the redraw option be set to false, and instead
+ * explicitly call the {@link Chart#redraw()} method after you're done updating the chart.
+ * @return 'true' if the series was a part of this chart and successfully removed, or 'false' if the
+ * given series was not a part of this chart and therefore couldn't be removed.
+ */
+ public boolean removeSeries(Series series, boolean redraw) {
+ if (!seriesList.remove(series)) {
+ return false;
+ }
+ if (isRendered()) {
+ final JavaScriptObject nativeSeries = nativeGet(chart, series.getId());
+ if (nativeSeries != null) {
+ nativeRemoveSeries(chart, nativeSeries, redraw);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * A convenience method to run through and remove all of the series that are currently part of the chart
+ * instance, only performing a redraw after they're all done. See the {@link Series#remove()} or
+ * {@link #removeSeries(Series)} method if you instead want to remove a single series from the chart.
+ * Also see the {@link #removeAllSeries(boolean)} method if you need more control over when the chart
+ * is redrawn.
+ *
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T removeAllSeries() {
+ removeAllSeries(true);
+ return returnThis();
+ }
+
+ /**
+ * A convenience method to run through and remove all of the series that are currently part of the chart
+ * instance, with explicit control over the animation options. See the {@link Series#remove()} or
+ * {@link #removeSeries(Series)} method if you instead want to remove a single series from the chart.
+ *
+ * @param redraw Whether to redraw the chart after the series is removed. When you're performing multiple
+ * options on the chart, it is highly recommended that the redraw option be set to false, and instead
+ * explicitly call the {@link Chart#redraw()} method after you're done updating the chart.
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T removeAllSeries(boolean redraw) {
+ // Clone the collection so that we can remove from the main list while iterating over the clone
+ ArrayListredraw() after.
+ *
+ * The redraw() method only redraws those parts of the chart that are actually changed.
+ * If the data of a series is changed and it doesn't affect the axes, only the series itself is redrawn.
+ * If the new data requires the axis extremes to be altered, the axis and all other series depending
+ * on it are redrawn.
+ *
+ * @return A reference to this {@link BaseChart} instance for convenient method chaining.
+ */
+ public T redraw() {
+ if (isRendered()) {
+ nativeRedraw(chart);
+ }
+ return returnThis();
+ }
+
+ /**
+ * Returns true if the chart has already been rendered to the DOM, or false otherwise.
+ *
+ * @return 'true' if the chart has been rendered to the DOM
+ */
+ public boolean isRendered() {
+ return chart != null;
+ }
+
+ private JavaScriptObject chart;
+
+ @Override
+ protected void onLoad() {
+
+ // Build some arrays that we can pass into the JS function so that it knows how many custom callback functions it needs to wire
+ // up on the client side for formatter functions.
+ JSONArray xAxisLabelFormatters = new JSONArray();
+ for (int i = 0, xAxesSize = xAxes.size(); i < xAxesSize; i++) {
+ XAxis xAxis = xAxes.get(i);
+ xAxisLabelFormatters.set(i, JSONBoolean.getInstance(xAxis.getLabels() != null && xAxis.getLabels().getFormatter() != null));
+ }
+ JSONArray yAxisLabelFormatters = new JSONArray();
+ JSONArray yAxisStackLabelFormatters = new JSONArray();
+ for (int i = 0, yAxesSize = yAxes.size(); i < yAxesSize; i++) {
+ YAxis yAxis = yAxes.get(i);
+ yAxisLabelFormatters.set(i, JSONBoolean.getInstance(yAxis.getLabels() != null && yAxis.getLabels().getFormatter() != null));
+ yAxisStackLabelFormatters.set(i, JSONBoolean.getInstance(yAxis.getStackLabels() != null && yAxis.getStackLabels().getFormatter() != null));
+ }
+
+ // Build a similar object for dealing with all of the data label formatters that may be set on the plot options
+ JSONObject plotOptionsLabelFormatters = new JSONObject();
+ plotOptionsLabelFormatters.put("area", hasDataLabelsFormatter(areaPlotOptions));
+ plotOptionsLabelFormatters.put("areaspline", hasDataLabelsFormatter(areaSplinePlotOptions));
+ plotOptionsLabelFormatters.put("bar", hasDataLabelsFormatter(barPlotOptions));
+ plotOptionsLabelFormatters.put("column", hasDataLabelsFormatter(columnPlotOptions));
+ plotOptionsLabelFormatters.put("line", hasDataLabelsFormatter(linePlotOptions));
+ plotOptionsLabelFormatters.put("pie", hasDataLabelsFormatter(piePlotOptions));
+ plotOptionsLabelFormatters.put("series", hasDataLabelsFormatter(seriesPlotOptions));
+ plotOptionsLabelFormatters.put("scatter", hasDataLabelsFormatter(scatterPlotOptions));
+ plotOptionsLabelFormatters.put("spline", hasDataLabelsFormatter(splinePlotOptions));
+
+ // And one more for dealing with any data label formatters that have been applied directly to a series
+ JSONArray seriesLabelFormatters = new JSONArray();
+ for (int i = 0, seriesListSize = seriesList.size(); i < seriesListSize; i++) {
+ Series series = seriesList.get(i);
+ seriesLabelFormatters.set(i, hasDataLabelsFormatter(series));
+ }
+
+ // Another one for events fired on the chart
+ JSONObject chartEventHandlers = new JSONObject();
+ chartEventHandlers.put("click", JSONBoolean.getInstance(chartClickEventHandler != null));
+ chartEventHandlers.put("load", JSONBoolean.getInstance(chartLoadEventHandler != null));
+ chartEventHandlers.put("redraw", JSONBoolean.getInstance(chartRedrawEventHandler != null));
+ chartEventHandlers.put("selection", JSONBoolean.getInstance(chartSelectionEventHandler != null));
+
+ // And two more for events that have been applied to the series (or the points within the series)
+ JSONObject seriesEventHandlers = new JSONObject();
+ JSONObject pointEventHandlers = new JSONObject();
+
+ if (seriesPlotOptions != null) {
+
+ // Series event
+ seriesEventHandlers.put("click",
+ JSONBoolean.getInstance(seriesPlotOptions.getSeriesClickEventHandler() != null)
+ );
+ seriesEventHandlers.put("checkboxClick",
+ JSONBoolean.getInstance(seriesPlotOptions.getSeriesCheckboxClickEventHandler() != null)
+ );
+ seriesEventHandlers.put("hide",
+ JSONBoolean.getInstance(seriesPlotOptions.getSeriesHideEventHandler() != null)
+ );
+ seriesEventHandlers.put("legendItemClick",
+ JSONBoolean.getInstance(seriesPlotOptions.getSeriesLegendItemClickEventHandler() != null)
+ );
+ seriesEventHandlers.put("mouseOver",
+ JSONBoolean.getInstance(seriesPlotOptions.getSeriesMouseOverEventHandler() != null)
+ );
+ seriesEventHandlers.put("mouseOut",
+ JSONBoolean.getInstance(seriesPlotOptions.getSeriesMouseOutEventHandler() != null)
+ );
+ seriesEventHandlers.put("show",
+ JSONBoolean.getInstance(seriesPlotOptions.getSeriesShowEventHandler() != null)
+ );
+
+ // Point events
+ pointEventHandlers.put("click",
+ JSONBoolean.getInstance(seriesPlotOptions.getPointClickEventHandler() != null)
+ );
+ pointEventHandlers.put("mouseOver",
+ JSONBoolean.getInstance(seriesPlotOptions.getPointMouseOverEventHandler() != null)
+ );
+ pointEventHandlers.put("mouseOut",
+ JSONBoolean.getInstance(seriesPlotOptions.getPointMouseOutEventHandler() != null)
+ );
+ pointEventHandlers.put("remove",
+ JSONBoolean.getInstance(seriesPlotOptions.getPointRemoveEventHandler() != null)
+ );
+ pointEventHandlers.put("select",
+ JSONBoolean.getInstance(seriesPlotOptions.getPointSelectEventHandler() != null)
+ );
+ pointEventHandlers.put("unselect",
+ JSONBoolean.getInstance(seriesPlotOptions.getPointUnselectEventHandler() != null)
+ );
+ pointEventHandlers.put("update",
+ JSONBoolean.getInstance(seriesPlotOptions.getPointUpdateEventHandler() != null)
+ );
+ }
+
+ // Pie charts support one additional point event
+ if (piePlotOptions != null) {
+ pointEventHandlers.put("legendItemClick",
+ JSONBoolean.getInstance(piePlotOptions.getPointLegendItemClickEventHandler() != null)
+ );
+ }
+
+ chart = nativeRenderChart(
+ getChartTypeName(),
+ createNativeOptions(),
+ toolTip != null && toolTip.getToolTipFormatter() != null,
+ chartEventHandlers.getJavaScriptObject(),
+ seriesEventHandlers.getJavaScriptObject(),
+ pointEventHandlers.getJavaScriptObject(),
+ xAxisLabelFormatters.getJavaScriptObject(),
+ yAxisLabelFormatters.getJavaScriptObject(),
+ yAxisStackLabelFormatters.getJavaScriptObject(),
+ plotOptionsLabelFormatters.getJavaScriptObject(),
+ seriesLabelFormatters.getJavaScriptObject()
+ );
+
+ // Now that we're rendered we're going to switch to maintaining everything within the DOM, so we can dump
+ // any series data that we were managing internally
+ for (Series series : seriesList) {
+ series.clearInternalPointsList();
+ series.setRendered(true);
+ }
+
+ }
+
+ /**
+ * To be overridden in a sub class to return the JS type name of the chart instance that
+ * should be created when the chart is rendered. E.g. "Chart", "StockChart", etc.
+ *
+ * @return The name of the JS class type that should be created when this chart is rendered.
+ */
+ protected abstract String getChartTypeName();
+
+ private JSONBoolean hasDataLabelsFormatter(PlotOptions plotOptions) {
+ return JSONBoolean.getInstance(plotOptions != null &&
+ plotOptions.getDataLabels() != null &&
+ plotOptions.getDataLabels().getFormatter() != null
+ );
+ }
+
+ private JSONBoolean hasDataLabelsFormatter(Series series) {
+ return JSONBoolean.getInstance(series != null &&
+ series.getPlotOptions() != null &&
+ series.getPlotOptions().getDataLabels() != null &&
+ series.getPlotOptions().getDataLabels().getFormatter() != null
+ );
+ }
+
+
+ @Override
+ protected void onUnload() {
+ if (isRendered()) {
+ nativeDestroy(chart);
+ chart = null;
+ }
+ }
+
+ private JavaScriptObject createNativeOptions() {
+ JSONObject options = configurable.getOptions();
+ if (options == null) {
+ options = new JSONObject();
+ }
+
+ // #1: We need to merge the options they provided with the additional detail we know internally,
+ // and first we need to set which DOM element the chart should be rendered within
+ JSONValue chartValue = options.get("chart");
+ if (chartValue == null || chartValue.isObject() == null) {
+ chartValue = new JSONObject();
+ options.put("chart", chartValue);
+ }
+ final JSONObject chartObject = (JSONObject) options.get("chart");
+ chartObject.put("renderTo", new JSONString(this.getElement().getId()));
+
+ // #2: We need to setup whatever data series needs to be rendered initially in the chart
+ if (seriesList.size() > 0) {
+ final JSONValue seriesValue = options.get("series");
+ if (seriesValue == null || seriesValue.isArray() == null) {
+ options.put("series", new JSONArray());
+ }
+ final JSONArray seriesArray = (JSONArray) options.get("series");
+ for (int i = 0, seriesListSize = seriesList.size(); i < seriesListSize; i++) {
+ Series series = seriesList.get(i);
+ JSONObject seriesOptions = convertSeriesToJSON(series);
+ seriesArray.set(i, seriesOptions);
+ }
+ }
+
+ // #3: We need to add references to our axis so that we can later lookup the
+ // axis by id (as well as pass along any configuration options that were applied to the axis)
+ final JSONValue xAxisJSONValue = convertToJSONValue(xAxes.toArray(new Configurable[xAxes.size()]));
+ if (xAxisJSONValue != null && xAxisJSONValue.isNull() == null) {
+ options.put("xAxis", xAxisJSONValue);
+ }
+ final JSONValue yAxisJSONValue = convertToJSONValue(yAxes.toArray(new Configurable[yAxes.size()]));
+ if (yAxisJSONValue != null && yAxisJSONValue.isNull() == null) {
+ options.put("yAxis", yAxisJSONValue);
+ }
+
+ // For debugging the raw options that we're passing to the chart on startup, uncomment the following line
+ // com.google.gwt.user.client.Window.alert(options.toString());
+
+ return options.getJavaScriptObject();
+ }
+
+ private JSONObject convertSeriesToJSON(Series series) {
+ JSONObject seriesOptions = series.getOptions();
+ if (seriesOptions == null) {
+ seriesOptions = new JSONObject();
+ }
+ JSONValue dataValue = seriesOptions.get("data");
+ if (dataValue == null || dataValue.isArray() == null) {
+ seriesOptions.put("data", new JSONArray());
+ }
+ copyPointsToJSONArray(series.getPoints(), (JSONArray) seriesOptions.get("data"));
+ return seriesOptions;
+ }
+
+ private static JSONValue convertToJSONValue(Configurable... configurables) {
+ if (configurables.length > 1) {
+ JSONArray jsonArray = new JSONArray();
+ for (int i = 0; i < configurables.length; i++) {
+ jsonArray.set(i, configurables[i].getOptions());
+ }
+ return jsonArray;
+ } else if (configurables.length == 1) {
+ return configurables[0].getOptions();
+ }
+ return JSONNull.getInstance();
+ }
+
+ private static void copyPointsToJSONArray(Point[] points, JSONArray jsonArray) {
+ for (int i = 0, pointsLength = points.length; i < pointsLength; i++) {
+ final Point point = points[i];
+ jsonArray.set(i, convertPointToJSON(point));
+ }
+ }
+
+ // Purposefully package scope so we can get to this method from the Series and Point classes as well
+ static JSONValue convertPointToJSON(Point point) {
+ final JSONObject options = point.getOptions();
+ if (options != null) {
+ return addPointScalarValues(point, options);
+ } else if (point.getX() != null) {
+ JSONArray jsonArray = new JSONArray();
+ jsonArray.set(0, new JSONNumber(point.getX().doubleValue()));
+ if (point.getY() != null) {
+ jsonArray.set(1, new JSONNumber(point.getY().doubleValue()));
+ } else {
+ jsonArray.set(1, JSONNull.getInstance());
+ }
+ return jsonArray;
+ } else if (point.getY() != null) {
+ return new JSONNumber(point.getY().doubleValue());
+ } else {
+ return JSONNull.getInstance();
+ }
+ }
+
+ // Purposefully package scope
+ static JSONValue addPointScalarValues(Point point, JSONObject options) {
+ if (point.getX() != null) {
+ options.put("x", new JSONNumber(point.getX().doubleValue()));
+ }
+ if (point.getY() != null) {
+ options.put("y", new JSONNumber(point.getY().doubleValue()));
+ } else {
+ options.put("y", JSONNull.getInstance());
+ }
+ return options;
+ }
+
+ // Purposefully constrained to package scope
+ JavaScriptObject get(String id) {
+ if (isRendered()) {
+ return nativeGet(chart, id);
+ } else {
+ return null;
+ }
+ }
+
+ private native JavaScriptObject nativeRenderChart(String chartTypeName,
+ JavaScriptObject options,
+ boolean toolTipFormatterFlag,
+ JavaScriptObject chartEventHandlerFlags,
+ JavaScriptObject seriesEventHandlerFlags,
+ JavaScriptObject pointEventHandlerFlags,
+ JavaScriptObject xAxisLabelFormatterFlags,
+ JavaScriptObject yAxisLabelFormatterFlags,
+ JavaScriptObject yAxisStackLabelFormatterFlags,
+ JavaScriptObject plotOptionsLabelsFormatterFlags,
+ JavaScriptObject seriesLabelsFormatterFlags) /*-{
+
+ var self = this;
+
+ // Add in GWT interceptor callback functions for the various core chart event handlers
+ for (var type1 in chartEventHandlerFlags) {
+ if (type1.indexOf("gwt") < 0 && chartEventHandlerFlags[type1]) {
+ options.chart.events = options.chart.events || {};
+ options.chart.events[type1] = function(e) {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::chartEventCallback(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;)(e, arguments.callee.type);
+ };
+ options.chart.events[type1].type = type1;
+ }
+ }
+
+ // Add in GWT interceptor callback functions for the various series event handlers
+ for (var type2 in seriesEventHandlerFlags) {
+ if (type2.indexOf("gwt") < 0 && seriesEventHandlerFlags[type2]) {
+ options.plotOptions = options.plotOptions || {};
+ options.plotOptions.series = options.plotOptions.series || {};
+ options.plotOptions.series.events = options.plotOptions.series.events || {};
+ options.plotOptions.series.events[type2] = function(e) {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::seriesEventCallback(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;)(this, e, arguments.callee.type);
+ };
+ options.plotOptions.series.events[type2].type = type2;
+ }
+ }
+
+ // Add in GWT interceptor callback functions for the various series point event handlers
+ for (var type3 in pointEventHandlerFlags) {
+ if (type3.indexOf("gwt") < 0 && pointEventHandlerFlags[type3]) {
+ options.plotOptions = options.plotOptions || {};
+ options.plotOptions.series = options.plotOptions.series || {};
+ options.plotOptions.series.point = options.plotOptions.series.point || {};
+ options.plotOptions.series.point.events = options.plotOptions.series.point.events || {};
+ options.plotOptions.series.point.events[type3] = function(e) {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::pointEventCallback(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;)(this, e, arguments.callee.type);
+ };
+ options.plotOptions.series.point.events[type3].type = type3;
+ }
+ }
+
+ // Add in GWT interceptor callback functions for the various formatters so that we can move from
+ // the native JS world back to the Java world...
+ if (toolTipFormatterFlag) {
+ options.tooltip = options.tooltip || {};
+ options.tooltip.formatter = function() {
+ var result = self.@org.moxieapps.gwt.highcharts.client.BaseChart::toolTipFormatterCallback(Lcom/google/gwt/core/client/JavaScriptObject;)(this);
+ if (result == null) {
+ return false;
+ }
+ return result;
+ };
+ }
+
+ // X axis label formatters
+ for (i = 0; i < xAxisLabelFormatterFlags.length; i++) {
+ if (!xAxisLabelFormatterFlags[i]) continue;
+ var xAxis = xAxisLabelFormatterFlags.length == 1 ? options.xAxis : options.xAxis[i];
+ xAxis.labels = xAxis.labels || {};
+ xAxis.labels.formatter = function() {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::xAxisLabelFormatterCallback(Lcom/google/gwt/core/client/JavaScriptObject;I)(this, arguments.callee.index);
+ };
+ xAxis.labels.formatter.index = i;
+ }
+
+ // Y axis label formatters
+ for (i = 0; i < yAxisLabelFormatterFlags.length && i < yAxisStackLabelFormatterFlags.length; i++) {
+ var yAxis = yAxisLabelFormatterFlags.length == 1 ? options.yAxis : options.yAxis[i];
+ if (yAxisLabelFormatterFlags[i]) {
+ yAxis.labels = yAxis.labels || {};
+ yAxis.labels.formatter = function() {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::yAxisLabelFormatterCallback(Lcom/google/gwt/core/client/JavaScriptObject;I)(this, arguments.callee.index);
+ };
+ yAxis.labels.formatter.index = i;
+ }
+ if (yAxisStackLabelFormatterFlags[i]) {
+ yAxis.stackLabels = yAxis.stackLabels || {};
+ yAxis.stackLabels.formatter = function() {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::yAxisStackLabelFormatterCallback(Lcom/google/gwt/core/client/JavaScriptObject;I)(this, arguments.callee.index);
+ };
+ yAxis.stackLabels.formatter.index = i;
+ }
+ }
+
+ // Plot options data label formatters
+ for (var type4 in plotOptionsLabelsFormatterFlags) {
+ if (type4.indexOf("gwt") < 0 && plotOptionsLabelsFormatterFlags[type4]) {
+ options.plotOptions = options.plotOptions || {};
+ options.plotOptions[type4] = options.plotOptions[type4] || {};
+ options.plotOptions[type4].dataLabels = options.plotOptions[type4].dataLabels || {};
+ options.plotOptions[type4].dataLabels.formatter = function() {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::plotOptionsLabelsFormatterCallback(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;)(this, arguments.callee.type);
+ };
+ options.plotOptions[type4].dataLabels.formatter.type = type4;
+ }
+ }
+
+ // Series override label formatters
+ for (i = 0; i < seriesLabelsFormatterFlags.length; i++) {
+ if (!seriesLabelsFormatterFlags[i]) continue;
+ var series = options.series[i];
+ series.dataLabels = series.dataLabels || {};
+ series.dataLabels.formatter = function() {
+ return self.@org.moxieapps.gwt.highcharts.client.BaseChart::seriesLabelsFormatterCallback(Lcom/google/gwt/core/client/JavaScriptObject;I)(this, arguments.callee.index);
+ };
+ series.dataLabels.formatter.index = i;
+ }
+
+ // Draw the chart!
+ return new $wnd.Highcharts[chartTypeName](options);
+ }-*/;
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private void chartEventCallback(JavaScriptObject nativeEvent, String eventType) {
+ if ("click".equals(eventType) && chartClickEventHandler != null) {
+ chartClickEventHandler.onClick(new ChartClickEvent(nativeEvent));
+ } else if ("load".equals(eventType) && chartLoadEventHandler != null) {
+ chartLoadEventHandler.onLoad(new ChartLoadEvent(nativeEvent));
+ } else if ("redraw".equals(eventType) && chartRedrawEventHandler != null) {
+ chartRedrawEventHandler.onRedraw(new ChartRedrawEvent(nativeEvent));
+ } else if ("selection".equals(eventType) && chartSelectionEventHandler != null) {
+ chartSelectionEventHandler.onSelection(new ChartSelectionEvent(nativeEvent));
+ }
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private void seriesEventCallback(JavaScriptObject nativeSeries, JavaScriptObject nativeEvent, String eventType) {
+ if ("click".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getSeriesClickEventHandler() != null) {
+ seriesPlotOptions.getSeriesClickEventHandler().onClick(new SeriesClickEvent(nativeEvent, nativeSeries));
+ } else if ("checkboxClick".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getSeriesCheckboxClickEventHandler() != null) {
+ seriesPlotOptions.getSeriesCheckboxClickEventHandler().onClick(new SeriesCheckboxClickEvent(nativeEvent, nativeSeries));
+ } else if ("hide".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getSeriesHideEventHandler() != null) {
+ seriesPlotOptions.getSeriesHideEventHandler().onHide(new SeriesHideEvent(nativeEvent, nativeSeries));
+ } else if ("legendItemClick".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getSeriesLegendItemClickEventHandler() != null) {
+ seriesPlotOptions.getSeriesLegendItemClickEventHandler().onClick(new SeriesLegendItemClickEvent(nativeEvent, nativeSeries));
+ } else if ("mouseOver".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getSeriesMouseOverEventHandler() != null) {
+ seriesPlotOptions.getSeriesMouseOverEventHandler().onMouseOver(new SeriesMouseOverEvent(nativeEvent, nativeSeries));
+ } else if ("mouseOut".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getSeriesMouseOutEventHandler() != null) {
+ seriesPlotOptions.getSeriesMouseOutEventHandler().onMouseOut(new SeriesMouseOutEvent(nativeEvent, nativeSeries));
+ } else if ("show".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getSeriesShowEventHandler() != null) {
+ seriesPlotOptions.getSeriesShowEventHandler().onShow(new SeriesShowEvent(nativeEvent, nativeSeries));
+ }
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private void pointEventCallback(JavaScriptObject nativePoint, JavaScriptObject nativeEvent, String eventType) {
+ if ("click".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getPointClickEventHandler() != null) {
+ seriesPlotOptions.getPointClickEventHandler().onClick(new PointClickEvent(nativeEvent, nativePoint));
+ } else if ("mouseOver".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getPointMouseOverEventHandler() != null) {
+ seriesPlotOptions.getPointMouseOverEventHandler().onMouseOver(new PointMouseOverEvent(nativeEvent, nativePoint));
+ } else if ("mouseOut".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getPointMouseOutEventHandler() != null) {
+ seriesPlotOptions.getPointMouseOutEventHandler().onMouseOut(new PointMouseOutEvent(nativeEvent, nativePoint));
+ } else if ("remove".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getPointRemoveEventHandler() != null) {
+ seriesPlotOptions.getPointRemoveEventHandler().onRemove(new PointRemoveEvent(nativeEvent, nativePoint));
+ } else if ("select".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getPointSelectEventHandler() != null) {
+ seriesPlotOptions.getPointSelectEventHandler().onSelect(new PointSelectEvent(nativeEvent, nativePoint));
+ } else if ("unselect".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getPointUnselectEventHandler() != null) {
+ seriesPlotOptions.getPointUnselectEventHandler().onUnselect(new PointUnselectEvent(nativeEvent, nativePoint));
+ } else if ("update".equals(eventType) && seriesPlotOptions != null && seriesPlotOptions.getPointUpdateEventHandler() != null) {
+ seriesPlotOptions.getPointUpdateEventHandler().onUpdate(new PointUpdateEvent(nativeEvent, nativePoint));
+ } else if ("legendItemClick".equals(eventType) && piePlotOptions != null && piePlotOptions.getPointLegendItemClickEventHandler() != null) {
+ piePlotOptions.getPointLegendItemClickEventHandler().onClick(new PointLegendItemClickEvent(nativeEvent, nativePoint));
+ }
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private String toolTipFormatterCallback(JavaScriptObject nativeData) {
+ if (toolTip == null || toolTip.getToolTipFormatter() == null) {
+ return null;
+ }
+ return toolTip.getToolTipFormatter().format(new ToolTipData(nativeData));
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private String xAxisLabelFormatterCallback(JavaScriptObject nativeData, int axisIndex) {
+ if (xAxes == null || xAxes.size() <= axisIndex ||
+ xAxes.get(axisIndex).getLabels() == null ||
+ xAxes.get(axisIndex).getLabels().getFormatter() == null) {
+ return null;
+ }
+ return xAxes.get(axisIndex).getLabels().getFormatter().format(new AxisLabelsData(nativeData));
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private String yAxisLabelFormatterCallback(JavaScriptObject nativeData, int axisIndex) {
+ if (yAxes == null || yAxes.size() <= axisIndex ||
+ yAxes.get(axisIndex).getLabels() == null ||
+ yAxes.get(axisIndex).getLabels().getFormatter() == null) {
+ return null;
+ }
+ return yAxes.get(axisIndex).getLabels().getFormatter().format(new AxisLabelsData(nativeData));
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private String yAxisStackLabelFormatterCallback(JavaScriptObject nativeData, int axisIndex) {
+ if (yAxes == null || yAxes.size() <= axisIndex ||
+ yAxes.get(axisIndex).getStackLabels() == null ||
+ yAxes.get(axisIndex).getStackLabels().getFormatter() == null) {
+ return null;
+ }
+ return yAxes.get(axisIndex).getStackLabels().getFormatter().format(new StackLabelsData(nativeData));
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private String plotOptionsLabelsFormatterCallback(JavaScriptObject nativeData, String type) {
+ PlotOptions plotOptions = null;
+ if ("area".equals(type)) plotOptions = areaPlotOptions;
+ if ("areaspline".equals(type)) plotOptions = areaSplinePlotOptions;
+ if ("bar".equals(type)) plotOptions = barPlotOptions;
+ if ("column".equals(type)) plotOptions = columnPlotOptions;
+ if ("line".equals(type)) plotOptions = linePlotOptions;
+ if ("pie".equals(type)) plotOptions = piePlotOptions;
+ if ("scatter".equals(type)) plotOptions = scatterPlotOptions;
+ if ("series".equals(type)) plotOptions = seriesPlotOptions;
+ if ("spline".equals(type)) plotOptions = splinePlotOptions;
+
+ if (plotOptions == null || plotOptions.getDataLabels() == null || plotOptions.getDataLabels().getFormatter() == null) {
+ return null;
+ }
+ return plotOptions.getDataLabels().getFormatter().format(new DataLabelsData(nativeData));
+ }
+
+ @SuppressWarnings({"UnusedDeclaration"})
+ private String seriesLabelsFormatterCallback(JavaScriptObject nativeData, int seriesIndex) {
+ if (seriesList == null || seriesList.size() <= seriesIndex ||
+ seriesList.get(seriesIndex).getPlotOptions() == null ||
+ seriesList.get(seriesIndex).getPlotOptions().getDataLabels() == null ||
+ seriesList.get(seriesIndex).getPlotOptions().getDataLabels().getFormatter() == null) {
+ return null;
+ }
+ return seriesList.get(seriesIndex).getPlotOptions().getDataLabels().getFormatter().format(new DataLabelsData(nativeData));
+ }
+
+ private static native void nativeRedraw(JavaScriptObject chart) /*-{
+ chart.redraw();
+ }-*/;
+
+ private static native void nativeDestroy(JavaScriptObject chart) /*-{
+ chart.destroy();
+ }-*/;
+
+ private static native void nativeSetSize(JavaScriptObject chart, int width, int height, boolean animated) /*-{
+ chart.setSize(width, height, animated);
+ }-*/;
+
+ private static native void nativeSetSize(JavaScriptObject chart, int width, int height, JavaScriptObject animation) /*-{
+ chart.setSize(width, height, animation);
+ }-*/;
+
+ private static native JavaScriptObject nativeGet(JavaScriptObject chart, String id) /*-{
+ return chart.get(id);
+ }-*/;
+
+ private static native void nativeAddSeries(JavaScriptObject chart, JavaScriptObject seriesOptions, boolean redraw, boolean animationFlag) /*-{
+ chart.addSeries(seriesOptions, redraw, animationFlag);
+ }-*/;
+
+ private static native void nativeAddSeries(JavaScriptObject chart, JavaScriptObject seriesOptions, boolean redraw, JavaScriptObject animationOptions) /*-{
+ chart.addSeries(seriesOptions, redraw, animationOptions);
+ }-*/;
+
+ private static native void nativeRemoveSeries(JavaScriptObject chart, JavaScriptObject nativeSeries, boolean redraw) /*-{
+ nativeSeries.remove(redraw);
+ }-*/;
+
+ private static native void nativeHideLoading(JavaScriptObject chart) /*-{
+ chart.hideLoading();
+ }-*/;
+
+ private static native void nativeShowLoading(JavaScriptObject chart, String message) /*-{
+ chart.showLoading(message);
+ }-*/;
+
+ private static native void nativePrint(JavaScriptObject chart) /*-{
+ chart.print();
+ }-*/;
+
+ private static native JsArrayString nativeGetSelectedSeriesIds(JavaScriptObject chart) /*-{
+ var seriesIds = [];
+ var selectedSeries = chart.getSelectedSeries();
+ for (var i = 0; i < selectedSeries.length; i++) {
+ seriesIds.push(selectedSeries[i].options["id"]);
+ }
+ return seriesIds;
+ }-*/;
+
+ private static native JsArray
+ * For details on available options see the Highcharts reference.
+ *
+ * Note that in order for this widget to function you must have included the Highcharts javascript
+ * library and any of its dependencies in the page that the widget will run inside of. E.g.:
+ *
+ * Chart chart = new Chart()
+ * .setType(Series.Type.SPLINE)
+ * .setChartTitleText("Nice Chart")
+ * .setMarginRight(10);
+ * Series series = chart.createSeries()
+ * .addPoint(40)
+ * .addPoint(35)
+ * .addPoint(60);
+ * chart.addSeries(series);
+ * RootPanel.get().add(chart);
+ *
+ * <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ * <script type="text/javascript" src="js/highcharts.js"></script>
+ *
+ * <!-- Optionally, add a highcharts theme file -->
+ * <script type="text/javascript" src="js/themes/gray.js"></script>
+ *
+ * Note that Highcharts supports other JS frameworks besides jQuery for its internal DOM manipulation
+ * functionality. So, if jQuery isn't your cup of tea check the
+ * installation docs
+ * on the Highcharts site for more details.
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Chart extends BaseChart
+ * <!-- Optionally, include the highcharts exporting module -->
+ * <script type="text/javascript" src="js/modules/exporting.js"></script>
+ *
+ */
+ public Chart() {
+ super();
+ }
+
+ /**
+ * Sets which dimensions the user can zoom by dragging the mouse.
+ * Can be one of {@link Chart.ZoomType#X}, {@link Chart.ZoomType#Y} or
+ * {@link Chart.ZoomType#X_AND_Y}. Defaults to null.
+ * This is equivalent to setting the option manually with code like:
+ *
+ * Chart chart = new Chart()
+ * .setType(Series.Type.SPLINE)
+ * .setChartTitleText("Nice Chart")
+ * .setMarginRight(10);
+ * RootPanel.get().add(chart);
+ *
+ *
+ * @param zoomType One of the allowed zoom types.
+ * @return A reference to this {@link Chart} instance for convenient method chaining.
+ */
+ public Chart setZoomType(Chart.ZoomType zoomType) {
+ return this.setOption("/chart/zoomType", zoomType != null ? zoomType.toString() : null);
+ }
+
+
+ @Override
+ protected String getChartTypeName() {
+ return "Chart";
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/ChartSubtitle.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/ChartSubtitle.java
new file mode 100755
index 00000000000..f373fc57c72
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/ChartSubtitle.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A configurable class that can be used to represent custom sub title options for the
+ * chart, which can then be set on the chart (via the {@link Chart#setChartSubtitle(ChartSubtitle)} method.)
+ * Example usage:
+ *
+ * chart.setOption("/chart/zoomType", Chart.ZoomType.X);
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class ChartSubtitle extends Configurable
+ * chart.setChartSubTitle(
+ * new ChartSubtitle()
+ * .setText("Source: Wikipedia")
+ * .setAlign(ChartTitle.Align.MIDDLE)
+ * );
+ *
+ * The horizontal alignment of the subtitle. Can be one of "left", "center" and "right".
+ * Defaults to {@link ChartTitle.Align#CENTER}.
+ *
+ * @param align The horizontal alignment of the subtitle.
+ * @return A reference to this {@link ChartSubtitle} instance for convenient method chaining.
+ */
+ public ChartSubtitle setAlign(ChartTitle.Align align) {
+ return this.setOption("align", align != null ? align.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'floating' option of the subtitle. Equivalent to:
+ *
+ * chartSubtitle.setOption("align", chartSubtitle.Align.LEFT);
+ *
+ * When the subtitle is floating, the plot area will not move to make space for it. Defaults to false.
+ *
+ * @param floating 'true' to float the subtitle above the plot area, or 'false' (the default) to make space for it.
+ * @return A reference to this {@link ChartSubtitle} instance for convenient method chaining.
+ */
+ public ChartSubtitle setFloating(boolean floating) {
+ return this.setOption("floating", floating);
+ }
+
+ /**
+ * Convenience method for setting the 'style' options of the subtitle. Equivalent to:
+ *
+ * chartSubtitle.setOption("floating", true);
+ *
+ * CSS styles for the subtitle. Exact positioning of the title can be achieved by changing the
+ * margin property, or by adding position: "absolute" and left and top properties. Defaults to:
+ *
+ * chartSubtitle.setOption("/style/fontWeight", "bold");
+ * chartSubtitle.setOption("/style/fontFamily", "serif");
+ * etc.
+ *
+ *
+ *
+ * @param style CSS styles for the subtitle.
+ * @return A reference to this {@link ChartSubtitle} instance for convenient method chaining.
+ */
+ public ChartSubtitle setStyle(Style style) {
+ return this.setOption("style", style != null ? style.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'text' option of the subtitle. Equivalent to:
+ *
+ * The actual text of the axis subtitle. It can contain basic HTML text markup
+ * like <b>, <i> and spans with style. Defaults to null.
+ *
+ * Note to disable an axis subtitle from being displayed completely, simply set the text
+ * to "null". (This can also be accomplished more simply by just setting the subtitle
+ * text to null directly on the axis via the {@link Axis#setAxisTitleText(String)} method.)
+ *
+ * @param text The actual text of the axis subtitle.
+ * @return A reference to this {@link ChartSubtitle} instance for convenient method chaining.
+ */
+ public ChartSubtitle setText(String text) {
+ return this.setOption("text", text);
+ }
+
+ /**
+ * Convenience method for setting the 'verticalAlign' option of the subtitle. Equivalent to:
+ *
+ * chartSubtitle.setOption("text", "Sales by Month");
+ *
+ * The vertical alignment of the subtitle. Can be one of "top", "middle" and "bottom". Defaults to "top".
+ * Defaults to {@link ChartTitle.VerticalAlign#TOP}.
+ *
+ * @param verticalAlign The vertical alignment of the subtitle.
+ * @return A reference to this {@link ChartSubtitle} instance for convenient method chaining.
+ */
+ public ChartSubtitle setVerticalAlign(ChartTitle.VerticalAlign verticalAlign) {
+ return this.setOption("verticalAlign", verticalAlign != null ? verticalAlign.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'x' position option of the subtitle. Equivalent to:
+ *
+ * chartSubtitle.setOption("verticalAlign", chartSubtitle.VerticalAlign.BOTTOM);
+ *
+ * The x position of the subtitle relative to the alignment within the spacing set on the chart
+ * controlled via {@link Chart#setSpacingLeft(Number)} and {@link Chart#setSpacingRight(Number)}.
+ * Defaults to 0.
+ *
+ * @param x The x position of the subtitle, relative to the chart's spacing.
+ * @return A reference to this {@link ChartSubtitle} instance for convenient method chaining.
+ */
+ public ChartSubtitle setX(Number x) {
+ return this.setOption("x", x);
+ }
+
+ /**
+ * Convenience method for setting the 'y' position option of the subtitle. Equivalent to:
+ *
+ * chartSubtitle.setOption("x", 70);
+ *
+ * The y position of the subtitle relative to the alignment within the spacing set on the chart
+ * controlled via {@link Chart#setSpacingTop(Number)} and {@link Chart#setSpacingBottom(Number)}.
+ * Defaults to 25.
+ *
+ * @param y The y position of the subtitle, relative to the chart's spacing.
+ * @return A reference to this {@link ChartSubtitle} instance for convenient method chaining.
+ */
+ public ChartSubtitle setY(Number y) {
+ return this.setOption("y", y);
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/ChartTitle.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/ChartTitle.java
new file mode 100755
index 00000000000..297dea15c5a
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/ChartTitle.java
@@ -0,0 +1,234 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A configurable class that can be used to represent custom title options for the
+ * chart, which can then be set the chart (via the {@link Chart#setChartTitle(ChartTitle)} method.)
+ * Example usage:
+ *
+ * chartSubtitle.setOption("y", -20);
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class ChartTitle extends Configurable
+ * chart.setChartTitle(
+ * new ChartTitle()
+ * .setText("Sales by Month")
+ * .setAlign(ChartTitle.Align.MIDDLE)
+ * );
+ *
+ * The horizontal alignment of the title. Can be one of "left", "center" and "right".
+ * Defaults to {@link ChartTitle.Align#CENTER}.
+ *
+ * @param align The horizontal alignment of the title.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setAlign(Align align) {
+ return this.setOption("align", align != null ? align.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'floating' option of the title. Equivalent to:
+ *
+ * chartTitle.setOption("align", ChartTitle.Align.LEFT);
+ *
+ * When the title is floating, the plot area will not move to make space for it. Defaults to false.
+ *
+ * @param floating 'true' to float the title above the plot area, or 'false' (the default) to make space for it.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setFloating(boolean floating) {
+ return this.setOption("floating", floating);
+ }
+
+ /**
+ * Convenience method for setting the 'margin' option of the title. Equivalent to:
+ *
+ * chartTitle.setOption("floating", true);
+ *
+ * The margin between the title and the plot area, or if a subtitle is present,
+ * the margin between the subtitle and the plot area. Defaults to 15.
+ *
+ * @param margin The margin between the title and the plot area, or if a subtitle is present,
+ * the margin between the subtitle and the plot area.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setMargin(Number margin) {
+ return this.setOption("margin", margin);
+ }
+
+ /**
+ * Convenience method for setting the 'style' options of the title. Equivalent to:
+ *
+ * chartTitle.setOption("margin", 60);
+ *
+ * CSS styles for the title. Use this for font styling, but use {@link #setAlign(org.moxieapps.gwt.highcharts.client.ChartTitle.Align)},
+ * {@link #setX(Number)}, and {@link #setY(Number)} for text alignment. Defaults to:
+ *
+ * chartTitle.setOption("/style/fontWeight", "bold");
+ * chartTitle.setOption("/style/fontFamily", "serif");
+ * etc.
+ *
+ *
+ *
+ * @param style CSS styles for the title.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setStyle(Style style) {
+ return this.setOption("style", style != null ? style.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'text' option of the title. Equivalent to:
+ *
+ * The actual text of the axis title. It can contain basic HTML text markup
+ * like <b>, <i> and spans with style. Defaults to null.
+ *
+ * Note to disable an axis title from being displayed completely, simply set the text
+ * to "null". (This can also be accomplished more simply by just setting the title
+ * text to null directly on the axis via the {@link Axis#setAxisTitleText(String)} method.)
+ *
+ * @param text The actual text of the axis title.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setText(String text) {
+ return this.setOption("text", text);
+ }
+
+ /**
+ * Convenience method for setting the 'verticalAlign' option of the title. Equivalent to:
+ *
+ * chartTitle.setOption("text", "Sales by Month");
+ *
+ * The vertical alignment of the title. Can be one of "top", "middle" and "bottom". Defaults to "top".
+ * Defaults to {@link ChartTitle.VerticalAlign#TOP}.
+ *
+ * @param verticalAlign The vertical alignment of the title.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setVerticalAlign(VerticalAlign verticalAlign) {
+ return this.setOption("verticalAlign", verticalAlign != null ? verticalAlign.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'x' position option of the title. Equivalent to:
+ *
+ * chartTitle.setOption("verticalAlign", ChartTitle.VerticalAlign.BOTTOM);
+ *
+ * The x position of the title relative to the alignment within the spacing set on the chart
+ * controlled via {@link Chart#setSpacingLeft(Number)} and {@link Chart#setSpacingRight(Number)}.
+ * Defaults to 0.
+ *
+ * @param x The x position of the title, relative to the chart's spacing.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setX(Number x) {
+ return this.setOption("x", x);
+ }
+
+ /**
+ * Convenience method for setting the 'y' position option of the title. Equivalent to:
+ *
+ * chartTitle.setOption("x", 70);
+ *
+ * The y position of the title relative to the alignment within the spacing set on the chart
+ * controlled via {@link Chart#setSpacingTop(Number)} and {@link Chart#setSpacingBottom(Number)}.
+ * Defaults to 25.
+ *
+ * @param y The y position of the title, relative to the chart's spacing.
+ * @return A reference to this {@link ChartTitle} instance for convenient method chaining.
+ */
+ public ChartTitle setY(Number y) {
+ return this.setOption("y", y);
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Color.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Color.java
new file mode 100755
index 00000000000..eaf3f512b4b
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Color.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+import com.google.gwt.json.client.JSONArray;
+import com.google.gwt.json.client.JSONNumber;
+import com.google.gwt.json.client.JSONString;
+import com.google.gwt.json.client.JSONValue;
+
+/**
+ * Represents a color as either a solid RGB color, an RBG color with an alpha channel,
+ * or a gradient of colors. Many of the configurable chart objects support setting various
+ * color options (backgrounds, borders, etc). They all support a simply mechanism for
+ * setting the color to a standard RGB hex value (such as {@link Chart#setBackgroundColor(String)}.
+ * However, if they also support alpha channels or gradients an overloaded method will be
+ * provided that takes a Color instance instead (e.g. {@link Chart#setBackgroundColor(Color)}.
+ *
+ * Example which sets the background color to a 10% opacity red color:
+ *
+ * chartTitle.setOption("y", -20);
+ *
+ *
+ * Example which sets the background color to a linear gradient from white to
+ * a 50% opaque blue:
+ *
+ * chart.setBackgroundColor(new Color(255, 0, 0, .1));
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Color extends Configurable
+ * chart.setBackgroundColor(new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addColorStop(0, "#FFFFFF")
+ * .addColorStop(0, 200, 200, 255, 0.5)
+ * );
+ *
+ * Or:
+ *
+ * color.setLinearGradient("0", "0", "500", "500");
+ *
+ * Note that you can also use the {@link #setLinearGradient(int, int, int, int)}
+ * version if you know you're only going to be operating in pixels, or the
+ * {@link #setLinearGradient(double, double, double, double)} if you're only operating
+ * in percentages.
+ *
+ * @param x0 The x-coordinate of the start point of the gradient.
+ * @param y0 The y-coordinate of the start point of the gradient.
+ * @param x1 The x-coordinate of the end point of the gradient.
+ * @param y1 The y-coordinate of the end point of the gradient.
+ * @return A reference to this {@link Color} instance for convenient method chaining.
+ */
+ public Color setLinearGradient(String x0, String y0, String x1, String y1) {
+ value = null;
+ JSONArray coordinates = new JSONArray();
+ coordinates.set(0, new JSONString(x0));
+ coordinates.set(1, new JSONString(y0));
+ coordinates.set(2, new JSONString(x1));
+ coordinates.set(3, new JSONString(y1));
+ return this.setOption("linearGradient", coordinates);
+ }
+
+ /**
+ * Sets up this color as a linear gradient from one location in space to another, specifying
+ * the coordinates in pixels.
+ *
+ * Note that you can also use the {@link #setLinearGradient(double, double, double, double)}
+ * version if you know you instead want to operate in percentages, or the
+ * {@link #setLinearGradient(String, String, String, String)} version if you need to
+ * operate in both percentages and pixels concurrently.
+ *
+ * @param x0 The x-coordinate of the start point of the gradient (in pixels).
+ * @param y0 The y-coordinate of the start point of the gradient (in pixels).
+ * @param x1 The x-coordinate of the end point of the gradient (in pixels).
+ * @param y1 The y-coordinate of the end point of the gradient (in pixels).
+ * @return A reference to this {@link Color} instance for convenient method chaining.
+ */
+ public Color setLinearGradient(int x0, int y0, int x1, int y1) {
+ value = null;
+ JSONArray coordinates = new JSONArray();
+ coordinates.set(0, new JSONNumber(x0));
+ coordinates.set(1, new JSONNumber(y0));
+ coordinates.set(2, new JSONNumber(x1));
+ coordinates.set(3, new JSONNumber(y1));
+ return this.setOption("linearGradient", coordinates);
+ }
+
+ /**
+ * Sets up this color as a linear gradient from one location in space to another, specifying
+ * the coordinates in percentages of the space the gradient will fill. Note that the percentage
+ * is specified by providing a floating point number in the range of 0.0 to 1.0, where 0.0 is
+ * equivalent to "0%" and 1.0 is equivalent to "100%".
+ *
+ * Note that you can also use the {@link #setLinearGradient(int, int, int, int)}
+ * version if you know you instead want to operate in pixels, or the
+ * {@link #setLinearGradient(String, String, String, String)} version if you need to
+ * operate in both percentages and pixels concurrently.
+ *
+ * @param x0 The x-percentage of the start point of the gradient (0.0 to 1.0)
+ * @param y0 The y-percentage of the start point of the gradient (0.0 to 1.0)
+ * @param x1 The x-percentage of the end point of the gradient (0.0 to 1.0)
+ * @param y1 The y-percentage of the end point of the gradient (0.0 to 1.0)
+ * @return A reference to this {@link Color} instance for convenient method chaining.
+ */
+ public Color setLinearGradient(double x0, double y0, double x1, double y1) {
+ value = null;
+ JSONArray coordinates = new JSONArray();
+ coordinates.set(0, new JSONString(((Double) (x0 * 100)).intValue() + "%"));
+ coordinates.set(1, new JSONString(((Double) (y0 * 100)).intValue() + "%"));
+ coordinates.set(2, new JSONString(((Double) (x1 * 100)).intValue() + "%"));
+ coordinates.set(3, new JSONString(((Double) (y1 * 100)).intValue() + "%"));
+ return this.setOption("linearGradient", coordinates);
+ }
+
+ private JSONArray colorStops = new JSONArray();
+
+ /**
+ * Adds the specified color at some position within the gradient (to be used in
+ * conjunction with the {@link #setLinearGradient(double, double, double, double)} method
+ * or another one of its overloaded variants.)
+ *
+ * Example which sets the background color to a linear gradient from white to blue:
+ *
+ * color.setLinearGradient("20%", "20%", "80%", "80%");
+ *
+ * Note that this method is intended to be used when you simply want to set the gradient
+ * stop color to a standard RGB hex value. If you need more control use the
+ * {@link #addColorStop(double, int, int, int)} or {@link #addColorStop(double, int, int, int, double)}
+ * method instead.
+ *
+ * @param offset A floating point value between 0.0 and 1.0 that represents the position
+ * between the start and end points in a gradient.
+ * @param rgbHexColor The RGB hex color that the gradient should display at the given offset (include the "#").
+ * @return A reference to this {@link Color} instance for convenient method chaining.
+ */
+ public Color addColorStop(double offset, String rgbHexColor) {
+ return this.internalAddColorStop(offset, rgbHexColor);
+ }
+
+ /**
+ * Adds the specified color at some position within the gradient (to be used in
+ * conjunction with the {@link #setLinearGradient(double, double, double, double)} method
+ * or another one of its overloaded variants.)
+ *
+ * Example which sets the background color to a linear gradient from white to blue:
+ *
+ * chart.setBackgroundColor(new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addColorStop(0.0, "#FFFFFF")
+ * .addColorStop(0.0, "#0000FF")
+ * );
+ *
+ * Note that this method is intended to be used when you simply want to set the gradient
+ * stop color to a standard RGB hex value. If you need more control use the
+ * {@link #addColorStop(double, int, int, int, double)} method instead.
+ *
+ * @param offset A floating point value between 0.0 and 1.0 that represents the position
+ * between the start and end points in a gradient.
+ * @param r The red component of the color in the RGB color space (0 to 255)
+ * @param g The green component of the color in the RGB color space (0 to 255)
+ * @param b The blue component of the color in the RGB color space (0 to 255)
+ * @return A reference to this {@link Color} instance for convenient method chaining.
+ */
+ public Color addColorStop(double offset, int r, int g, int b) {
+ return this.internalAddColorStop(offset, createRGB(r, g, b));
+ }
+
+ /**
+ * Adds the specified color at some position within the gradient allowing for the color
+ * to be specified with an alpha channel (to be used in conjunction with the
+ * {@link #setLinearGradient(double, double, double, double)} method or another one of its overloaded variants.)
+ *
+ * Example which sets the background color to a linear gradient from solid white to
+ * a 50% opaque blue:
+ *
+ * chart.setBackgroundColor(new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addColorStop(0.0, 255, 255, 255)
+ * .addColorStop(0.0, 0, 0, 255)
+ * );
+ *
+ *
+ * @param offset A floating point value between 0.0 and 1.0 that represents the position
+ * between the start and end points in a gradient.
+ * @param r The red component of the color in the RGB color space (0 to 255)
+ * @param g The green component of the color in the RGB color space (0 to 255)
+ * @param b The blue component of the color in the RGB color space (0 to 255)
+ * @param a The alpha channel of the color (0.0 to 1.0)
+ * @return A reference to this {@link Color} instance for convenient method chaining.
+ */
+ public Color addColorStop(double offset, int r, int g, int b, double a) {
+ return this.internalAddColorStop(offset, createRGBA(r, g, b, a));
+ }
+
+ /**
+ * This method will return the value of the object as a single value if it is
+ * represented as just a solid color or as a JSONObject if it represents a gradient.
+ * Note that this method is primarily intended for internal use.
+ *
+ * @return The value of this object as a single value (if appropriate), or a JSONObject
+ * if this color represents a gradient.
+ */
+ public JSONValue getOptionValue() {
+ return value != null ? value : this.getOptions();
+ }
+
+ // Internal helper methods
+ private Color internalAddColorStop(double offset, String color) {
+ value = null;
+ JSONArray colorStop = new JSONArray();
+ colorStop.set(0, new JSONNumber(offset));
+ colorStop.set(1, new JSONString(color));
+ colorStops.set(colorStops.size(), colorStop);
+ return this.setOption("stops", colorStops);
+ }
+
+ private String createRGB(int r, int g, int b) {
+ return new StringBuilder()
+ .append("rgb(")
+ .append(r)
+ .append(",")
+ .append(g)
+ .append(",")
+ .append(b)
+ .append(")").toString();
+ }
+
+ private String createRGBA(int r, int g, int b, double a) {
+ return new StringBuilder()
+ .append("rgba(")
+ .append(r)
+ .append(",")
+ .append(g)
+ .append(",")
+ .append(b)
+ .append(",")
+ .append(a)
+ .append(")").toString();
+ }
+
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Configurable.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Configurable.java
new file mode 100755
index 00000000000..2e2a51c0e4e
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Configurable.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.json.client.*;
+
+/**
+ * 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
+ * {@link #setOption(String, Object)} method that will allow for a configuration option
+ * to be set at any level.
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public abstract class Configurable
+ * chart.setBackgroundColor(new Color()
+ * .setLinearGradient(0.0, 0.0, 1.0, 1.0)
+ * .addColorStop(0.0, 255, 255, 255)
+ * .addColorStop(0.0, 0, 0, 255, 0.5)
+ * );
+ *
+ * Would result in initializing HighCharts like the following:
+ *
+ * Chart chart = new Chart();
+ * chart.setOption("/chart/type", "spline");
+ * chart.setOption("/chart/marginRight", 10);
+ * chart.setOption("/title/text", "Nice Chart");
+ *
+ * Note that the beginning "/" is optional, so
+ * new HighCharts.Chart({
+ * chart: {
+ * type: "spline",
+ * marginRight: 10
+ * },
+ * title: {
+ * text: "Nice Chart"
+ * }
+ * });
+ * 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:
+ *
+ * Do this instead:
+ *
+ * series.setOption("type", "spline");
+ *
+ *
+ * @param path The path to the option to set (e.g. "/title/text");
+ * @param value The value to set for the option (can be a String, Number, Boolean, or JSONObject)
+ * @return A reference to this {@link Configurable} instance for convenient method chaining.
+ */
+ public T setOption(String path, Object value) {
+ if (options == null) {
+ options = new JSONObject();
+ }
+ setOption(options, path, value);
+ @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
+ final T instance = (T) this;
+ return instance;
+ }
+
+ /**
+ * Retrieve all of the options that have been configured for this instance
+ * as a JSONObject.
+ *
+ * @return A JSONObject representing all of the configuration options
+ * that have been set on the instance (will be null if no options have been set)
+ */
+ public JSONObject getOptions() {
+ return options;
+ }
+
+ // Internal...
+ private void setOption(JSONObject rootObject, String path, Object value) {
+ if (path == null) {
+ return;
+ }
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+ if (path.length() <= 0) {
+ return;
+ }
+ String nodeName = path;
+ if (nodeName.contains("/")) {
+ nodeName = nodeName.substring(0, nodeName.indexOf("/"));
+ JSONValue objectAsValue = rootObject.get(nodeName);
+ if (objectAsValue == null || objectAsValue.isObject() == null) {
+ rootObject.put(nodeName, new JSONObject());
+ }
+ JSONObject object = (JSONObject) rootObject.get(nodeName);
+ setOption(object, path.substring(path.indexOf("/") + 1), value);
+ } else {
+ rootObject.put(nodeName, convertToJSONValue(value));
+ }
+ }
+
+ private JSONValue convertToJSONValue(Object value) {
+ if (value == null) {
+ return JSONNull.getInstance();
+ } else if(value instanceof JSONValue) {
+ return (JSONValue)value;
+ } if (value instanceof Boolean) {
+ return JSONBoolean.getInstance((Boolean) value);
+ } else if (value instanceof Number) {
+ return new JSONNumber(((Number) value).doubleValue());
+ } else if (value instanceof String) {
+ return new JSONString((String) value);
+ } else if (value instanceof JavaScriptObject) {
+ return new JSONObject((JavaScriptObject)value);
+ } else if (value instanceof Configurable) {
+ return ((Configurable)value).getOptions();
+ } else if (value.getClass().isArray()) {
+ JSONArray jsonArray = new JSONArray();
+ Object[] valueArray = (Object[]) value;
+ for (int i = 0, valueArrayLength = valueArray.length; i < valueArrayLength; i++) {
+ Object arrayValue = valueArray[i];
+ jsonArray.set(i, convertToJSONValue(arrayValue));
+ }
+ return jsonArray;
+ }
+ return null;
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Credits.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Credits.java
new file mode 100755
index 00000000000..f292d2923dc
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Credits.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A configurable class that can be used to represent custom credits options for the
+ * chart, which can then be set on the chart (via the {@link Chart#setCredits(Credits)} method.)
+ * Highchart by default puts a credits label in the lower right corner of the chart.
+ * This can be changed using these options. Example usage:
+ *
+ * series.setType(Series.Type.SPLINE);
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Credits extends Configurable
+ * chart.setCredits(
+ * new Credits()
+ * .setText("Presented by Snoopy")
+ * .setHref("http://www.peanuts.com/")
+ * );
+ *
+ * The horizontal alignment of the credits text within the chart area. Can be one of "left", "center" and "right".
+ * Defaults to {@link Credits.Align#RIGHT}.
+ *
+ * @param align The horizontal alignment of the credits text within the chart area.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setAlign(Align align) {
+ return this.setOption("/position/align", align != null ? align.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'enabled' option for the credits. Equivalent to:
+ *
+ * credits.setOption("/position/align", Credit.Align.LEFT);
+ *
+ * Whether to show the credits text. Defaults to true.
+ *
+ * @param enabled Whether or not to enable or disable the credits text.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setEnabled(boolean enabled) {
+ return this.setOption("enabled", enabled);
+ }
+
+ /**
+ * Convenience method for setting the 'href' option of the credits. Equivalent to:
+ *
+ * credits.setOption("enabled", true);
+ *
+ * The URL for the credits label. Defaults to "http://www.highcharts.com".
+ *
+ * @param href The URL for the credits label.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setHref(String href) {
+ return this.setOption("href", href);
+ }
+
+ /**
+ * Convenience method for setting the 'style' options of the credits. Equivalent to:
+ *
+ * credits.setOption("href", "http://www.peanuts.com/");
+ *
+ * CSS styles for the credits label. . Defaults to:
+ *
+ * credits.setOption("/style/fontWeight", "bold");
+ * credits.setOption("/style/fontFamily", "serif");
+ * etc.
+ *
+ *
+ *
+ * @param style An object containing the style properties to set on the credits.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setStyle(Style style) {
+ return this.setOption("style", style != null ? style.getOptions() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'text' option of the credits. Equivalent to:
+ *
+ * The text for the credits label. Defaults to "Highcharts.com".
+ *
+ * @param text The text for the credits label.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setText(String text) {
+ return this.setOption("text", text);
+ }
+
+ /**
+ * Convenience method for setting the 'verticalAlign' option of the credits. Equivalent to:
+ *
+ * credits.setOption("text", "Thanks to Snoopy");
+ *
+ * The vertical alignment of the legend box. Can be one of "top", "middle" or "bottom".
+ * Vertical position can be further determined by the y option.
+ * Defaults to {@link Legend.VerticalAlign#BOTTOM}.
+ *
+ * @param verticalAlign The vertical alignment of the credits.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setVerticalAlign(VerticalAlign verticalAlign) {
+ return this.setOption("/position/verticalAlign", verticalAlign != null ? verticalAlign.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'x' position option of the credits. Equivalent to:
+ *
+ * legend.setOption("/position/verticalAlign", Credits.VerticalAlign.BOTTOM);
+ *
+ * The x offset of the credits relative to it's horizontal alignment align within
+ * {@link Chart#setSpacingLeft(Number)} and {@link Chart#setSpacingRight(Number)}. Negative x
+ * moves it to the left, positive x moves it to the right. The default value of -10 together
+ * with {@link Align#RIGHT} puts it near the right side of the plot area. Defaults to -10.
+ *
+ * @param x The x offset of the credits, relative to the chart's spacing.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setX(Number x) {
+ return this.setOption("/position/x", x);
+ }
+
+ /**
+ * Convenience method for setting the 'y' position option of the credits. Equivalent to:
+ *
+ * legend.setOption("/position/x", 70);
+ *
+ * The vertical offset of the legend relative to it's vertical alignment (@link VerticalAlign}
+ * within {@link Chart#setSpacingTop(Number)} and {@link Chart#setSpacingBottom(Number)}.
+ * Negative y moves it up, positive y moves it down. Defaults to -5.
+ *
+ * @param y The y position of the credits, relative to the chart's spacing.
+ * @return A reference to this {@link Credits} instance for convenient method chaining.
+ */
+ public Credits setY(Number y) {
+ return this.setOption("/position/y", y);
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/DateTimeLabelFormats.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/DateTimeLabelFormats.java
new file mode 100755
index 00000000000..cdce9258741
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/DateTimeLabelFormats.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * Represents the configuration options available for controlling the way date and time information
+ * will be displayed. For a datetime axis, the scale will automatically adjust to the appropriate unit. This configuration
+ * class controls the default string format representations used for each unit. Defaults to:
+ *
+ * legend.setOption("/position/y", -20);
+ *
+ *
+ * Available replacement codes for the day of date are:
+ *
+ *
+ * Available replacement codes for the month of the date are:
+ *
+ *
+ * Available replacement codes for the year of the date are:
+ *
+ *
+ * Available replacement codes for the time portions are:
+ *
+ *
+ * Example usage:
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class DateTimeLabelFormats extends Configurable
+ * axis.setDateTimeLabelFormats(
+ * new DateTimeLabelFormats()
+ * .setHour("%I %p")
+ * .setMinute("%I:%M %p")
+ * );
+ *
+ *
+ * @param second The format to use when displaying labels in units of seconds.
+ * @return A reference to this {@link DateTimeLabelFormats} instance for convenient method chaining.
+ */
+ public DateTimeLabelFormats setSecond(String second) {
+ return this.setOption("second", second);
+ }
+
+ /**
+ * Convenience method for setting the 'minute' format. Equivalent to:
+ *
+ * dateTimeLabelFormats.setOption("second", "%H:%M:%S");
+ *
+ *
+ * @param minute The format to use when displaying labels in units of minutes.
+ * @return A reference to this {@link DateTimeLabelFormats} instance for convenient method chaining.
+ */
+ public DateTimeLabelFormats setMinute(String minute) {
+ return this.setOption("minute", minute);
+ }
+
+ /**
+ * Convenience method for setting the 'hour' format. Equivalent to:
+ *
+ * dateTimeLabelFormats.setOption("minute", "%H:%M");
+ *
+ *
+ * @param hour The format to use when displaying labels in units of hours.
+ * @return A reference to this {@link DateTimeLabelFormats} instance for convenient method chaining.
+ */
+ public DateTimeLabelFormats setHour(String hour) {
+ return this.setOption("hour", hour);
+ }
+
+ /**
+ * Convenience method for setting the 'day' format. Equivalent to:
+ *
+ * dateTimeLabelFormats.setOption("hour", "%H:%M");
+ *
+ *
+ * @param day The format to use when displaying labels in units of days.
+ * @return A reference to this {@link DateTimeLabelFormats} instance for convenient method chaining.
+ */
+ public DateTimeLabelFormats setDay(String day) {
+ return this.setOption("day", day);
+ }
+
+ /**
+ * Convenience method for setting the 'week' format. Equivalent to:
+ *
+ * dateTimeLabelFormats.setOption("day", "%e. %b");
+ *
+ *
+ * @param week The format to use when displaying labels in units of weeks.
+ * @return A reference to this {@link DateTimeLabelFormats} instance for convenient method chaining.
+ */
+ public DateTimeLabelFormats setWeek(String week) {
+ return this.setOption("week", week);
+ }
+
+ /**
+ * Convenience method for setting the 'month' format. Equivalent to:
+ *
+ * dateTimeLabelFormats.setOption("week", "%e. %b");
+ *
+ *
+ * @param month The format to use when displaying labels in units of month.
+ * @return A reference to this {@link DateTimeLabelFormats} instance for convenient method chaining.
+ */
+ public DateTimeLabelFormats setMonth(String month) {
+ return this.setOption("month", month);
+ }
+
+ /**
+ * Convenience method for setting the 'year' format. Equivalent to:
+ *
+ * dateTimeLabelFormats.setOption("month", "%b \'%y");
+ *
+ *
+ * @param year The format to use when displaying labels in units of year.
+ * @return A reference to this {@link DateTimeLabelFormats} instance for convenient method chaining.
+ */
+ public DateTimeLabelFormats setYear(String year) {
+ return this.setOption("year", year);
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Exporting.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Exporting.java
new file mode 100755
index 00000000000..22888ef1f19
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Exporting.java
@@ -0,0 +1,132 @@
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A configurable class that will allow you to control the options for exporting module. An instance of
+ * this class can be constructed and then set on the chart via the
+ * {@link BaseChart#setExporting(Exporting)} method.
+ *
+ * Note that the "exporting" module must be included in the page in order for the exporting
+ * navigation options to apply. E.g.:
+ *
+ * <script type="text/javascript" src="js/modules/exporting.js"></script>
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.1.0
+ */
+public class Exporting extends Configurable
+ * dateTimeLabelFormats.setOption("year", "%Y");
+ *
+ * Whether to enable the exporting module. Defaults to true, but note that the exporting module
+ * Javascript file must be included in the source of the page in order for the exporting
+ * functionality to appear.
+ *
+ * @param enabled Whether or not to enable or disable the exporting module for the chart.
+ * @return A reference to this {@link Exporting} instance for convenient method chaining.
+ */
+ public Exporting setEnabled(boolean enabled) {
+ return this.setOption("enabled", enabled);
+ }
+
+ /**
+ * Convenience method for setting the 'filename' option for the exporting module. Equivalent to:
+ *
+ * exporting.setOption("enabled", true);
+ *
+ * The filename, without extension, to use for the exported chart. Defaults to "chart".
+ *
+ * @param fileName The filename, without extension, to use for the exported chart.
+ * @return A reference to this {@link Exporting} instance for convenient method chaining.
+ */
+ public Exporting setFilename(String fileName) {
+ return this.setOption("fileName", fileName);
+ }
+
+ /**
+ * Convenience method for setting the 'type' option for the exporting module. Equivalent to:
+ *
+ * exporting.setOption("filename", true);
+ *
+ * Default MIME type for exporting if chart.exportChart() is called without specifying a type option.
+ * Possible values are image/png, image/jpeg, application/pdf and image/svg+xml. Defaults to "image/png".
+ *
+ * @param type The default file format that exported charts should be created as.
+ * @return A reference to this {@link Exporting} instance for convenient method chaining.
+ */
+ public Exporting setType(Type type) {
+ return this.setOption("type", type != null ? type.toString() : null);
+ }
+
+ /**
+ * Convenience method for setting the 'url' option for the exporting module. Equivalent to:
+ *
+ * exporting.setOption("type", "image/jpeg");
+ *
+ * The URL for the server module converting the SVG string to an image format. By default this
+ * points to Highslide Software's free web service. Defaults to http://export.highcharts.com.
+ *
+ * @param url The URL for the server module converting the SVG string to an image format.
+ * @return A reference to this {@link Exporting} instance for convenient method chaining.
+ */
+ public Exporting setUrl(String url) {
+ return this.setOption("url", url);
+ }
+
+ /**
+ * Convenience method for setting the 'width' option for the exporting module. Equivalent to:
+ *
+ * exporting.setOption("url", "http://export.highcharts.com");
+ *
+ * The pixel width of charts exported to PNG or JPG. Defaults to 800.
+ *
+ * @param width The pixel width of charts exported to PNG or JPG.
+ * @return A reference to this {@link Exporting} instance for convenient method chaining.
+ */
+ public Exporting setWidth(Number width) {
+ return this.setOption("width", width);
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Extremes.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Extremes.java
new file mode 100755
index 00000000000..9efc14f13a5
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Extremes.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A simple value object that is used to report the current extremes of an axis whenever
+ * the {@link Axis#getExtremes()} method is invoked (normally after the chart has been rendered).
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Extremes {
+
+ private Number dataMax;
+ private Number dataMin;
+ private Number max;
+ private Number min;
+
+ /**
+ * Use the {@link Axis#getExtremes()} method to gain
+ * access to 'Extremes' instance associated with the chart axis.
+ *
+ * @param dataMin The minimum value of the axis' associated series.
+ * @param dataMax The maximum value of the axis' associated series.
+ * @param min The minimum axis value, either automatic or set manually.
+ * @param max The maximum axis value, either automatic or set manually.
+ */
+ Extremes(Number dataMin, Number dataMax, Number min, Number max) {
+ this.dataMin = dataMin;
+ this.dataMax = dataMax;
+ this.min = min;
+ this.max = max;
+ }
+
+ /**
+ * Return the minimum value of the axis' associated series, or null if the extremes
+ * are requested before the chart has been rendered.
+ *
+ * @return The maximum value of the axis' associated series.
+ */
+ public Number getDataMin() {
+ return dataMin;
+ }
+
+ /**
+ * Return the maximum value of the axis' associated series, or null if the extremes
+ * are requested before the chart has been rendered.
+ *
+ * @return The maximum value of the axis' associated series.
+ */
+ public Number getDataMax() {
+ return dataMax;
+ }
+
+ /**
+ * Return the minimum axis value, either automatic or set manually. If the max option
+ * is not set and minPadding is 0, this value will be the same as {@link #getDataMin()}. Will
+ * return null if the extremes are requested before the chart has been rendered and
+ * no manual minimum has been set via {@link Axis#setMin(Number)}.
+ *
+ * @return The minimum axis value, either automatic or set manually.
+ */
+ public Number getMin() {
+ return min;
+ }
+
+ /**
+ * Return the maximum axis value, either automatic or set manually. If the max option
+ * is not set and maxPadding is 0, this value will be the same as {@link #getDataMax()}. Will
+ * return null if the extremes are requested before the chart has been rendered and
+ * no manual maximum has been set via {@link Axis#setMax(Number)}.
+ *
+ * @return The maximum axis value, either automatic or set manually.
+ */
+ public Number getMax() {
+ return max;
+ }
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/LabelItem.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/LabelItem.java
new file mode 100755
index 00000000000..ea36de02d7f
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/LabelItem.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A simple configurable object that can be used to position arbitrary HTML labels
+ * anywhere in the chart area. After creating a LabelItem it can then be added to the
+ * chart via the {@link Chart#setLabelItems(LabelItem...)} method. Example usage:
+ *
+ * exporting.setOption("width", 600);
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class LabelItem extends Configurable
+ * chart.setLabelItems(
+ * new LabelItem()
+ * .setHtml("United States")
+ * .setStyle(new Style()
+ * .setColor("#FF0000")
+ * .setTop("10px")
+ * .setLeft("10px")
+ * ),
+ * new LabelItem()
+ * .setHtml("Europe")
+ * .setStyle(new Style()
+ * .setColor("#0000FF")
+ * .setTop("10px")
+ * .setLeft("210px")
+ * ),
+ * );
+ *
+ * Inner HTML or text for the label. Defaults to "".
+ *
+ * @param html Inner HTML or text for the label.
+ * @return A reference to this {@link LabelItem} instance for convenient method chaining.
+ */
+ public LabelItem setHtml(String html) {
+ return this.setOption("html", html);
+ }
+
+ /**
+ * Convenience method for setting the 'style' options of the label item. Equivalent to:
+ *
+ * labelItem.setOption("html", "Australia");
+ *
+ * CSS styles for each label. To position the label, use left and top like this:
+ *
+ * labelItem.setOption("/style/left", "100px");
+ * labelItem.setOption("/style/top", "10px");
+ * etc.
+ *
+ *
+ * @param style CSS styles for each label
+ * @return A reference to this {@link LabelItem} instance for convenient method chaining.
+ */
+ public LabelItem setStyle(Style style) {
+ return this.setOption("style", style != null ? style.getOptions() : null);
+ }
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Lang.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Lang.java
new file mode 100755
index 00000000000..3bdb13d82a6
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Lang.java
@@ -0,0 +1,13 @@
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * TODO
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Lang {
+
+ // TODO
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Legend.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Legend.java
new file mode 100755
index 00000000000..14181eb8742
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Legend.java
@@ -0,0 +1,478 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A configurable class that can be used to represent custom legend options for the
+ * chart, which can then be set on the chart (via the {@link Chart#setLegend(Legend)} method.)
+ * The legend is a box containing a symbol and name for each series item or point item in the chart.
+ * Example usage:
+ *
+ * new LabelItem()
+ * .setHtml("Antarctica")
+ * .setStyle(new Style()
+ * .setColor("#0000FF")
+ * .setTop("10px")
+ * .setLeft("100px")
+ * )
+ *
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Legend extends Configurable
+ * chart.setLegend(
+ * new Legend()
+ * .setBorderColor("#CC0000")
+ * .setLayout(Legend.Layout.HORIZONTAL)
+ * );
+ *
+ * chart.addSeries(chart.createSeries()
+ * .setName("Browser share")
+ * .setPoints(new Point[]{
+ * new Point("Firefox", 45.0),
+ * new Point("IE", 26.8),
+ * new Point("Chrome", 12.8)
+ * .setSliced(true)
+ * .setSelected(true),
+ * new Point("Safari", 8.5),
+ * new Point("Opera", 6.2),
+ * new Point("Others", 0.7)
+ * })
+ * );
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Point extends Configurable
+ * point.setOption("color", "#CC0000");
+ *
+ * Individual color for the point. Defaults to null.
+ *
+ * @param color The value to set as the point's color.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ */
+ public Point setColor(String color) {
+ return this.setOption("color", color);
+ }
+
+ /**
+ * Override the individual point marker for the point. Defaults to null. E.g.
+ *
+ * new Point(10, 30)
+ * .setMarker(
+ * new Marker()
+ * .setEnabled(true)
+ * .setFillColor("#CC0000")
+ * .setRadius(4)
+ * );
+ *
+ *
+ * Note that this method is intended to be used to override the marker options of one
+ * particular point. If you instead want to control the marker options for the entire
+ * series, use the {@link org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions#setMarker(Marker)}
+ * method instead.
+ *
+ * @param marker The override marker options for this particular point, or null to
+ * simply use the whatever default marker options have been applied to whole series
+ * via {@link org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions#setMarker(Marker)}
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point setMarker(Marker marker) {
+ return this.setOption("marker", marker != null ? marker.getOptions() : null);
+ }
+
+ private String name;
+
+ /**
+ * Convenience method for setting the 'name' option of the point. Equivalent to:
+ *
+ * point.setOption("name", "Green Bears");
+ *
+ * The name of the point as shown in the legend, tooltip, dataLabel etc. Defaults to "".
+ *
+ * @param name The value to set as the point's name.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ */
+ public Point setName(String name) {
+ this.name = name;
+ return this.setOption("name", name);
+ }
+
+ /**
+ * Return the name property that was set on this point, or null if no name was set.
+ *
+ * @return The 'name' property that was set on this point (likely via {@link #setName(String)},
+ * or null if no name was set.
+ */
+ public String getName() {
+ if (this.nativePoint != null) {
+ return nativeGetString(this.nativePoint, "name");
+ } else {
+ return this.name;
+ }
+ }
+
+ private boolean selected = false;
+
+ /**
+ * Convenience method for setting the 'selected' option of the point. Equivalent to:
+ *
+ * point.setOption("selected", true);
+ *
+ * Whether the point is selected or not.
+ *
+ * @param selected Whether the point is selected or not.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ */
+ public Point setSelected(boolean selected) {
+ this.selected = selected;
+ return this.setOption("selected", selected);
+ }
+
+ private boolean sliced = false;
+
+ /**
+ * Convenience method for setting the 'sliced' option of the point. Equivalent to:
+ *
+ * point.setOption("sliced", false);
+ *
+ * Pie series only. Whether to display a slice offset from the center. Defaults to false.
+ *
+ * @param sliced The value to set as the point's 'sliced' option.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ */
+ public Point setSliced(boolean sliced) {
+ this.sliced = sliced;
+ return this.setOption("sliced", sliced);
+ }
+
+ /**
+ * Store some arbitrary data on the point. As the user interacts with the chart various events
+ * are fired (such as {@link org.moxieapps.gwt.highcharts.client.events.PointClickEvent}), which
+ * include a reference to the Point instance that the event was fired on. The Point instances
+ * that are returned from the live rendered chart are actually different instances then the versions
+ * that were originally added to the chart via one of the Series addPoint() or setPoints() methods,
+ * as Highcharts has its own internal representation of all of the point objects. Therefore,
+ * if you need to track some additional information with each point (beyond its axis values)
+ * that you can later access when an event on the point is fired, this method provides a convenient
+ * way for you to store some arbitrary data on the point which will then later be available
+ * via the {@link #getUserData()} method.
+ *
+ * @param userData Some arbitrary data that to store with the point that will be available
+ * later whenever the point instance is retrieved after the chart is rendered.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point setUserData(JSONObject userData) {
+ return this.setOption("userData", userData);
+ }
+
+ /**
+ * Retrieve any arbitrary data that was stored along with the point
+ * (via the {@link #setUserData(JSONObject)} method) when it was originally added to a series
+ *
+ * @return The arbitrary data that was stored with the point when it was first added to the series,
+ * or null if no such data was set.
+ * @since 1.1.0
+ */
+ public JSONObject getUserData() {
+ if(nativePoint != null) {
+ JavaScriptObject nativeUserData = nativeGetUserData(nativePoint);
+ return nativeUserData != null ? new JSONObject(nativeUserData) : null;
+ } else {
+ return this.getOptions() != null ? (JSONObject)this.getOptions().get("userData") : null;
+ }
+ }
+
+ /**
+ * Remove the point from the series, automatically redrawing the chart using the default
+ * animation options.
+ * Note that this method is only relevant on Point instance that are obtained from the chart
+ * after it has been rendered, such as via an event or dynamically retrieving the points of
+ * a series.
+ *
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point remove() {
+ return this.remove(true, true);
+ }
+
+ /**
+ * Remove the point from the series, explicitly controlling whether the chart is redrawn
+ * and/or animated or not.
+ * Note that this method is only relevant on Point instance that are obtained from the chart
+ * after it has been rendered, such as via an event or dynamically retrieving the points of
+ * a series.
+ *
+ * @param redraw Whether to redraw the chart after the point is removed. When removing more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the removing of points is finished.
+ * @param animation Defaults to true. When true, the graph will be animated with default animation options.
+ * Note, see the {@link #remove(boolean, Animation)} method
+ * for more control over how the animation will run.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point remove(boolean redraw, boolean animation) {
+ return this.remove(redraw, animation ? new Animation() : null);
+ }
+
+ /**
+ * Remove the point from the series, explicitly controlling whether the chart is redrawn
+ * and the details of the animation options.
+ * Note that this method is only relevant on Point instance that are obtained from the chart
+ * after it has been rendered, such as via an event or dynamically retrieving the points of
+ * a series.
+ *
+ * @param redraw Whether to redraw the chart after the point is removed. When removing more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the removing of points is finished.
+ * @param animation The custom animation to use when removing the point from the series.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point remove(boolean redraw, Animation animation) {
+ if (this.nativePoint != null) {
+ if (animation == null || animation.getOptions() == null) {
+ nativeRemove(this.nativePoint, redraw, animation != null);
+ } else {
+ nativeRemove(this.nativePoint, redraw, animation.getOptions().getJavaScriptObject());
+ }
+ }
+ // Nothing to do if this point isn't connected to a Highcharts JS point instance
+ return this;
+ }
+
+ /**
+ * Select or unselect the point. See the {@link #selectToggle(boolean)} method for other options.
+ *
+ * @param select When true, the point is selected. If you'd instead like to simply toggle the selection
+ * state see the {@link #selectToggle(boolean)} method instead.
+ * @param accumulate When true, the selection is added to other selected points. When false, other
+ * selected points are deselected. Internally in Highcharts, selected points
+ * are accumulated on Control, Shift or Cmd clicking the point.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point select(boolean select, boolean accumulate) {
+ if (this.nativePoint != null) {
+ nativeSelect(this.nativePoint, select, accumulate);
+ } else {
+ setSelected(select);
+ }
+ return this;
+ }
+
+ /**
+ * Toggle the selection state of the point. See the {@link #select(boolean, boolean)} method for other options.
+ *
+ * @param accumulate When true, the selection is added to other selected points. When false, other
+ * selected points are deselected. Internally in Highcharts, selected points
+ * are accumulated on Control, Shift or Cmd clicking the point.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point selectToggle(boolean accumulate) {
+ if (this.nativePoint != null) {
+ nativeSelectToggle(this.nativePoint, accumulate);
+ } else {
+ setSelected(!selected);
+ }
+ return this;
+ }
+
+ /**
+ * Slice out or set back in a pie chart slice, automatically redrawing the chart with the default
+ * animation options. This is the default way of Highcharts to visualize that a pie point is
+ * selected. See the {@link #sliceToggle()} method as well.
+ *
+ * @param sliced When true, the point is sliced out. When false, the point is set in.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point slice(boolean sliced) {
+ return this.slice(sliced, true, true);
+ }
+
+ /**
+ * Slice out or set back in a pie chart slice, controlling whether or not the chart will be
+ * automatically redraw or not. This is the default way of Highcharts to visualize that a pie point is
+ * selected. See the {@link #sliceToggle(boolean, boolean)} method as well.
+ *
+ * @param sliced When true, the point is sliced out. When false, the point is set in.
+ * @param redraw Whether to redraw the chart after the point is sliced. When slicing more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the slicing of points is finished.
+ * @param animation Defaults to true. When true, the graph will be animated with default animation options.
+ * Note, also see the {@link #slice(boolean, boolean, Animation)} method
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point slice(boolean sliced, boolean redraw, boolean animation) {
+ return this.slice(sliced, redraw, animation ? new Animation() : null);
+ }
+
+ /**
+ * Slice out or set back in a pie chart slice, controlling whether or not the chart will be
+ * automatically redraw or not. This is the default way of Highcharts to visualize that a pie point is
+ * selected. See the {@link #sliceToggle(boolean, Animation)} method as well.
+ *
+ * @param sliced When true, the point is sliced out. When false, the point is set in.
+ * @param redraw Whether to redraw the chart after the point is sliced. When slicing more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the slicing of points is finished.
+ * @param animation The custom animation to use when slicing the point ing the series.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point slice(boolean sliced, boolean redraw, Animation animation) {
+ if (this.nativePoint != null) {
+ if (animation == null || animation.getOptions() == null) {
+ nativeSlice(this.nativePoint, sliced, redraw, animation != null);
+ } else {
+ nativeSlice(this.nativePoint, sliced, redraw, animation.getOptions().getJavaScriptObject());
+ }
+ } else {
+ setSliced(sliced);
+ }
+ return this;
+ }
+
+ /**
+ * Toggle slicing out or set back in a pie chart slice, automatically redrawing the chart with the default
+ * animation options. This is the default way of Highcharts to visualize that a pie point is
+ * selected. See the {@link #slice(boolean)} method as well.
+ *
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point sliceToggle() {
+ return this.sliceToggle(true, true);
+ }
+
+ /**
+ * Toggle slicing out or set back in a pie chart slice, controlling whether or not the chart will be
+ * automatically redraw or not. This is the default way of Highcharts to visualize that a pie point is
+ * selected. See the {@link #slice(boolean, boolean, boolean)} method as well.
+ *
+ * @param redraw Whether to redraw the chart after the point is sliced. When slicing more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the slicing of points is finished.
+ * @param animation Defaults to true. When true, the graph will be animated with default animation options.
+ * Note, also see the {@link #slice(boolean, boolean, Animation)} method
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point sliceToggle(boolean redraw, boolean animation) {
+ return this.sliceToggle(redraw, animation ? new Animation() : null);
+ }
+
+ /**
+ * Toggle slicing out or set back in a pie chart slice, controlling whether or not the chart will be
+ * automatically redraw or not. This is the default way of Highcharts to visualize that a pie point is
+ * selected. See the {@link #slice(boolean, boolean, Animation)} method as well.
+ *
+ * @param redraw Whether to redraw the chart after the point is sliced. When slicing more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the slicing of points is finished.
+ * @param animation The custom animation to use when slicing the point ing the series.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point sliceToggle(boolean redraw, Animation animation) {
+ if (this.nativePoint != null) {
+ if (animation == null || animation.getOptions() == null) {
+ nativeSlice(this.nativePoint, redraw, animation != null);
+ } else {
+ nativeSlice(this.nativePoint, redraw, animation.getOptions().getJavaScriptObject());
+ }
+ } else {
+ setSliced(!sliced);
+ }
+ return this;
+ }
+
+ /**
+ * Update the point with the new values, automatically redrawing
+ * the chart with the default animation options.
+ *
+ * @param y The new y value for the point.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point update(Number y) {
+ return this.update(new Point(y));
+ }
+
+ /**
+ * Update the point with the new values, automatically redrawing
+ * the chart with the default animation options.
+ *
+ * @param x The new x value for the point.
+ * @param y The new value for the point.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point update(Number x, Number y) {
+ return this.update(new Point(x, y));
+ }
+
+ /**
+ * Update the point with the new values, specifying whether or not the chart should be automatically
+ * redrawn with the new values.
+ *
+ * @param y The new y value for the point.
+ * @param redraw Whether to redraw the chart after the point is updated. When updating more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the updating of points is finished.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point update(Number y, boolean redraw) {
+ return this.update(new Point(y), redraw, true);
+ }
+
+ /**
+ * Update the point with the new values, specifying whether or not the chart should be automatically
+ * redrawn with the new values.
+ *
+ * @param x The new x value for the point.
+ * @param y The new value for the point.
+ * @param redraw Whether to redraw the chart after the point is updated. When updating more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the updating of points is finished.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point update(Number x, Number y, boolean redraw) {
+ return this.update(new Point(x, y), redraw, true);
+ }
+
+ /**
+ * Update the point with the new values and options from the given point, automatically redrawing
+ * the chart with the default animation options.
+ *
+ * @param pointOptions The point instance from which the new values and options will be retrieved.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point update(Point pointOptions) {
+ return this.update(pointOptions, true, true);
+ }
+
+ /**
+ * Update the point with the new values and options from the given point, specifying if the chart
+ * should be automatically redrawn and animated or not.
+ *
+ * @param pointOptions The point instance from which the new values and options will be retrieved.
+ * @param redraw Whether to redraw the chart after the point is updated. When updating more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the updating of points is finished.
+ * @param animation Defaults to true. When true, the graph will be animated with default animation options.
+ * Note, see the {@link #update(Point, boolean, Animation)} method
+ * for more control over how the animation will run.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point update(Point pointOptions, boolean redraw, boolean animation) {
+ return this.update(pointOptions, redraw, animation ? new Animation() : null);
+ }
+
+ /**
+ * Update the point with the new values and options from the given point, specifying if the chart
+ * should be automatically redrawn and animated or not.
+ *
+ * @param pointOptions The point instance from which the new values and options will be retrieved.
+ * @param redraw Whether to redraw the chart after the point is updating. When updating more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called after the updating of points is finished.
+ * @param animation The custom animation to use when updating the point in the series.
+ * @return A reference to this {@link Point} instance for convenient method chaining.
+ * @since 1.1.0
+ */
+ public Point update(Point pointOptions, boolean redraw, Animation animation) {
+ if (this.nativePoint != null) {
+ if (animation == null || animation.getOptions() == null) {
+ if (pointOptions.isSingleValue()) {
+ if(pointOptions.getY() == null) {
+ nativeUpdateToNull(this.nativePoint, redraw, animation != null);
+ } else {
+ nativeUpdate(this.nativePoint, pointOptions.getY().doubleValue(), redraw, animation != null);
+ }
+ } else {
+ nativeUpdate(this.nativePoint, Series.convertPointToJavaScriptObject(pointOptions), redraw, animation != null);
+ }
+ } else {
+ if (pointOptions.isSingleValue()) {
+ if(pointOptions.getY() == null) {
+ nativeUpdateToNull(this.nativePoint, redraw, animation.getOptions().getJavaScriptObject());
+ } else {
+ nativeUpdate(this.nativePoint, pointOptions.getY().doubleValue(), redraw, animation.getOptions().getJavaScriptObject());
+ }
+ } else {
+ nativeUpdate(this.nativePoint, Series.convertPointToJavaScriptObject(pointOptions), redraw, animation.getOptions().getJavaScriptObject());
+ }
+ }
+ } else {
+ this.x = pointOptions.x;
+ this.y = pointOptions.y;
+ this.name = pointOptions.name;
+ this.selected = pointOptions.selected;
+ this.sliced = pointOptions.sliced;
+ for (String key : pointOptions.getOptions().keySet()) {
+ this.setOption(key, pointOptions.getOptions().get(key));
+ }
+ }
+ return this;
+ }
+
+ // Purposefully package scope
+ boolean isSingleValue() {
+ return this.getOptions() == null && this.getX() == null;
+ }
+
+ private static native double nativeGetNumber(JavaScriptObject point, String key) /*-{
+ return point[key];
+ }-*/;
+
+ private static native String nativeGetString(JavaScriptObject point, String key) /*-{
+ return point[key];
+ }-*/;
+
+ private static native void nativeRemove(JavaScriptObject point, boolean redraw, boolean animation) /*-{
+ point.remove(redraw, animation);
+ }-*/;
+
+ private static native void nativeRemove(JavaScriptObject point, boolean redraw, JavaScriptObject animation) /*-{
+ point.remove(redraw, animation);
+ }-*/;
+
+ private static native void nativeSelect(JavaScriptObject point, boolean select, boolean accumulate) /*-{
+ point.select(select, accumulate);
+ }-*/;
+
+ private static native void nativeSelectToggle(JavaScriptObject point, boolean accumulate) /*-{
+ point.select(null, accumulate);
+ }-*/;
+
+ private static native void nativeSlice(JavaScriptObject point, boolean sliced, boolean redraw, JavaScriptObject animation) /*-{
+ point.slice(sliced, redraw, animation);
+ }-*/;
+
+ private static native void nativeSlice(JavaScriptObject point, boolean sliced, boolean redraw, boolean animation) /*-{
+ point.slice(sliced, redraw, animation);
+ }-*/;
+
+ private static native void nativeSlice(JavaScriptObject point, boolean redraw, JavaScriptObject animation) /*-{
+ point.slice(null, redraw, animation);
+ }-*/;
+
+ private static native void nativeSlice(JavaScriptObject point, boolean redraw, boolean animation) /*-{
+ point.slice(null, redraw, animation);
+ }-*/;
+
+ private static native void nativeUpdate(JavaScriptObject point, JavaScriptObject options, boolean redraw, JavaScriptObject animation) /*-{
+ point.update(options, redraw, animation);
+ }-*/;
+
+ private static native void nativeUpdate(JavaScriptObject point, double y, boolean redraw, JavaScriptObject animation) /*-{
+ point.update(y, redraw, animation);
+ }-*/;
+
+ private static native void nativeUpdate(JavaScriptObject point, JavaScriptObject options, boolean redraw, boolean animation) /*-{
+ point.update(options, redraw, animation);
+ }-*/;
+
+ private static native void nativeUpdate(JavaScriptObject point, double y, boolean redraw, boolean animation) /*-{
+ point.update(y, redraw, animation);
+ }-*/;
+
+ private static native void nativeUpdateToNull(JavaScriptObject point, boolean redraw, JavaScriptObject animation) /*-{
+ point.update(null, redraw, animation);
+ }-*/;
+
+ private static native void nativeUpdateToNull(JavaScriptObject point, boolean redraw, boolean animation) /*-{
+ point.update(null, redraw, animation);
+ }-*/;
+
+ private static native JavaScriptObject nativeGetUserData(JavaScriptObject point) /*-{
+ return point.userData;
+ }-*/;
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/RangeSelector.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/RangeSelector.java
new file mode 100755
index 00000000000..9056e87e592
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/RangeSelector.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * TODO: This is a place holder class which will be formalized once the Highstock
+ * library is released.
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class RangeSelector extends Configurable
+ * Series series = chart.createSeries()
+ * .setName("Random Stuff")
+ * .addPoint(40)
+ * .addPoint(35)
+ * .addPoint(60);
+ * chart.addSeries(series);
+ *
+ * Example of updating all of the points in a series at once:
+ *
+ * chart.addSeries(chart.createSeries()
+ * .setName("Random Stuff")
+ * .setPoints(new Number[] { 40, 35, 60 })
+ * );
+ *
+ * Example of changing the options for one point in the series:
+ *
+ * chart.addSeries(chart.createSeries()
+ * .setName("Random Stuff")
+ * .addPoint(40)
+ * .addPoint(new Point(35).setColor("#BF0B23"))
+ * .addPoint(60)
+ * );
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Series extends Configurable
+ * series.setOption("name", "My Chart");
+ *
+ * The name of the series as shown in the legend, tooltip etc. Defaults to "".
+ *
+ * @param name The string to set as the series name.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setName(String name) {
+ return this.setOption("name", name);
+ }
+
+ /**
+ * Convenience method for setting the 'stack' option of the series to a string. Equivalent to:
+ *
+ * series.setOption("stack", "Stack 1");
+ *
+ * The 'stack' option allows grouping series in a stacked chart. Defaults to null. Note
+ * that you can also set this option to a number instead via the {@link #setStack(Number)} method.
+ *
+ * @param stack The string to set as the 'stack' option on the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setStack(String stack) {
+ return this.setOption("stack", stack);
+ }
+
+ /**
+ * Convenience method for setting the 'stack' option of the series to a number. Equivalent to:
+ *
+ * series.setOption("stack", 1);
+ *
+ * The 'stack' option allows grouping series in a stacked chart. Defaults to null. Note
+ * that you can also set this option to a string instead via the {@link #setStack(String)} method.
+ *
+ * @param stack The number to set as the 'stack' option on the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setStack(Number stack) {
+ return this.setOption("stack", stack);
+ }
+
+ /**
+ * Sets the type of this series (which controls the way the series will be rendered), using
+ * an enumeration type in order to ensure a correct value is passed. This is equivalent to
+ * setting the option manually with code like:
+ *
+ * series.setOption("type", "line");
+ *
+ * Note that if you don't set this explicitly the default series type is {@link Series.Type#LINE}.
+ *
+ * @param type One of the supported series types.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setType(Type type) {
+ return this.setOption("type", type.toString());
+ }
+
+ /**
+ * Convenience method for setting the 'xAxis' property of the series to a number. Equivalent to:
+ *
+ * series.setOption("xAxis", 1);
+ *
+ * When using dual or multiple x axes, this number defines which xAxis the particular series is
+ * connected to. It refers to the index of the axis in the xAxis array, with 0 being the first.
+ * Defaults to 0.
+ *
+ * @param xAxis The number to set as the 'xAxis' option on the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setXAxis(Number xAxis) {
+ return this.setOption("xAxis", xAxis);
+ }
+
+ /**
+ * Convenience method for setting the 'yAxis' property of the series to a number. Equivalent to:
+ *
+ * series.setOption("yAxis", 1);
+ *
+ * When using dual or multiple y axes, this number defines which yAxis the particular series is
+ * connected to. It refers to the index of the axis in the yAxis array, with 0 being the first.
+ * Defaults to 0.
+ *
+ * @param yAxis The number to set as the 'yAxis' option on the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setYAxis(Number yAxis) {
+ return this.setOption("yAxis", yAxis);
+ }
+
+ // Need to maintain a refernce to the plot options set on us in order to deal with potential custom data label formatters
+ private PlotOptions plotOptions;
+
+ /**
+ * Updates the plot options for this series to reflect the given options. The default
+ * options for all series in the chart (of each type) can be set on the {@link Chart} instance,
+ * and therefore you only need to use this method if you want to override the plot options for
+ * this series only.
+ *
+ * Note that the general {@link PlotOptions} type only represents the abstract base class of all the
+ * different series types. To call this method you need to instantiate one of the concrete
+ * sub-classes instead (e.g. {@link org.moxieapps.gwt.highcharts.client.plotOptions.AreaPlotOptions},
+ * {@link org.moxieapps.gwt.highcharts.client.plotOptions.BarPlotOptions}, etc.).
+ *
+ * Also note that changing the plot options for a series after it has been rendered to the screen
+ * does not change the way the live series will appear. If you need to change the plot options
+ * after the series is rendered, you'd instead need to first {@link #remove()} the series from
+ * the chart and then re-add it to the chart via the {@link Chart#addSeries(Series)} method.
+ *
+ * @param plotOptions The plot options to use for this series (or one of its sub-types)
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setPlotOptions(PlotOptions plotOptions) {
+
+ this.plotOptions = plotOptions;
+
+ if (plotOptions == null) {
+ return this;
+ }
+
+ // Applying plot options directly to a series is a little different as the optoins
+ // get applied directly to the root configuration object, instead of off within their
+ // own sub object like almost everything else works. So, we need to merge the given
+ // options with our root options
+ JSONObject plotOptionsJSON = plotOptions.getOptions();
+
+ if (plotOptionsJSON != null) {
+ for (String key : plotOptionsJSON.keySet()) {
+ this.setOption(key, plotOptionsJSON.get(key));
+ }
+ }
+
+ return this;
+ }
+
+ // Purposefully package scope
+ PlotOptions getPlotOptions() {
+ return this.plotOptions;
+ }
+
+ /**
+ * Simplest way to add a point using the default options, and setting only the Y value
+ * that the point should be rendered at within the series. See the various overloaded
+ * versions of the addPoint() method for more control over the way the
+ * point is rendered.
+ *
+ * @param y The value on the Y axis that the point should be drawn at within the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Number y) {
+ return this.addPoint(new Point(y));
+ }
+
+ /**
+ * Add a point to the series with a specific value on the Y axis, controlling the
+ * options on how the change will be drawn to the series.
+ *
+ * @param y The value on the Y axis that the point should be drawn at within the series.
+ * @param redraw Whether to redraw the chart after the point is added. When adding more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called
+ * after the adding of points is finished.
+ * @param shift Defaults to false. When shift is true, one point is shifted off the start of the
+ * series as one is appended to the end. Use this option for live charts monitoring
+ * a value over time.
+ * @param animation Defaults to true. When true, the graph will be animated with default animation options.
+ * Note, see the {@link #addPoint(Number, boolean, boolean, Animation)} method
+ * for more control over how the animation will run.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Number y, boolean redraw, boolean shift, boolean animation) {
+ return this.addPoint(new Point(y), redraw, shift, animation);
+ }
+
+ /**
+ * Add a point to the series with a specific value on the Y axis, controlling the
+ * options on how the change will be drawn to the series.
+ *
+ * @param y The value on the Y axis that the point should be drawn at within the series.
+ * @param redraw Whether to redraw the chart after the point is added. When adding more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called
+ * after the adding of points is finished.
+ * @param shift Defaults to false. When shift is true, one point is shifted off the start of the
+ * series as one is appended to the end. Use this option for live charts monitoring
+ * a value over time.
+ * @param animation The custom animation to use when adding the point to the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Number y, boolean redraw, boolean shift, Animation animation) {
+ return this.addPoint(new Point(y), redraw, shift, animation);
+ }
+
+ /**
+ * Simple way to add a point using the default options, and setting only the X and Y value
+ * that the point should be rendered at within the series. See the various overloaded
+ * versions of the addPoint() method for more control over the way the
+ * point is rendered.
+ *
+ * @param x The value on the X axis that the point should be drawn at within the series.
+ * @param y The value on the Y axis that the point should be drawn at within the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Number x, Number y) {
+ return this.addPoint(new Point(x, y));
+ }
+
+ /**
+ * Add a point to the series with a specific value on the X and Y axis, controlling the
+ * options on how the change will be drawn to the series.
+ *
+ * @param x The value on the X axis that the point should be drawn at within the series.
+ * @param y The value on the Y axis that the point should be drawn at within the series.
+ * @param redraw Whether to redraw the chart after the point is added. When adding more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called
+ * after the adding of points is finished.
+ * @param shift Defaults to false. When shift is true, one point is shifted off the start of the
+ * series as one is appended to the end. Use this option for live charts monitoring
+ * a value over time.
+ * @param animation Defaults to true. When true, the graph will be animated with default animation options.
+ * Note, see the {@link #addPoint(Number, Number, boolean, boolean, Animation)} method
+ * for more control over how the animation will run.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Number x, Number y, boolean redraw, boolean shift, boolean animation) {
+ return this.addPoint(new Point(x, y), redraw, shift, animation);
+ }
+
+ /**
+ * Add a point to the series with a specific value on the X and Y axis, controlling the
+ * options on how the change will be drawn to the series.
+ *
+ * @param x The value on the X axis that the point should be drawn at within the series.
+ * @param y The value on the Y axis that the point should be drawn at within the series.
+ * @param redraw Whether to redraw the chart after the point is added. When adding more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called
+ * after the adding of points is finished.
+ * @param shift Defaults to false. When shift is true, one point is shifted off the start of the
+ * series as one is appended to the end. Use this option for live charts monitoring
+ * a value over time.
+ * @param animation The custom animation to use when adding the point to the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Number x, Number y, boolean redraw, boolean shift, Animation animation) {
+ return this.addPoint(new Point(x, y), redraw, shift, animation);
+ }
+
+ /**
+ * Add a point to the series accepting the default options on how the point will be drawn.
+ *
+ * @param point The point to add to the series (which, in turn, can have its own configuration options).
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Point point) {
+ return this.addPoint(point, true, false, true);
+ }
+
+ /**
+ * Add a point to the series with a specific value on the X and Y axis, controlling the
+ * options on how the change will be drawn to the series.
+ *
+ * @param point The point to add to the series (which, in turn, can have its own configuration options).
+ * @param redraw Whether to redraw the chart after the point is added. When adding more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called
+ * after the adding of points is finished.
+ * @param shift Defaults to false. When shift is true, one point is shifted off the start of the
+ * series as one is appended to the end. Use this option for live charts monitoring
+ * a value over time.
+ * @param animation Defaults to true. When true, the graph will be animated with default animation options.
+ * Note, see the {@link #addPoint(Point, boolean, boolean, Animation)} method
+ * for more control over how the animation will run.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Point point, boolean redraw, boolean shift, boolean animation) {
+ return this.addPoint(point, redraw, shift, animation ? new Animation() : null);
+ }
+
+ /**
+ * Add a point to the series with a specific value on the X and Y axis, controlling the
+ * options on how the change will be drawn to the series.
+ *
+ * @param point The point to add to the series (which, in turn, can have its own configuration options).
+ * @param redraw Whether to redraw the chart after the point is added. When adding more than one
+ * point, it is highly recommended that the redraw option be set to false, and instead
+ * {@link Chart#redraw()} is explicitly called
+ * after the adding of points is finished.
+ * @param shift Defaults to false. When shift is true, one point is shifted off the start of the
+ * series as one is appended to the end. Use this option for live charts monitoring
+ * a value over time.
+ * @param animation The custom animation to use when adding the point to the series.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series addPoint(Point point, boolean redraw, boolean shift, Animation animation) {
+ if (isRendered()) {
+ // We'll store the point directly in the DOM if we've already been rendered
+ final JavaScriptObject nativeSeries = chart.get(this.id);
+ if (nativeSeries != null) {
+ if (animation == null || animation.getOptions() == null) {
+ final boolean animationFlag = animation != null;
+ if (point.isSingleValue()) {
+ nativeAddPoint(nativeSeries, point.getY(), redraw, shift, animationFlag);
+ } else {
+ nativeAddPoint(nativeSeries, convertPointToJavaScriptObject(point), redraw, shift, animationFlag);
+ }
+ } else {
+ final JavaScriptObject animationOptions = animation.getOptions().getJavaScriptObject();
+ if (point.isSingleValue()) {
+ nativeAddPoint(nativeSeries, point.getY(), redraw, shift, animationOptions);
+ } else {
+ nativeAddPoint(nativeSeries, convertPointToJavaScriptObject(point), redraw, shift, animationOptions);
+ }
+ }
+
+ }
+ } else {
+ // If we haven't been rendered, then store the point in ourselves for now
+ points.add(point);
+ }
+ return this;
+ }
+
+ // Purposefully friendly scope so that we can get to this method from the Point class as well
+ static JavaScriptObject convertPointToJavaScriptObject(Point point) {
+ final JSONObject options = point.getOptions() != null ? point.getOptions() : new JSONObject();
+ Chart.addPointScalarValues(point, options);
+ return options.getJavaScriptObject();
+ }
+
+ /**
+ * Apply a new set of data (Y values only) to the series and automatically redraw it. If you need
+ * more control than just simply setting the y values of each data point, then use the
+ * {@link #setPoints(Point[])} method instead.
+ *
+ * @param yValues The array of Y values to set on the data series (replacing any data already in place)
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setPoints(Number[] yValues) {
+ return this.setPoints(yValues, true);
+ }
+
+ /**
+ * Apply a new set of data (Y values only) to the series and optionally redraw it. If you need
+ * more control than just simply setting the y values of each data point, then use the
+ * {@link #setPoints(Point[], boolean)} method instead.
+ *
+ * @param yValues The array of Y values to set on the data series (replacing any data already in place)
+ * @param redraw Whether to redraw the chart after the series is altered. If doing more operations
+ * on the chart, it is a good idea to set redraw to false and then call
+ * {@link Chart#redraw()} after.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setPoints(Number[] yValues, boolean redraw) {
+ this.points.clear();
+ if (isRendered()) {
+ final JavaScriptObject nativeSeries = chart.get(this.id);
+ if (nativeSeries != null) {
+ JSONArray jsonArray = new JSONArray();
+ for (int i = 0, pointsLength = yValues.length; i < pointsLength; i++) {
+ jsonArray.set(i, new JSONNumber(yValues[i].doubleValue()));
+ }
+ nativeSetData(nativeSeries, jsonArray.getJavaScriptObject(), redraw);
+ }
+ } else {
+ for (Number yValue : yValues) {
+ this.addPoint(yValue);
+ }
+ }
+ return this;
+ }
+
+ /**
+ * Apply a new set of data (X and Y values) to the series and automatically redraw it. If you need
+ * more control than just simply setting the x and y values of each data point, then use the
+ * {@link #setPoints(Point[])} method instead.
+ *
+ * @param values A two dimensional array of values, where the main array is the list of points and
+ * each inner array contains two values representing the X and Y values respectively.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setPoints(Number[][] values) {
+ return this.setPoints(values, true);
+ }
+
+ /**
+ * Apply a new set of data (X and Y values) to the series and optionally redraw it. If you need
+ * more control than just simply setting the x and y values of each data point, then use the
+ * {@link #setPoints(Point[])} method instead.
+ *
+ * @param values A two dimensional array of values, where the main array is the list of points and
+ * each inner array contains two values representing the X and Y values respectively.
+ * @param redraw Whether to redraw the chart after the series is altered. If doing more operations
+ * on the chart, it is a good idea to set redraw to false and then call
+ * {@link Chart#redraw()} after.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setPoints(Number[][] values, boolean redraw) {
+ this.points.clear();
+ if (isRendered()) {
+ final JavaScriptObject nativeSeries = chart.get(this.id);
+ if (nativeSeries != null) {
+ JSONArray jsonArray = new JSONArray();
+ for (int i = 0, pointsLength = values.length; i < pointsLength; i++) {
+ Number[] point = values[i];
+ JSONValue jsonValue;
+ if (point.length > 1) {
+ JSONArray pointArray = new JSONArray();
+ pointArray.set(0, new JSONNumber(point[0].doubleValue()));
+ pointArray.set(1, new JSONNumber(point[1].doubleValue()));
+ jsonValue = pointArray;
+ } else {
+ jsonValue = new JSONNumber(point[0].doubleValue());
+ }
+ jsonArray.set(i, jsonValue);
+ }
+ nativeSetData(nativeSeries, jsonArray.getJavaScriptObject(), redraw);
+ }
+ } else {
+ for (Number[] xyValue : values) {
+ this.addPoint(xyValue[0], xyValue[1]);
+ }
+ }
+ return this;
+ }
+
+ /**
+ * Apply a new set of data to the series and automatically redraw it.
+ *
+ * @param points The array of points to set on the data series (replacing any data already in place)
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setPoints(Point[] points) {
+ return this.setPoints(points, true);
+ }
+
+ /**
+ * Apply a new set of data to the series and optionally redraw it.
+ *
+ * @param points The array of points to set on the data series (replacing any data already in place)
+ * @param redraw Whether to redraw the chart after the series is altered. If doing more operations
+ * on the chart, it is a good idea to set redraw to false and then call
+ * {@link Chart#redraw()} after.
+ * @return A reference to this {@link Series} instance for convenient method chaining.
+ */
+ public Series setPoints(Point[] points, boolean redraw) {
+ this.points.clear();
+ if (isRendered()) {
+ final JavaScriptObject nativeSeries = chart.get(this.id);
+ if (nativeSeries != null) {
+ JSONArray jsonArray = new JSONArray();
+ for (int i = 0, pointsLength = points.length; i < pointsLength; i++) {
+ jsonArray.set(i, Chart.convertPointToJSON(points[i]));
+ }
+ nativeSetData(nativeSeries, jsonArray.getJavaScriptObject(), redraw);
+ }
+ } else {
+ Collections.addAll(this.points, points);
+ }
+ return this;
+ }
+
+ /**
+ * Retrieve the array of points that have been added to this series. If this method is invoked
+ * before the series is rendered to a chart, then it will simply return the points that have been
+ * added so far. If it is invoked after the series has been rendered, then it will retrieve
+ * the JS point instances from the live Highcharts element and convert them to GWT points.
+ *
+ * @return The array of points, or an empty array (non null) if no points have been added to the series yet.
+ */
+ public Point[] getPoints() {
+ ArrayList
+ * StockChart stockChart = new StockChart()
+ * .setChartTitleText("NYSE")
+ * .setMarginRight(10);
+ * Series series = stockChart.createSeries()
+ * .addPoint(40)
+ * .addPoint(35)
+ * .addPoint(60);
+ * stockChart.addSeries(series);
+ * RootPanel.get().add(stockChart);
+ *
+ * For details on available options see the Highcharts reference.
+ *
+ * Note that in order for this widget to function you must have included the Highstock javascript
+ * library and any of its dependencies in the page that the widget will run inside of. E.g.:
+ *
+ * <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ * <script type="text/javascript" src="js/highstock.js"></script>
+ *
+ * <!-- Optionally, add a highcharts theme file -->
+ * <script type="text/javascript" src="js/themes/gray.js"></script>
+ *
+ * <!-- Optionally, include the highcharts exporting module -->
+ * <script type="text/javascript" src="js/modules/exporting.js"></script>
+ *
+ * Note that the "highstock.js" file includes all of the capabilities of the "highcharts.js" file.
+ * So if you plan on using both {@link StockChart}'s and regular {@link Chart}'s simultaneously, then
+ * you only need to include the "highstock.js" file in your page.
+ *
+ * Also note that Highcharts supports other JS frameworks besides jQuery for its internal DOM manipulation
+ * functionality. So, if jQuery isn't your cup of tea check the
+ * installation docs
+ * on the Highcharts site for more details.
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class StockChart extends BaseChart
+ * StockChart chart = new StockChart()
+ * .setChartTitleText("Nice Chart")
+ * .setMarginRight(10);
+ * RootPanel.get().add(chart);
+ *
+ */
+ public StockChart() {
+ super();
+ }
+
+ @Override
+ protected String getChartTypeName() {
+ return "StockChart";
+ }
+
+ /**
+ * Convenience method for setting the 'rangeSelector' chart options. Equivalent to:
+ *
+ * stockChart.setOption("/rangeSelector/selected", 1);
+ * stockChart.setOption("/rangeSelector/inputEnabled", false);
+ * etc...
+ *
+ *
+ * @param rangeSelector Sets the chart range selector options.
+ * @return A reference to this {@link StockChart} instance for convenient method chaining.
+ */
+ public StockChart setRangeSelector(RangeSelector rangeSelector) {
+ return this.setOption("/rangeSelector", rangeSelector != null ? rangeSelector.getOptions() : null);
+ }
+
+
+}
diff --git a/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Style.java b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Style.java
new file mode 100755
index 00000000000..cb9145eb616
--- /dev/null
+++ b/java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/Style.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2011 Moxie Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.moxieapps.gwt.highcharts.client;
+
+/**
+ * A configurable class that can be used to represent custom CSS style options for the
+ * chart, which can then be set on various other configuration objects (e.g.
+ * {@link Chart#setStyle(Style)}, {@link ChartTitle#setStyle(Style)}, etc.).
+ * Example usage:
+ *
+ * chart.setStyle(
+ * new Style()
+ * .setOption("fontFamily", "serif")
+ * );
+ *
+ * Note that some convenience methods are provided on this class for setting commonly used
+ * CSS options (such as {@link #setColor(String)}, {@link #setFontFamily(String)},
+ * {@link #setFontSize(String)}, etc). But, any arbitrary CSS option can be set by
+ * simply using the {@link #setOption(String, Object)} method. E.g., the following two
+ * lines are equivalent:
+ *
+ * style.setFontFamily("serif");
+ * style.setOption("fontFamily", "serif");
+ *
+ *
+ * @author squinn@moxiegroup.com (Shawn Quinn)
+ * @since 1.0.0
+ */
+public class Style extends Configurable