From 8142ad77043582e5fb522a3e8932efe0640e0ffe Mon Sep 17 00:00:00 2001 From: Uemit Seren Date: Tue, 8 Mar 2016 16:32:21 +0100 Subject: [PATCH] Added support for MotionChart Add MotionChart and a corresponding MotionChartOptions class and "motionchart" enum to the ChartPackage class. Unlike the other charts MotionChart is not responsive. In order to keep the same behavior as the other chart types, the MotionChart will determine if width or height are specified. If not it will assume to resize if the available space. For this to work, the access level of the Options variable inside of the ChartWidget had to be changed from private to protected. This fixes #53 --- gwt-charts/pom.xml | 512 +++++++++--------- .../gwt/charts/client/ChartPackage.java | 208 +++---- .../gwt/charts/client/ChartWidget.java | 378 ++++++------- .../client/motionchart/MotionChart.java | 96 ++++ .../motionchart/MotionChartOptions.java | 127 +++++ 5 files changed, 776 insertions(+), 545 deletions(-) create mode 100644 gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChart.java create mode 100644 gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChartOptions.java diff --git a/gwt-charts/pom.xml b/gwt-charts/pom.xml index dd720df..74f40a9 100644 --- a/gwt-charts/pom.xml +++ b/gwt-charts/pom.xml @@ -1,255 +1,259 @@ - - 4.0.0 - com.googlecode.gwt-charts - gwt-charts - 0.9.11-SNAPSHOT - jar - - GWT Charts - Unofficial Google Chart Tools API for Google Web Toolkit - http://code.google.com/p/gwt-charts - 2012 - - - org.sonatype.oss - oss-parent - 9 - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - http://gwt-charts.googlecode.com/svn/trunk/gwt-charts - scm:svn:http://gwt-charts.googlecode.com/svn/trunk/gwt-charts - scm:svn:https://gwt-charts.googlecode.com/svn/trunk/gwt-charts - - - - - Rui Afonso - - - - - - com.google.gwt - gwt-user - 2.6.0 - provided - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.7 - 1.7 - - - - org.codehaus.mojo - gwt-maven-plugin - 2.6.0 - - - - resources - compile - - - - - - org.apache.maven.plugins - maven-war-plugin - 2.3 - - src/main/webapp - src/main/webapp/WEB-INF/web.xml - - - - org.apache.maven.plugins - maven-site-plugin - 3.2 - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - verify - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - attach-sources - verify - - jar - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.codehaus.mojo - - - gwt-maven-plugin - - - [2.4.0,) - - - resources - - - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - [1.0.0,) - - enforce - - - - - - - - - - - - - - - - http://code.google.com/p/gwt-charts/issues - Google Code - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8.1 - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.9 - false - - - - checkstyle - - - - - .settings/gwt-checkstyle.xml - - - - org.apache.maven.plugins - maven-pmd-plugin - 2.6 - - true - 1.5 - - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.3 - - true - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.11 - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.4 - - - org.codehaus.mojo - taglist-maven-plugin - 2.4 - - - TODO - FIXME - - - - - target/site - - - - UTF-8 - + + 4.0.0 + com.googlecode.gwt-charts + gwt-charts + 0.9.11-SNAPSHOT + jar + + GWT Charts + Unofficial Google Chart Tools API for Google Web Toolkit + http://code.google.com/p/gwt-charts + 2012 + + + org.sonatype.oss + oss-parent + 9 + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + http://gwt-charts.googlecode.com/svn/trunk/gwt-charts + scm:svn:http://gwt-charts.googlecode.com/svn/trunk/gwt-charts + scm:svn:https://gwt-charts.googlecode.com/svn/trunk/gwt-charts + + + + + Rui Afonso + + + + + + com.google.gwt + gwt-user + 2.6.0 + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + + + + org.codehaus.mojo + gwt-maven-plugin + 2.6.0 + + + + resources + compile + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.3 + + src/main/webapp + src/main/webapp/WEB-INF/web.xml + + + + org.apache.maven.plugins + maven-site-plugin + 3.2 + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + verify + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + attach-sources + verify + + jar + + + + -Xdoclint:none + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.codehaus.mojo + + + gwt-maven-plugin + + + [2.4.0,) + + + resources + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + [1.0.0,) + + enforce + + + + + + + + + + + + + + + + http://code.google.com/p/gwt-charts/issues + Google Code + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8.1 + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.9 + false + + + + checkstyle + + + + + .settings/gwt-checkstyle.xml + + + + org.apache.maven.plugins + maven-pmd-plugin + 2.6 + + true + 1.5 + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + true + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.11 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.4 + + + org.codehaus.mojo + taglist-maven-plugin + 2.4 + + + TODO + FIXME + + + + + target/site + + + + UTF-8 + \ No newline at end of file diff --git a/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartPackage.java b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartPackage.java index de91b8b..a9e0ce5 100644 --- a/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartPackage.java +++ b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartPackage.java @@ -1,102 +1,106 @@ -/* - * Copyright 2012 Rui Afonso - * - * 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 com.googlecode.gwt.charts.client; - -/** - * A definition of available packages. - */ -public enum ChartPackage { - /** - * Exclusive use for annotation charts. - */ - ANNOTATIONCHART("annotationchart"), - /** - * Exclusive use for calendar charts. - */ - CALENDAR("calendar"), - /** - * Used for chart editor. No need to load the packages for the chart type that you render in the editor; the - * chart editor will load that package for you. - */ - CHARTEDITOR("charteditor"), - /** - * Used for controls and dashboards. - */ - CONTROLS("controls"), - /** - * Use for area, bar, bubble, candlestick, column, combo, line, pie, scatter and stepped area charts. - */ - CORECHART("corechart"), - /** - * Exclusive use for gauge charts. - */ - GAUGE("gauge"), - /** - * Exclusive use for geochart charts. - */ - GEOCHART("geochart"), - /** - * Exclusive use for map charts. - */ - MAP("map"), - /** - * Exclusive use for orgchart charts. - */ - ORGCHART("orgchart"), - /** - * Exclusive use for sankey diagrams. - */ - SANKEY("sankey"), - /** - * Exclusive use for tables. - */ - TABLE("table"), - /** - * Exclusive use for timelines. - */ - TIMELINE("timeline"), - /** - * Exclusive use for treemap charts. - */ - TREEMAP("treemap"); - - /** - * Get a ChartPackage by providing its name. - * - * @param name the ChartPackage name. - * @return a ChartPackage corresponding to the provided name. - */ - public static ChartPackage findByName(String name) { - for (ChartPackage chartPackage : ChartPackage.values()) { - if (chartPackage.getName().equals(name)) { - return chartPackage; - } - } - return null; - } - - private final String name; - - private ChartPackage(String name) { - this.name = name; - } - - /** - * Get the name of the ChartPackage. - * - * @return the name - */ - public String getName() { - return name; - } -} +/* + * Copyright 2012 Rui Afonso + * + * 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 com.googlecode.gwt.charts.client; + +/** + * A definition of available packages. + */ +public enum ChartPackage { + /** + * Exclusive use for annotation charts. + */ + ANNOTATIONCHART("annotationchart"), + /** + * Exclusive use for calendar charts. + */ + CALENDAR("calendar"), + /** + * Used for chart editor. No need to load the packages for the chart type that you render in the editor; the + * chart editor will load that package for you. + */ + CHARTEDITOR("charteditor"), + /** + * Used for controls and dashboards. + */ + CONTROLS("controls"), + /** + * Use for area, bar, bubble, candlestick, column, combo, line, pie, scatter and stepped area charts. + */ + CORECHART("corechart"), + /** + * Exclusive use for gauge charts. + */ + GAUGE("gauge"), + /** + * Exclusive use for geochart charts. + */ + GEOCHART("geochart"), + /** + * Exclusive use for map charts. + */ + MAP("map"), + /** + * Exclusive use for orgchart charts. + */ + ORGCHART("orgchart"), + /** + * Exclusive use for sankey diagrams. + */ + SANKEY("sankey"), + /** + * Exclusive use for tables. + */ + TABLE("table"), + /** + * Exclusive use for timelines. + */ + TIMELINE("timeline"), + /** + * Exclusive use for treemap charts. + */ + TREEMAP("treemap"), + /** + * Exclusive use for motioncharts charts. + */ + MOTIONCHART("motionchart"); + + /** + * Get a ChartPackage by providing its name. + * + * @param name the ChartPackage name. + * @return a ChartPackage corresponding to the provided name. + */ + public static ChartPackage findByName(String name) { + for (ChartPackage chartPackage : ChartPackage.values()) { + if (chartPackage.getName().equals(name)) { + return chartPackage; + } + } + return null; + } + + private final String name; + + private ChartPackage(String name) { + this.name = name; + } + + /** + * Get the name of the ChartPackage. + * + * @return the name + */ + public String getName() { + return name; + } +} diff --git a/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartWidget.java b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartWidget.java index 99ce7a1..f3f96b9 100644 --- a/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartWidget.java +++ b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/ChartWidget.java @@ -1,189 +1,189 @@ -/* - * Copyright 2012 Rui Afonso - * - * 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 com.googlecode.gwt.charts.client; - -import com.google.gwt.core.client.Scheduler; -import com.google.gwt.dom.client.Element; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.ui.RequiresResize; -import com.google.gwt.user.client.ui.Widget; - -import com.googlecode.gwt.charts.client.event.Event; -import com.googlecode.gwt.charts.client.event.EventHandler; -import com.googlecode.gwt.charts.client.event.HandlerRef; -import com.googlecode.gwt.charts.client.options.Options; - -import java.util.HashMap; - -/** - * This class is used as a widget wrapper for all chart types. - * Supports automatically resizing via {@link RequiresResize}, which means that all parents - * must implement {@link com.google.gwt.user.client.ui.ProvidesResize} for this to work. - * It also supports attach/detach funcionality. - * - * @param the chart options type - */ -public abstract class ChartWidget extends Widget implements RequiresResize { - protected ChartObject chartObject; - private DataSource data; - private Options options; - private HashMap eventMap; - private boolean unloaded; - private boolean pending; - - /** - * Creates a new ChartWidget. - */ - public ChartWidget() { - super(); - Element chartDiv = DOM.createDiv(); - chartObject = createChartObject(chartDiv); - setElement(chartDiv); - eventMap = new HashMap(); - } - - /** - * Clears the chart, and releases all of its allocated resources. - */ - public void clearChart() { - chartObject.clearChart(); - } - - /** - * Draws the visualization on the page. Behind the scenes this can be fetching a graphic from a server or creating - * the graphic on the page using the linked visualization code. You should call this method every time the data or - * options change. - * - * @param data a {@link DataTable} or {@link DataView} holding the data to use to draw the chart. - * @see draw API reference - */ - public void draw(DataSource data) { - draw(data, null); - } - - /** - * Draws the visualization on the page. Behind the scenes this can be fetching a graphic from a server or creating - * the graphic on the page using the linked visualization code. You should call this method every time the data or - * options change. - * - * @param data a {@link DataTable} or {@link DataView} holding the data to use to draw the chart. - * @param options A map of name/value pairs of custom options. - * @see draw API reference - */ - public void draw(DataSource data, T options) { - this.data = data; - this.options = options; - redraw(); - } - - /** - * Fires an event to all listeners. - * - * @param event the event object to fire - */ - public void fireEvent(Event event) { - chartObject.trigger(event.getEventName(), event.getProperties()); - } - - @Override - public void onResize() { - redraw(); - } - - /** - * Redraws the chart with last used data and options. - */ - public void redraw() { - if (pending) { - return; - } - pending = true; - // Double deferred command because of layout issues - Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { - - @Override - public void execute() { - Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { - - @Override - public void execute() { - redrawNow(); - } - }); - } - }); - } - - /** - * Removes all existing handlers from this chart. - */ - public void removeAllHandlers() { - eventMap.clear(); - chartObject.removeAllListeners(); - } - - /** - * Removes a single handler matching the given handler reference. - * - * @param handlerRef an handler reference - */ - public void removeHandler(HandlerRef handlerRef) { - eventMap.remove(handlerRef); - chartObject.removeListener(handlerRef); - } - - /** - * Call this method to register to receive events fired by a visualization hosted on your page. Note that this will - * not work for visualizations embedded in a gadget. - * - * @param - * @param handler the function to call when the event is fired - * @return the new handler reference. Can be used for removing by calling {@link #removeHandler(HandlerRef)}. - */ - protected final HandlerRef addHandler(H handler) { - HandlerRef handlerRef = chartObject.addListener(handler.getEventName(), handler); - eventMap.put(handlerRef, handler); - return handlerRef; - } - - protected abstract ChartObject createChartObject(Element parent); - - @Override - protected void onLoad() { - if (!unloaded) { - return; - } - unloaded = false; - recreate(); - redraw(); - } - - @Override - protected void onUnload() { - this.unloaded = true; - } - - protected void recreate() { - chartObject = createChartObject(getElement()); - for (EventHandler eventHandler : eventMap.values()) { - chartObject.addListener(eventHandler.getEventName(), eventHandler); - } - } - - protected void redrawNow() { - if (data != null) { - chartObject.draw(data, options); - } - pending = false; - } -} +/* + * Copyright 2012 Rui Afonso + * + * 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 com.googlecode.gwt.charts.client; + +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.dom.client.Element; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.RequiresResize; +import com.google.gwt.user.client.ui.Widget; + +import com.googlecode.gwt.charts.client.event.Event; +import com.googlecode.gwt.charts.client.event.EventHandler; +import com.googlecode.gwt.charts.client.event.HandlerRef; +import com.googlecode.gwt.charts.client.options.Options; + +import java.util.HashMap; + +/** + * This class is used as a widget wrapper for all chart types. + * Supports automatically resizing via {@link RequiresResize}, which means that all parents + * must implement {@link com.google.gwt.user.client.ui.ProvidesResize} for this to work. + * It also supports attach/detach funcionality. + * + * @param the chart options type + */ +public abstract class ChartWidget extends Widget implements RequiresResize { + protected ChartObject chartObject; + private DataSource data; + protected T options; + private HashMap eventMap; + private boolean unloaded; + private boolean pending; + + /** + * Creates a new ChartWidget. + */ + public ChartWidget() { + super(); + Element chartDiv = DOM.createDiv(); + chartObject = createChartObject(chartDiv); + setElement(chartDiv); + eventMap = new HashMap(); + } + + /** + * Clears the chart, and releases all of its allocated resources. + */ + public void clearChart() { + chartObject.clearChart(); + } + + /** + * Draws the visualization on the page. Behind the scenes this can be fetching a graphic from a server or creating + * the graphic on the page using the linked visualization code. You should call this method every time the data or + * options change. + * + * @param data a {@link DataTable} or {@link DataView} holding the data to use to draw the chart. + * @see draw API reference + */ + public void draw(DataSource data) { + draw(data, null); + } + + /** + * Draws the visualization on the page. Behind the scenes this can be fetching a graphic from a server or creating + * the graphic on the page using the linked visualization code. You should call this method every time the data or + * options change. + * + * @param data a {@link DataTable} or {@link DataView} holding the data to use to draw the chart. + * @param options A map of name/value pairs of custom options. + * @see draw API reference + */ + public void draw(DataSource data, T options) { + this.data = data; + this.options = options; + redraw(); + } + + /** + * Fires an event to all listeners. + * + * @param event the event object to fire + */ + public void fireEvent(Event event) { + chartObject.trigger(event.getEventName(), event.getProperties()); + } + + @Override + public void onResize() { + redraw(); + } + + /** + * Redraws the chart with last used data and options. + */ + public void redraw() { + if (pending) { + return; + } + pending = true; + // Double deferred command because of layout issues + Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { + + @Override + public void execute() { + Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { + + @Override + public void execute() { + redrawNow(); + } + }); + } + }); + } + + /** + * Removes all existing handlers from this chart. + */ + public void removeAllHandlers() { + eventMap.clear(); + chartObject.removeAllListeners(); + } + + /** + * Removes a single handler matching the given handler reference. + * + * @param handlerRef an handler reference + */ + public void removeHandler(HandlerRef handlerRef) { + eventMap.remove(handlerRef); + chartObject.removeListener(handlerRef); + } + + /** + * Call this method to register to receive events fired by a visualization hosted on your page. Note that this will + * not work for visualizations embedded in a gadget. + * + * @param + * @param handler the function to call when the event is fired + * @return the new handler reference. Can be used for removing by calling {@link #removeHandler(HandlerRef)}. + */ + protected final HandlerRef addHandler(H handler) { + HandlerRef handlerRef = chartObject.addListener(handler.getEventName(), handler); + eventMap.put(handlerRef, handler); + return handlerRef; + } + + protected abstract ChartObject createChartObject(Element parent); + + @Override + protected void onLoad() { + if (!unloaded) { + return; + } + unloaded = false; + recreate(); + redraw(); + } + + @Override + protected void onUnload() { + this.unloaded = true; + } + + protected void recreate() { + chartObject = createChartObject(getElement()); + for (EventHandler eventHandler : eventMap.values()) { + chartObject.addListener(eventHandler.getEventName(), eventHandler); + } + } + + protected void redrawNow() { + if (data != null) { + chartObject.draw(data, options); + } + pending = false; + } +} diff --git a/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChart.java b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChart.java new file mode 100644 index 0000000..9fdb125 --- /dev/null +++ b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChart.java @@ -0,0 +1,96 @@ +package com.googlecode.gwt.charts.client.motionchart; + +import com.google.gwt.dom.client.Element; +import com.googlecode.gwt.charts.client.ChartObject; +import com.googlecode.gwt.charts.client.ChartWidget; +import com.googlecode.gwt.charts.client.DataSource; +import com.googlecode.gwt.charts.client.event.ErrorHandler; +import com.googlecode.gwt.charts.client.event.HandlerRef; +import com.googlecode.gwt.charts.client.event.ReadyHandler; +import com.googlecode.gwt.charts.client.event.StateChangeHandler; + + +/** + * A dynamic chart to explore several indicators over time. The chart is rendered within the browser using Flash + */ +public class MotionChart extends ChartWidget { + + private boolean isResponsive = true; + + /** + * Creates a new chart widget. + */ + public MotionChart() { + super(); + } + + /** + * Adds an handler that listens for error events. + * + * @param handler the class to call when the event is fired + * @return the handler reference + */ + public HandlerRef addErrorHandler(ErrorHandler handler) { + return addHandler(handler); + } + + /** + * Adds an handler that listens for ready events. + * + * @param handler the class to call when the event is fired + * @return the handler reference + */ + public HandlerRef addReadyHandler(ReadyHandler handler) { + return addHandler(handler); + } + + /** + * Adds an handler that listens when user has interacted with the chart in some way. + * Call getState() to learn the current state of the chart. + + * + * @param handler the class to call when the event is fired + * @return the handler reference + */ + public HandlerRef addStateChangeHandler(StateChangeHandler handler) { + return addHandler(handler); + } + + + @Override + protected void redrawNow() { + if (isResponsive) { + int height = getParent().getOffsetHeight(); + if (height > 0) { + options.setHeight(height); + } + int width = getParent().getOffsetWidth(); + if (width > 0) { + options.setWidth(width); + } + } + super.redrawNow(); + } + + @Override + public void draw(DataSource data, MotionChartOptions options) { + this.isResponsive = options.getHeight() == null && options.getWidth() == null; + super.draw(data, options); + } + + /** + * Returns the current state of the motionchart, serialized to a JSON string. + * To assign this state to the chart, assign this string to the state option in the draw() method. + * This is often used to specify a custom chart state on startup, instead of using the default state. + * + * @return the state of the charts + */ + public native final String getState() /*-{ + return this.getState(); + }-*/; + + @Override + protected native ChartObject createChartObject(Element container) /*-{ + return new $wnd.google.visualization.MotionChart(container); + }-*/; +} diff --git a/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChartOptions.java b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChartOptions.java new file mode 100644 index 0000000..9ca635e --- /dev/null +++ b/gwt-charts/src/main/java/com/googlecode/gwt/charts/client/motionchart/MotionChartOptions.java @@ -0,0 +1,127 @@ +package com.googlecode.gwt.charts.client.motionchart; + +import com.googlecode.gwt.charts.client.options.Options; + +/** + * Configuration options for {@link MotionChart}. + * + * @see Motion Chart + * Configuration Options + */ +public class MotionChartOptions extends Options { + + /** + * Default constructor. + * + * @return a new object instance + */ + public static MotionChartOptions create() { + return createObject().cast(); + } + + protected MotionChartOptions() { + } + + /** + * An initial display state for the chart. + * This is a serialized JSON object that describes zoom level, selected dimensions, selected bubbles/entities, and other state descriptions. + * See Setting Initial State to learn how to set this. + * + * @param state (Default: null) + */ + public final native void setState(String state) /*-{ + this.state = state; + }-*/; + + /** + * false hides the buttons that control the chart type (bubbles / lines / columns) at top right corner. + * + * @param showChartButtons (Default: true) + */ + public final native void setShowChartButtons(boolean showChartButtons) /*-{ + this.showChartButtons = showChartButtons; + }-*/; + + /** + * false hides the title label of the entities (derived from the label of the first column in the data table). + * + * @param showHeader (Default: true) + */ + public final native void setShowHeader(boolean showHeader) /*-{ + this.showHeader = showHeader; + }-*/; + + /** + * false hides the list of visible entities. + * + * @param showSelectListComponent (Default: true) + */ + public final native void setShowSelectListComponent(boolean showSelectListComponent) /*-{ + this.showSelectListComponent = showSelectListComponent; + }-*/; + + /** + * false hides the right hand panel. + + * @param showSidePanel (Default: true) + */ + public final native void setShowSidePanel(boolean showSidePanel) /*-{ + this.showSidePanel = showSidePanel; + }-*/; + + /** + * false hides the metric picker for x. + * + * @param showXMetricPicker (Default: true) + */ + public final native void setShowXMetricPicker(boolean showXMetricPicker) /*-{ + this.showXMetricPicker = showXMetricPicker; + }-*/; + + /** + * false hides the metric picker for y. + * + * @param showYMetricPicker (Default: true) + */ + public final native void setShowYMetricPicker(boolean showYMetricPicker) /*-{ + this.showYMetricPicker = showYMetricPicker; + }-*/; + + /** + * false hides the scale picker for x. + * + * @param showXScalePicker (Default: true) + */ + public final native void setShowXScalePicker(boolean showXScalePicker) /*-{ + this.showXScalePicker = showXScalePicker; + }-*/; + + /** + * false hides the scale picker for y. + * + * @param showYScalePicker (Default: true) + */ + public final native void setShowYScalePicker(boolean showYScalePicker) /*-{ + this.showYScalePicker = showYScalePicker; + }-*/; + + /** + * false disables the options compartment in the settings panel. + * + * @param showAdvancedPanel (Default: true) + */ + public final native void setShowAdvancedPanel(boolean showAdvancedPanel) /*-{ + this.showAdvancedPanel = showAdvancedPanel; + }-*/; + + + public final native Integer getWidth() /*-{ + return this.width; + }-*/; + + public final native Integer getHeight() /*-{ + return this.height; + }-*/; + + +}