mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 02:13:55 +00:00
unpacked Highcharts sources for 1.1.3 version; preparing for applying patches
This commit is contained in:
1 parent
7eec2b3ac1
commit
c15e57fc40
105 files changed
+16055
No files matched your search
Executable
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.moxieapps.gwt.highcharts</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,82 @@
|
||||
#Tue Feb 28 12:43:14 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
@@ -0,0 +1,4 @@
|
||||
#Tue Feb 28 12:33:59 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=false
|
||||
resolve.requirebundle=false
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Moxie Apps GWT Highcharts
|
||||
Bundle-SymbolicName: org.moxieapps.gwt.highcharts
|
||||
Bundle-Version: 1.1.4.qualifier
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Export-Package: org.moxieapps.gwt.highcharts.client.plotOptions;uses:="o
|
||||
rg.moxieapps.gwt.highcharts.client,com.google.gwt.json.client,org.moxie
|
||||
apps.gwt.highcharts.client.events,org.moxieapps.gwt.highcharts.client.l
|
||||
abels";version="1.1.3",org.moxieapps.gwt.highcharts;version="1.1.3",org
|
||||
.moxieapps.gwt.highcharts.client;uses:="com.google.gwt.core.client,com.
|
||||
google.gwt.dom.client,com.google.gwt.json.client,org.moxieapps.gwt.high
|
||||
charts.client.plotOptions,com.google.gwt.user.client,org.moxieapps.gwt.
|
||||
highcharts.client.events,org.moxieapps.gwt.highcharts.client.labels,com
|
||||
.google.gwt.user.client.ui";version="1.1.3",org.moxieapps.gwt.highchart
|
||||
s.client.events;uses:="com.google.gwt.core.client,com.google.gwt.dom.cl
|
||||
ient,org.moxieapps.gwt.highcharts.client";version="1.1.3",org.moxieapps
|
||||
.gwt.highcharts.client.labels;uses:="com.google.gwt.core.client,org.mox
|
||||
ieapps.gwt.highcharts.client,com.google.gwt.json.client";version="1.1.3
|
||||
"
|
||||
Import-Package: com.google.gwt.core.client,com.google.gwt.dom.client,com
|
||||
.google.gwt.json.client,com.google.gwt.user.client,com.google.gwt.user.
|
||||
client.ui
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<module>
|
||||
<inherits name='com.google.gwt.user.User'/>
|
||||
<inherits name="com.google.gwt.json.JSON" />
|
||||
<source path="client"/>
|
||||
</module>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<module>
|
||||
<inherits name='com.google.gwt.user.User'/>
|
||||
<inherits name="com.google.gwt.json.JSON" />
|
||||
<source path="client"/>
|
||||
</module>
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 animation options, which
|
||||
* can then be set as the default animation approach for the entire chart via the
|
||||
* {@link Chart#setAnimation(Animation)} method, or just set for certain operations (such as
|
||||
* when adding a new point to a series in {@link Series#addPoint(Number, boolean, boolean, Animation)}.
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* chart.setAnimation(
|
||||
* new Animation()
|
||||
* .setDuration(100)
|
||||
* .setEasing(Animation.Easing.LINEAR)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Animation extends Configurable<Animation> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported animation easing types, which can be passed to methods such as
|
||||
* {@link Animation#setEasing(Animation.Easing)}. Note that more easing functions are
|
||||
* supported via <a href="http://gsgd.co.uk/sandbox/jquery/easing/">jQuery plugins</a>, in
|
||||
* which case you'll want to use the general {@link Animation#setEasing(String)} method
|
||||
* instead to set the easing to a specific string (instead of being restricted to the easing
|
||||
* types included in this enumeration.)
|
||||
*/
|
||||
public enum Easing {
|
||||
|
||||
/**
|
||||
* Displays a constant pace transition.
|
||||
*/
|
||||
LINEAR("linear"),
|
||||
|
||||
/**
|
||||
* Displays the default jQuery easing transition.
|
||||
*/
|
||||
SWING("swing");
|
||||
|
||||
private Easing(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'duration' option of the animation. Equivalent to:
|
||||
* <pre><code>
|
||||
* animation.setOption("duration", 500);
|
||||
* </code></pre>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* animation.setOption("easing", "linear");
|
||||
* </code></pre>
|
||||
* Note that more easing functions are available using
|
||||
* <a href="http://gsgd.co.uk/sandbox/jquery/easing/">jQuery plugins</a>, 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:
|
||||
* <pre><code>
|
||||
* animation.setOption("easing", "linear");
|
||||
* </code></pre>
|
||||
* Note that this method is primarily intended to be used when you're using a
|
||||
* <a href="http://gsgd.co.uk/sandbox/jquery/easing/">jQuery plugin</a> 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);
|
||||
}
|
||||
|
||||
}
|
||||
+1095
File diff suppressed because it is too large.
Load diff
+155
@@ -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:
|
||||
* <code><pre>
|
||||
* chart.getXAxis().setAxisTitle(
|
||||
* new AxisTitle()
|
||||
* .setText("Sales by Month")
|
||||
* .setAlign(AxisTitle.Align.MIDDLE)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AxisTitle extends Configurable<AxisTitle> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported axis title alignment types, which can be passed to methods
|
||||
* like {@link AxisTitle#setAlign(AxisTitle.Align)} method.
|
||||
*/
|
||||
public enum Align {
|
||||
|
||||
/**
|
||||
* Align the title to the bottom (for a y-axis) or to the left (for an x-axis)
|
||||
*/
|
||||
LOW("low"),
|
||||
|
||||
/**
|
||||
* Align the title to the middle (for a y-axis) or to the center (for an x-axis)
|
||||
*/
|
||||
MIDDLE("middle"),
|
||||
|
||||
/**
|
||||
* Align the title to the top (for a y-axis) or to the right (for an x-axis)
|
||||
*/
|
||||
HIGH("high");
|
||||
|
||||
private Align(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option of the title. Equivalent to:
|
||||
* <pre><code>
|
||||
* axisTitle.setOption("align", AxisTitle.Align.LOW);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* axisTitle.setOption("margin", 60);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* axisTitle.setOption("margin", 60);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* axisTitle.setOption("/style/fontWeight", "bold");
|
||||
* axisTitle.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>color: '#6D869F'</li>
|
||||
* <li>fontWeight: 'bold'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* axisTitle.setOption("text", "Sales by Month");
|
||||
* </code></pre>
|
||||
* The actual text of the axis title. It can contain basic HTML text markup
|
||||
* like <b>, <i> and spans with style. Defaults to null.
|
||||
* <p/>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
+2356
File diff suppressed because it is too large.
Load diff
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The main GWT widget that can be constructed and then configured in order to add a Highcharts
|
||||
* chart into a GWT layout container. Note that only standard chart types can be created with
|
||||
* this widget. See the {@link StockChart} for other available chart types.
|
||||
* Basic usage is as follows:
|
||||
* <pre><code>
|
||||
* 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);
|
||||
* </code></pre>
|
||||
* For details on available options see the <a href="http://www.highcharts.com/ref/">Highcharts reference</a>.
|
||||
* <p/>
|
||||
* 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.:
|
||||
* <pre><code>
|
||||
* <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>
|
||||
* </code></pre><pre><code>
|
||||
* <!-- Optionally, add a highcharts theme file -->
|
||||
* <script type="text/javascript" src="js/themes/gray.js"></script>
|
||||
* </code></pre><pre><code>
|
||||
* <!-- Optionally, include the highcharts exporting module -->
|
||||
* <script type="text/javascript" src="js/modules/exporting.js"></script>
|
||||
* </code></pre>
|
||||
* 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
|
||||
* <a href="http://www.highcharts.com/documentation/how-to-use#installation">installation docs</a>
|
||||
* on the Highcharts site for more details.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Chart extends BaseChart<Chart> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported chart zoom types, which can be passed to the
|
||||
* {@link Chart#setZoomType(ZoomType)} method. The zoom type controls in what
|
||||
* dimensions the user can zoom by dragging the mouse
|
||||
*/
|
||||
public enum ZoomType {
|
||||
|
||||
/**
|
||||
* Allow zoom horizontally on the X axis only.
|
||||
*/
|
||||
X("x"),
|
||||
|
||||
/**
|
||||
* Allow zoom vertically on the Y axis only.
|
||||
*/
|
||||
Y("y"),
|
||||
|
||||
/**
|
||||
* Allow zooming both horizontally and vertically (both axes).
|
||||
*/
|
||||
X_AND_Y("xy");
|
||||
|
||||
private ZoomType(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Highcharts chart instance as a GWT Widget that can then be added to
|
||||
* a GWT layout like any other widget. Note that the various methods that support
|
||||
* setting properties of the chart (e.g. {@link #setType(org.moxieapps.gwt.highcharts.client.Series.Type)},
|
||||
* {@link #setBackgroundColor(String)}, {@link #setOption(String, Object)}, etc.)
|
||||
* then support method chaining, allowing for syntax like the following:
|
||||
* <pre><code>
|
||||
* Chart chart = new Chart()
|
||||
* .setType(Series.Type.SPLINE)
|
||||
* .setChartTitleText("Nice Chart")
|
||||
* .setMarginRight(10);
|
||||
* RootPanel.get().add(chart);
|
||||
* </code></pre>
|
||||
*/
|
||||
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:
|
||||
* <pre><code>
|
||||
* chart.setOption("/chart/zoomType", Chart.ZoomType.X);
|
||||
* </code></pre>
|
||||
*
|
||||
* @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";
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+151
@@ -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:
|
||||
* <code><pre>
|
||||
* chart.setChartSubTitle(
|
||||
* new ChartSubtitle()
|
||||
* .setText("Source: Wikipedia")
|
||||
* .setAlign(ChartTitle.Align.MIDDLE)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ChartSubtitle extends Configurable<ChartSubtitle> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option of the subtitle. Equivalent to:
|
||||
* <pre><code>
|
||||
* chartSubtitle.setOption("align", chartSubtitle.Align.LEFT);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartSubtitle.setOption("floating", true);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartSubtitle.setOption("/style/fontWeight", "bold");
|
||||
* chartSubtitle.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>color: '#3E576F'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* chartSubtitle.setOption("text", "Sales by Month");
|
||||
* </code></pre>
|
||||
* The actual text of the axis subtitle. It can contain basic HTML text markup
|
||||
* like <b>, <i> and spans with style. Defaults to null.
|
||||
* <p/>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartSubtitle.setOption("verticalAlign", chartSubtitle.VerticalAlign.BOTTOM);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartSubtitle.setOption("x", 70);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartSubtitle.setOption("y", -20);
|
||||
* </code></pre>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+234
@@ -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:
|
||||
* <code><pre>
|
||||
* chart.setChartTitle(
|
||||
* new ChartTitle()
|
||||
* .setText("Sales by Month")
|
||||
* .setAlign(ChartTitle.Align.MIDDLE)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ChartTitle extends Configurable<ChartTitle> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported chart title horizontal alignment types, which can be passed to methods
|
||||
* like {@link ChartTitle#setAlign(ChartTitle.Align)}.
|
||||
*/
|
||||
public enum Align {
|
||||
|
||||
/**
|
||||
* Left align the chart's title
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Center the chart's title
|
||||
*/
|
||||
CENTER("center"),
|
||||
|
||||
/**
|
||||
* Right align the chart's title
|
||||
*/
|
||||
RIGHT("right");
|
||||
|
||||
private Align(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of supported chart title vertical alignment types, which can be passed to methods
|
||||
* like {@link ChartTitle#setVerticalAlign(ChartTitle.VerticalAlign)}.
|
||||
*/
|
||||
public enum VerticalAlign {
|
||||
|
||||
/**
|
||||
* Show the title at the top of the chart
|
||||
*/
|
||||
TOP("top"),
|
||||
|
||||
/**
|
||||
* Show the title in the middle of the chart
|
||||
*/
|
||||
MIDDLE("middle"),
|
||||
|
||||
/**
|
||||
* Show the title at the bottom of the chart
|
||||
*/
|
||||
BOTTOM("bottom");
|
||||
|
||||
private VerticalAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option of the title. Equivalent to:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("align", ChartTitle.Align.LEFT);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("floating", true);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("margin", 60);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("/style/fontWeight", "bold");
|
||||
* chartTitle.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>color: '#3E576F'</li>
|
||||
* <li>fontSize: '16px'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("text", "Sales by Month");
|
||||
* </code></pre>
|
||||
* The actual text of the axis title. It can contain basic HTML text markup
|
||||
* like <b>, <i> and spans with style. Defaults to null.
|
||||
* <p/>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("verticalAlign", ChartTitle.VerticalAlign.BOTTOM);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("x", 70);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* chartTitle.setOption("y", -20);
|
||||
* </code></pre>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
+314
@@ -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)}.
|
||||
* <p/>
|
||||
* Example which sets the background color to a 10% opacity red color:
|
||||
* <pre><code>
|
||||
* chart.setBackgroundColor(new Color(255, 0, 0, .1));
|
||||
* </code></pre>
|
||||
* <p/>
|
||||
* Example which sets the background color to a linear gradient from white to
|
||||
* a 50% opaque blue:
|
||||
* <pre><code>
|
||||
* chart.setBackgroundColor(new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addColorStop(0, "#FFFFFF")
|
||||
* .addColorStop(0, 200, 200, 255, 0.5)
|
||||
* );
|
||||
* </code></pre>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Color extends Configurable<Color> {
|
||||
|
||||
/**
|
||||
* An empty constructor that can be used when creating a color as a gradient. See the
|
||||
* {@link #setLinearGradient(double, double, double, double)} and {@link #addColorStop(double, String)}
|
||||
* methods (and their overloaded variants.)
|
||||
*/
|
||||
public Color() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a color instance specifying the color in standard RGB hex notation (include the "#")
|
||||
*
|
||||
* @param rgbHexColor The RGB hex of the color (include the "#").
|
||||
*/
|
||||
public Color(String rgbHexColor) {
|
||||
value = new JSONString(rgbHexColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a color instance specifying the three components of the RGB color separately (will
|
||||
* result in a color that looks like "rgb(200, 255, 10)".
|
||||
*
|
||||
* @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)
|
||||
*/
|
||||
public Color(int r, int g, int b) {
|
||||
value = new JSONString(createRGB(r, g, b));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a color instance specifying the three components of the RGB color separately as we
|
||||
* as the alpha channel (will result in a color that looks like "rgb(200, 255, 10, 0.5)".
|
||||
*
|
||||
* @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)
|
||||
*/
|
||||
public Color(int r, int g, int b, double a) {
|
||||
value = new JSONString(createRGBA(r, g, b, a));
|
||||
}
|
||||
|
||||
private JSONValue value;
|
||||
|
||||
/**
|
||||
* Sets up this color as a linear gradient from one location in space to another.
|
||||
* Coordinates can either be provided as whole numbers, in which case they are
|
||||
* treated as pixels. Or, they can be provided as number with a "%" character on the
|
||||
* end, in which case they are treated in percentages. E.g.
|
||||
* <p/>
|
||||
* <pre><code>
|
||||
* color.setLinearGradient("0", "0", "500", "500");
|
||||
* </code></pre>
|
||||
* Or:
|
||||
* <pre><code>
|
||||
* color.setLinearGradient("20%", "20%", "80%", "80%");
|
||||
* </code></pre>
|
||||
* 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.
|
||||
* <p/>
|
||||
* 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%".
|
||||
* <p/>
|
||||
* 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.)
|
||||
* <p/>
|
||||
* Example which sets the background color to a linear gradient from white to blue:
|
||||
* <pre><code>
|
||||
* chart.setBackgroundColor(new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addColorStop(0.0, "#FFFFFF")
|
||||
* .addColorStop(0.0, "#0000FF")
|
||||
* );
|
||||
* </code></pre>
|
||||
* 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.)
|
||||
* <p/>
|
||||
* Example which sets the background color to a linear gradient from white to blue:
|
||||
* <pre><code>
|
||||
* 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)
|
||||
* );
|
||||
* </code></pre>
|
||||
* 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.)
|
||||
* <p/>
|
||||
* Example which sets the background color to a linear gradient from solid white to
|
||||
* a 50% opaque blue:
|
||||
* <pre><code>
|
||||
* 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)
|
||||
* );
|
||||
* </code></pre>
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Executable
+148
@@ -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<T> {
|
||||
|
||||
private JSONObject options;
|
||||
|
||||
/**
|
||||
* Set an option on the object at any level, using "/" characters to designate which
|
||||
* level of option you'd like to set. E.g., the following code:
|
||||
* <pre><code>
|
||||
* Chart chart = new Chart();
|
||||
* chart.setOption("/chart/type", "spline");
|
||||
* chart.setOption("/chart/marginRight", 10);
|
||||
* chart.setOption("/title/text", "Nice Chart");
|
||||
* </code></pre>
|
||||
* Would result in initializing HighCharts like the following:
|
||||
* <pre><code>
|
||||
* new HighCharts.Chart({
|
||||
* chart: {
|
||||
* type: "spline",
|
||||
* marginRight: 10
|
||||
* },
|
||||
* title: {
|
||||
* text: "Nice Chart"
|
||||
* }
|
||||
* });
|
||||
* </code></pre>
|
||||
* Note that the beginning "/" is optional, so <code>chart.setOption("/thing", "piglet")</code> is
|
||||
* equivalent to <code>chart.setOption("thing", "piglet")</code>.
|
||||
* <p/>
|
||||
* For details on available options see the <a href="http://www.highcharts.com/ref/">Highcharts reference</a>.
|
||||
* <p/>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* series.setOption("type", "spline");
|
||||
* </code></pre>
|
||||
* Do this instead:
|
||||
* <pre><code>
|
||||
* series.setType(Series.Type.SPLINE);
|
||||
* </code></pre>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
+230
@@ -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:
|
||||
* <code><pre>
|
||||
* chart.setCredits(
|
||||
* new Credits()
|
||||
* .setText("Presented by Snoopy")
|
||||
* .setHref("http://www.peanuts.com/")
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Credits extends Configurable<Credits> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported credits horizontal alignment types, which can be passed to methods
|
||||
* like {@link Credits#setAlign(Credits.Align)} method.
|
||||
*/
|
||||
public enum Align {
|
||||
|
||||
/**
|
||||
* Left align the credits
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Center the credits
|
||||
*/
|
||||
CENTER("center"),
|
||||
|
||||
/**
|
||||
* Right align the credits
|
||||
*/
|
||||
RIGHT("right");
|
||||
|
||||
private Align(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of supported credits vertical alignment types, which can be passed to methods
|
||||
* like {@link Credits#setVerticalAlign(Credits.VerticalAlign)} method.
|
||||
*/
|
||||
public enum VerticalAlign {
|
||||
|
||||
/**
|
||||
* Show the credits at the top of the chart
|
||||
*/
|
||||
TOP("top"),
|
||||
|
||||
/**
|
||||
* Show the credits in the middle of the chart
|
||||
*/
|
||||
MIDDLE("middle"),
|
||||
|
||||
/**
|
||||
* Show the credits at the bottom of the chart
|
||||
*/
|
||||
BOTTOM("bottom");
|
||||
|
||||
private VerticalAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option of the credits. Equivalent to:
|
||||
* <pre><code>
|
||||
* credits.setOption("/position/align", Credit.Align.LEFT);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* credits.setOption("enabled", true);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* credits.setOption("href", "http://www.peanuts.com/");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* credits.setOption("/style/fontWeight", "bold");
|
||||
* credits.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for the credits label. . Defaults to:
|
||||
* <ul>
|
||||
* <li>cursor: 'pointer'</li>
|
||||
* <li>color: '#909090'</li>
|
||||
* <li>fontSize: '10px'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* credits.setOption("text", "Thanks to Snoopy");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* legend.setOption("/position/verticalAlign", Credits.VerticalAlign.BOTTOM);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* legend.setOption("/position/x", 70);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* legend.setOption("/position/y", -20);
|
||||
* </code></pre>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+165
@@ -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:
|
||||
* <ul>
|
||||
* <li>second: '%H:%M:%S'</li>
|
||||
* <li>minute: '%H:%M'</li>
|
||||
* <li>hour: '%H:%M'</li>
|
||||
* <li>day: '%e. %b'</li>
|
||||
* <li>week: '%e. %b'</li>
|
||||
* <li>month: '%b \'%y'</li>
|
||||
* <li>year: '%Y</li>
|
||||
* </ul>
|
||||
* Available replacement codes for the day of date are:
|
||||
* <ul>
|
||||
* <li>'a': Short weekday, like 'Mon'</li>
|
||||
* <li>'A': Long weekday, like 'Monday'</li>
|
||||
* <li>'d': Two digit day of the month, 01 to 31</li>
|
||||
* <li>'e': Day of the month, 1 through 31</li>
|
||||
* </ul>
|
||||
* Available replacement codes for the month of the date are:
|
||||
* <ul>
|
||||
* <li>'b': Short month, like 'Jan'</li>
|
||||
* <li>'B': Long month, like 'January'</li>
|
||||
* <li>'m': Two digit month number, 01 through 12</li>
|
||||
* </ul>
|
||||
* Available replacement codes for the year of the date are:
|
||||
* <ul>
|
||||
* <li>'y': Two digits year, like 09 for 2009</li>
|
||||
* <li>'Y': Four digits year, like 2009</li>
|
||||
* </ul>
|
||||
* Available replacement codes for the time portions are:
|
||||
* <ul>
|
||||
* <li>'H': Two digits hours in 24h format, 00 through 23</li>
|
||||
* <li>'I': Two digits hours in 12h format, 00 through 11</li>
|
||||
* <li>'l': Hours in 12h format, 1 through 12</li>
|
||||
* <li>'M': Two digits minutes, 00 through 59</li>
|
||||
* <li>'p': Upper case AM or PM</li>
|
||||
* <li>'P': Lower case AM or PM</li>
|
||||
* <li>'S': Two digits seconds, 00 through 59</li>
|
||||
* </ul>
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* axis.setDateTimeLabelFormats(
|
||||
* new DateTimeLabelFormats()
|
||||
* .setHour("%I %p")
|
||||
* .setMinute("%I:%M %p")
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DateTimeLabelFormats extends Configurable<DateTimeLabelFormats> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'second' format. Equivalent to:
|
||||
* <pre><code>
|
||||
* dateTimeLabelFormats.setOption("second", "%H:%M:%S");
|
||||
* </code></pre>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* dateTimeLabelFormats.setOption("minute", "%H:%M");
|
||||
* </code></pre>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* dateTimeLabelFormats.setOption("hour", "%H:%M");
|
||||
* </code></pre>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* dateTimeLabelFormats.setOption("day", "%e. %b");
|
||||
* </code></pre>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* dateTimeLabelFormats.setOption("week", "%e. %b");
|
||||
* </code></pre>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* dateTimeLabelFormats.setOption("month", "%b \'%y");
|
||||
* </code></pre>
|
||||
*
|
||||
* @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:
|
||||
* <pre><code>
|
||||
* dateTimeLabelFormats.setOption("year", "%Y");
|
||||
* </code></pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
+132
@@ -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.
|
||||
* <p/>
|
||||
* Note that the "exporting" module must be included in the page in order for the exporting
|
||||
* navigation options to apply. E.g.:
|
||||
* <p/>
|
||||
* <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<Exporting> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported exporting file types, which can be passed to the
|
||||
* {@link Exporting#setType(Exporting.Type)} method.
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* Portable Network Graphics file type
|
||||
*/
|
||||
PNG("image/png"),
|
||||
|
||||
/**
|
||||
* Joint Photographic Experts Group file type
|
||||
*/
|
||||
JPEG("image/jpeg"),
|
||||
|
||||
/**
|
||||
* Portable Document Format file type
|
||||
*/
|
||||
PDF("application/pdf"),
|
||||
|
||||
/**
|
||||
* Scalable Vector Graphics file type
|
||||
*/
|
||||
SVG("image/svg+xml");
|
||||
|
||||
private Type(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: Add buttons configuration methods
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'enabled' option for the exporting module. Equivalent to:
|
||||
* <pre><code>
|
||||
* exporting.setOption("enabled", true);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* exporting.setOption("filename", true);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* exporting.setOption("type", "image/jpeg");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* exporting.setOption("url", "http://export.highcharts.com");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* exporting.setOption("width", 600);
|
||||
* </code></pre>
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
+93
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
+86
@@ -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:
|
||||
* <code><pre>
|
||||
* 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")
|
||||
* ),
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LabelItem extends Configurable<LabelItem> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'html' option of the label item. Equivalent to:
|
||||
* <pre><code>
|
||||
* labelItem.setOption("html", "Australia");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* labelItem.setOption("/style/left", "100px");
|
||||
* labelItem.setOption("/style/top", "10px");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for each label. To position the label, use left and top like this:
|
||||
* <pre><code>
|
||||
* new LabelItem()
|
||||
* .setHtml("Antarctica")
|
||||
* .setStyle(new Style()
|
||||
* .setColor("#0000FF")
|
||||
* .setTop("10px")
|
||||
* .setLeft("100px")
|
||||
* )
|
||||
* <p/>
|
||||
* </code></pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
+13
@@ -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
|
||||
|
||||
}
|
||||
+478
@@ -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:
|
||||
* <code><pre>
|
||||
* chart.setLegend(
|
||||
* new Legend()
|
||||
* .setBorderColor("#CC0000")
|
||||
* .setLayout(Legend.Layout.HORIZONTAL)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Legend extends Configurable<Legend> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported legend horizontal alignment types, which can be passed to methods
|
||||
* like {@link Legend#setAlign(Legend.Align)} method.
|
||||
*/
|
||||
public enum Align {
|
||||
|
||||
/**
|
||||
* Left align the legend
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Center the legend
|
||||
*/
|
||||
CENTER("center"),
|
||||
|
||||
/**
|
||||
* Right align the legend
|
||||
*/
|
||||
RIGHT("right");
|
||||
|
||||
private Align(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of supported legend vertical alignment types, which can be passed to methods
|
||||
* like {@link Legend#setVerticalAlign(Legend.VerticalAlign)} method.
|
||||
*/
|
||||
public enum VerticalAlign {
|
||||
|
||||
/**
|
||||
* Show the legend at the top of the chart
|
||||
*/
|
||||
TOP("top"),
|
||||
|
||||
/**
|
||||
* Show the legend in the middle of the chart
|
||||
*/
|
||||
MIDDLE("middle"),
|
||||
|
||||
/**
|
||||
* Show the legend at the bottom of the chart
|
||||
*/
|
||||
BOTTOM("bottom");
|
||||
|
||||
private VerticalAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of supported legend layout types, which can be passed to methods
|
||||
* like {@link Legend#setLayout(Layout)} method.
|
||||
*/
|
||||
public enum Layout {
|
||||
|
||||
/**
|
||||
* Lay the legend items out in a horizontal row
|
||||
*/
|
||||
HORIZONTAL("horizontal"),
|
||||
|
||||
/**
|
||||
* Lay the legend items out in a vertical stack
|
||||
*/
|
||||
VERTICAL("vertical");
|
||||
|
||||
private Layout(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("align", Legend.Align.LEFT);
|
||||
* </code></pre>
|
||||
* The horizontal alignment of the legend box within the chart area. Can be one of "left", "center" and "right".
|
||||
* Defaults to {@link Legend.Align#CENTER}.
|
||||
*
|
||||
* @param align The horizontal alignment of the legend box within the chart area.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setAlign(Align align) {
|
||||
return this.setOption("align", align != null ? align.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'backgroundColor' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("backgroundColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The background color of the legend, filling the rounded corner border. Defaults to null.
|
||||
*
|
||||
* @param backgroundColor The value to set as the 'backgroundColor' option on the legend.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setBackgroundColor(String backgroundColor) {
|
||||
return this.setOption("backgroundColor", backgroundColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderColor' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("borderColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The color of the drawn border around the legend. Defaults to #909090.
|
||||
*
|
||||
* @param borderColor The color of the drawn border around the legend.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setBorderColor(String borderColor) {
|
||||
return this.setOption("borderColor", borderColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderRadius' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("borderRadius", 8);
|
||||
* </code></pre>
|
||||
* The border corner radius of the legend. Defaults to 5.
|
||||
*
|
||||
* @param borderRadius The border corner radius of the legend.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setBorderRadius(Number borderRadius) {
|
||||
return this.setOption("borderRadius", borderRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderWidth' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("borderWidth", 3);
|
||||
* </code></pre>
|
||||
* The width of the drawn border around the legend. Defaults to 1.
|
||||
*
|
||||
* @param borderWidth The width of the drawn border around the legend.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setBorderWidth(Number borderWidth) {
|
||||
return this.setOption("borderWidth", borderWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'floating' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("floating", true);
|
||||
* </code></pre>
|
||||
* When the legend is floating, the plot area ignores it and is allowed to be placed below it. Defaults to false.
|
||||
*
|
||||
* @param floating 'true' to float the legend above the plot area, or 'false' (the default) to make space for it.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setFloating(boolean floating) {
|
||||
return this.setOption("floating", floating);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'enabled' option for the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("enabled", true);
|
||||
* </code></pre>
|
||||
* Enable or disable the legend. Defaults to true.
|
||||
*
|
||||
* @param enabled Whether or not to enable or disable the legend.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setEnabled(boolean enabled) {
|
||||
return this.setOption("enabled", enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'itemHiddenStyle' options of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("/itemHiddenStyle/fontWeight", "bold");
|
||||
* legend.setOption("/itemHiddenStyle/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for each legend item when the corresponding series or point is hidden. Properties are inherited
|
||||
* from {@link #setStyle(Style)} unless overridden here. Defaults to:
|
||||
* <ul>
|
||||
* <li>color: '#CCC'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param itemHiddenStyle CSS styles for each legend item when the corresponding series or point is hidden.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setItemHiddenStyle(Style itemHiddenStyle) {
|
||||
return this.setOption("itemHiddenStyle", itemHiddenStyle != null ? itemHiddenStyle.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'itemHoverStyle' options of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("/itemHoverStyle/fontWeight", "bold");
|
||||
* legend.setOption("/itemHoverStyle/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for each legend item in hover mode. Properties are inherited from {@link #setStyle(Style)}
|
||||
* unless overridden here. Defaults to:
|
||||
* <ul>
|
||||
* <li>color: '#000'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param itemHoverStyle CSS styles for each legend item in hover mode.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setItemHoverStyle(Style itemHoverStyle) {
|
||||
return this.setOption("itemHoverStyle", itemHoverStyle != null ? itemHoverStyle.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'itemStyle' options of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("/itemStyle/fontWeight", "bold");
|
||||
* legend.setOption("/itemStyle/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for each legend item. Defaults to:
|
||||
* <ul>
|
||||
* <li>cursor: 'pointer'</li>
|
||||
* <li>color: '#3E576F'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param itemStyle CSS styles for each legend item.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setItemStyle(Style itemStyle) {
|
||||
return this.setOption("itemStyle", itemStyle != null ? itemStyle.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'itemWidth' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("itemWidth", 150);
|
||||
* </code></pre>
|
||||
* The width for each legend item. This is useful in a horizontal layout with many items
|
||||
* when you want the items to align vertically. Defaults to null.
|
||||
*
|
||||
* @param itemWidth The width for each legend item, or null to automatically calculate.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setItemWidth(Number itemWidth) {
|
||||
return this.setOption("itemWidth", itemWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'layout' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("layout", Layout.VERTICAL);
|
||||
* </code></pre>
|
||||
* The layout of the legend items. Can be one of "horizontal" or "vertical".
|
||||
* Defaults to {@link Layout#HORIZONTAL}.
|
||||
*
|
||||
* @param layout The layout of the legend items.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setLayout(Layout layout) {
|
||||
return this.setOption("layout", layout != null ? layout.toString() : null);
|
||||
}
|
||||
|
||||
// TODO: Add label formatter
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'margin' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("margin", 60);
|
||||
* </code></pre>
|
||||
* If the plot area sized is calculated automatically and the legend is not floating, the
|
||||
* legend margin is the space between the legend and the axis labels or plot area. Defaults to 15.
|
||||
*
|
||||
* @param margin The space between the legend and the axis labels or plot area.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setMargin(Number margin) {
|
||||
return this.setOption("margin", margin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'reversed' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("reversed", true);
|
||||
* </code></pre>
|
||||
* Whether to reverse the order of the legend items compared to the order of the series
|
||||
* or points as defined in the configuration object. Defaults to false.
|
||||
*
|
||||
* @param reversed 'true' to reverse the order of the legend items.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setReversed(boolean reversed) {
|
||||
return this.setOption("reversed", reversed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'shadow' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("shadow", true);
|
||||
* </code></pre>
|
||||
* Whether to apply a drop shadow to the legend. A {@link #setBackgroundColor(String)}
|
||||
* also needs to be applied for this to take effect. Defaults to false.
|
||||
*
|
||||
* @param shadow 'true' to apply a drop shadow to the legend.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setShadow(boolean shadow) {
|
||||
return this.setOption("shadow", shadow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'style' options of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("/style/fontWeight", "bold");
|
||||
* legend.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for the legend area. In the 1.x versions the position of the legend area was
|
||||
* determined by CSS. In 2.x, the position is determined by properties like
|
||||
* {@link #setAlign(org.moxieapps.gwt.highcharts.client.Legend.Align)},
|
||||
* {@link #setVerticalAlign(org.moxieapps.gwt.highcharts.client.Legend.VerticalAlign)},
|
||||
* {@link #setX(Number)} and {@link #setY(Number)}, but the styles are still parsed for backwards compatibility.
|
||||
*
|
||||
* @param style CSS styles for the legend area.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setStyle(Style style) {
|
||||
return this.setOption("style", style != null ? style.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'symbolPadding' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("symbolPadding", 4);
|
||||
* </code></pre>
|
||||
* The pixel padding between the legend item symbol and the legend item text. Defaults to 5.
|
||||
*
|
||||
* @param symbolPadding The pixel padding between the legend item symbol and the legend item text.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setSymbolPadding(Number symbolPadding) {
|
||||
return this.setOption("symbolPadding", symbolPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'symbolWidth' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("symbolWidth", 40);
|
||||
* </code></pre>
|
||||
* The pixel width of the legend item symbol. Defaults to 30.
|
||||
*
|
||||
* @param symbolWidth The pixel width of the legend item symbol.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setSymbolWidth(Number symbolWidth) {
|
||||
return this.setOption("symbolWidth", symbolWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'verticalAlign' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("verticalAlign", Legend.VerticalAlign.BOTTOM);
|
||||
* </code></pre>
|
||||
* 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 legend.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setVerticalAlign(VerticalAlign verticalAlign) {
|
||||
return this.setOption("verticalAlign", verticalAlign != null ? verticalAlign.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'width' option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("width", 150);
|
||||
* </code></pre>
|
||||
* The width of the legend box, not including and padding set on the style. Defaults to null.
|
||||
*
|
||||
* @param width The width of the legend box (not including padding).
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setWidth(Number width) {
|
||||
return this.setOption("width", width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'x' position option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("x", 70);
|
||||
* </code></pre>
|
||||
* The x offset of the legend 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 15 together
|
||||
* with {@link Align#CENTER} puts it in the center of the plot area. Defaults to 15.
|
||||
*
|
||||
* @param x The x offset of the legend, relative to the chart's spacing.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setX(Number x) {
|
||||
return this.setOption("x", x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'y' position option of the legend. Equivalent to:
|
||||
* <pre><code>
|
||||
* legend.setOption("y", -20);
|
||||
* </code></pre>
|
||||
* 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 0.
|
||||
*
|
||||
* @param y The y position of the legend, relative to the chart's spacing.
|
||||
* @return A reference to this {@link Legend} instance for convenient method chaining.
|
||||
*/
|
||||
public Legend setY(Number y) {
|
||||
return this.setOption("y", y);
|
||||
}
|
||||
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 loading options for the
|
||||
* chart, which can then be set on the chart (via the {@link Chart#setLoading(Loading)} method.)
|
||||
* 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 GWT remoting
|
||||
* requests. The "Loading..." text itself is not part of this configuration object, but part of
|
||||
* the {@link Lang} object.
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* chart.setLoading(
|
||||
* new Loading()
|
||||
* .setShowDuration(500)
|
||||
* .setStyle(
|
||||
* new Style()
|
||||
* .setColor("red")
|
||||
* .setFontSize("16px")
|
||||
* )
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Loading extends Configurable<Loading> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'hideDuration' option of the loading options. Equivalent to:
|
||||
* <pre><code>
|
||||
* loading.setOption("hideDuration", 150);
|
||||
* </code></pre>
|
||||
* The duration in milliseconds of the fade out effect. Defaults to 100.
|
||||
*
|
||||
* @param hideDuration The duration in milliseconds of the fade out effect.
|
||||
* @return A reference to this {@link Loading} instance for convenient method chaining.
|
||||
*/
|
||||
public Loading setHideDuration(Number hideDuration) {
|
||||
return this.setOption("hideDuration", hideDuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'labelStyle' options of the loading options. Equivalent to:
|
||||
* <pre><code>
|
||||
* loading.setOption("labelStyle/fontSize", "16px");
|
||||
* loading.setOption("labelStyle/color", "red");
|
||||
* </code></pre>
|
||||
* CSS styles for the loading label span. Defaults to:
|
||||
* <ul>
|
||||
* <li>fontWeight: bold</li>
|
||||
* <li>position: relative</li>
|
||||
* <li>top: 1em</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param labelStyle The CSS styles for the loading label span.
|
||||
* @return A reference to this {@link Loading} instance for convenient method chaining.
|
||||
*/
|
||||
public Loading setLabelStyle(Style labelStyle) {
|
||||
return this.setOption("labelStyle", labelStyle != null ? labelStyle.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Convenience method for setting the 'showDuration' option of the loading options. Equivalent to:
|
||||
* <pre><code>
|
||||
* loading.setOption("showDuration", 150);
|
||||
* </code></pre>
|
||||
* The duration in milliseconds of the fade in effect. Defaults to 100.
|
||||
*
|
||||
* @param showDuration The duration in milliseconds of the fade in effect.
|
||||
* @return A reference to this {@link Loading} instance for convenient method chaining.
|
||||
*/
|
||||
public Loading setShowDuration(Number showDuration) {
|
||||
return this.setOption("showDuration", showDuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'labelStyle' options of the loading options. Equivalent to:
|
||||
* <pre><code>
|
||||
* loading.setOption("style/backgroundColor", "red");
|
||||
* loading.setOption("style/opacity", "0.8
|
||||
* </code></pre>
|
||||
* CSS styles for the loading screen that covers the plot area. Defaults to:
|
||||
* <ul>
|
||||
* <li>position: absolute</li>
|
||||
* <li>backgroundColor: 'white'</li>
|
||||
* <li>opacity: 0.5</li>
|
||||
* <li>textAlign: center</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param style The CSS styles for the loading screen that covers the plot area.
|
||||
* @return A reference to this {@link Loading} instance for convenient method chaining.
|
||||
*/
|
||||
public Loading setStyle(Style style) {
|
||||
return this.setOption("style", style != null ? style.getOptions() : null);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
package org.moxieapps.gwt.highcharts.client;
|
||||
|
||||
/**
|
||||
* A configurable class that will allow you to control the options for buttons and menus
|
||||
* appearing in the exporting module. An instance of this class can be constructed and then
|
||||
* set on the chart via the {@link BaseChart#setNavigation(Navigation)} method.
|
||||
* <p/>
|
||||
* Note that the "exporting" module must be included in the page in order for the exporting
|
||||
* navigation options to apply. E.g.:
|
||||
* <p/>
|
||||
* <script type="text/javascript" src="js/modules/exporting.js"></script>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class Navigation extends Configurable<Navigation> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'menuStyle' options of the navigation area. Equivalent to:
|
||||
* <pre><code>
|
||||
* navigation.setOption("/menuStyle/left", "100px");
|
||||
* navigation.setOption("/menuStyle/top", "10px");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for the popup menu appearing by default when the export icon is clicked. This menu is rendered in HTML.
|
||||
* Default options for the "menuStyle" are as follows:
|
||||
* <ul>
|
||||
* <li><b>border</b>: '1px solid #A0A0A0'</li>
|
||||
* <li><b>background</b>: '#FFFFFF</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param menuStyle CSS styles for the popup menus of the exporting module
|
||||
* @return A reference to this {@link Navigation} instance for convenient method chaining.
|
||||
*/
|
||||
public Navigation setMenuStyle(Style menuStyle) {
|
||||
return this.setOption("menuStyle", menuStyle != null ? menuStyle.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'menuItemStyle' options of the navigation area. Equivalent to:
|
||||
* <pre><code>
|
||||
* navigation.setOption("/menuItemStyle/left", "100px");
|
||||
* navigation.setOption("/menuItemStyle/top", "10px");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for the individual items within the popup menu appearing by default when the export icon
|
||||
* is clicked. The menu items are rendered in HTML. Default options for the "menuItemStyle" are as follows:
|
||||
* <ul>
|
||||
* <li><b>padding</b>: '0 5px'</li>
|
||||
* <li><b>background</b>: NONE</li>
|
||||
* <li><b>color</b>: '#303030'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param menuItemStyle CSS styles for the individual items in the popup menus of the exporting module.
|
||||
* @return A reference to this {@link Navigation} instance for convenient method chaining.
|
||||
*/
|
||||
public Navigation setMenuItemStyle(Style menuItemStyle) {
|
||||
return this.setOption("menuItemStyle", menuItemStyle != null ? menuItemStyle.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'menuItemHoverStyle' options of the navigation area. Equivalent to:
|
||||
* <pre><code>
|
||||
* navigation.setOption("/menuItemHoverStyle/left", "100px");
|
||||
* navigation.setOption("/menuItemHoverStyle/top", "10px");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for the hover state of the individual items within the popup menu appearing by default
|
||||
* when the export icon is clicked. The menu items are rendered in HTML. Default options for
|
||||
* the "menuItemHoverStyle" are as follows:
|
||||
* <ul>
|
||||
* <li><b>background</b>: '#4572A5'</li>
|
||||
* <li><b>color</b>: '#FFFFFF'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param menuItemHoverStyle CSS styles for the hover style of the individual items in the popup menus
|
||||
* of the exporting module.
|
||||
* @return A reference to this {@link Navigation} instance for convenient method chaining.
|
||||
*/
|
||||
public Navigation setMenuItemHoverStyle(Style menuItemHoverStyle) {
|
||||
return this.setOption("menuItemHoverStyle", menuItemHoverStyle != null ? menuItemHoverStyle.getOptions() : null);
|
||||
}
|
||||
|
||||
// TODO: Add buttonOptions configuration methods
|
||||
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* 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.dom.client.Document;
|
||||
import org.moxieapps.gwt.highcharts.client.labels.PlotBandLabel;
|
||||
|
||||
/**
|
||||
* A configurable class that can be used to represent plot bands across an area of the chart, which can
|
||||
* then be set on an axis (via the {@link Axis#setPlotBands(PlotBand...)} method.)
|
||||
* Note that a plot band is a colored band stretching across the plot area marking an interval on the axis.
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* XAxis xAxis = chart.getXAxis();
|
||||
* xAxis.setPlotBands(
|
||||
* xAxis.createPlotBand()
|
||||
* .setColor("#CC0000")
|
||||
* .setFrom(40)
|
||||
* .setTo(80),
|
||||
* xAxis.createPlotBand()
|
||||
* .setColor("#00CC00")
|
||||
* .setFrom(80)
|
||||
* .setTo(120),
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class PlotBand extends Configurable<PlotBand> {
|
||||
|
||||
private Axis axis;
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Use the {@link Axis#createPlotBand()} method to create new plot bands
|
||||
*
|
||||
* @param axis The axis instance that this plot band is being created within.
|
||||
*/
|
||||
PlotBand(Axis axis) {
|
||||
this.axis = axis;
|
||||
id = Document.get().createUniqueId();
|
||||
setOption("id", id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'color' option of the plot band to an RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBand.setOption("color", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The RGB color for the plot band. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setColor(Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param color The value to set as the 'color' option on the plot band.
|
||||
* @return A reference to this {@link PlotBand} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBand setColor(String color) {
|
||||
return this.setOption("color", color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'color' option of the plot band, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBand.setOption("color", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* The color or gradient for the plot band. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setColor(String)} version instead.
|
||||
*
|
||||
* @param color The color gradient or color with an alpha channel to set as the 'color' option on the plot band.
|
||||
* @return A reference to this {@link PlotBand} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBand setColor(Color color) {
|
||||
return this.setOption("color", color != null ? color.getOptionValue() : null);
|
||||
}
|
||||
|
||||
// TODO: Add events
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'from' option of the plot band. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBand.setOption("from", 40);
|
||||
* </code></pre>
|
||||
* The start position of the plot band in axis units. Defaults to null.
|
||||
*
|
||||
* @param from The start position of the plot band in axis units.
|
||||
* @return A reference to this {@link PlotBand} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBand setFrom(Number from) {
|
||||
return this.setOption("from", from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'label' options of the plot band. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBand.setOption("/label/align", PlotBandLabel.Align.LEFT);
|
||||
* plotBand.setOption("/label/x", 20);
|
||||
* etc....
|
||||
* </code></pre>
|
||||
*
|
||||
* @param plotBandLabel The options for the label on the plot band.
|
||||
* @return A reference to this {@link PlotBand} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBand setLabel(PlotBandLabel plotBandLabel) {
|
||||
return this.setOption("label", plotBandLabel != null ? plotBandLabel.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'to' option of the plot band. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBand.setOption("to", 40);
|
||||
* </code></pre>
|
||||
* The end position of the plot band in axis units. Defaults to null.
|
||||
*
|
||||
* @param to The end position of the plot band in axis units.
|
||||
* @return A reference to this {@link PlotBand} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBand setTo(Number to) {
|
||||
return this.setOption("to", to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'zIndex' option of the plot band. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBand.setOption("zIndex", 100);
|
||||
* </code></pre>
|
||||
* The z index of the plot band within the chart. Defaults to null.
|
||||
*
|
||||
* @param zIndex The z index of the plot band within the chart.
|
||||
* @return A reference to this {@link PlotBand} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBand setZIndex(Number zIndex) {
|
||||
return this.setOption("zIndex", zIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used to retrieve the unique id generated for this plot band.
|
||||
*
|
||||
* @return The unique id of this plot band
|
||||
* @since 1.1.3
|
||||
*/
|
||||
String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* 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.dom.client.Document;
|
||||
import org.moxieapps.gwt.highcharts.client.labels.PlotLineLabel;
|
||||
|
||||
/**
|
||||
* A configurable class that can be used to represent plot lines on an axis of the chart, which can
|
||||
* then be set on an axis (via the {@link Axis#setPlotLines(PlotLine...)} method.)
|
||||
* Note that a plot line is a line stretching across the plot area, marking a specific value on one of the axes.
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* XAxis xAxis = chart.getXAxis();
|
||||
* xAxis.setPlotLines(
|
||||
* xAxis.createPlotLine()
|
||||
* .setColor("#CC0000")
|
||||
* .setValue(40),
|
||||
* xAxis.createPlotLine()
|
||||
* .setColor("#009900")
|
||||
* .setValue(60)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class PlotLine extends Configurable<PlotLine> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported dash style types, which can be passed to the
|
||||
* {@link #setDashStyle(DashStyle)} method. See this
|
||||
* <a href="http://jsfiddle.net/cSrgA/">demonstration</a> for a visible reference
|
||||
* of the available dash styles.
|
||||
*/
|
||||
public enum DashStyle {
|
||||
|
||||
/**
|
||||
* Solid line, no dashes
|
||||
*/
|
||||
SOLID("Solid"),
|
||||
|
||||
/**
|
||||
* Short dashes, "- - - -"
|
||||
*/
|
||||
SHORT_DASH("ShortDash"),
|
||||
|
||||
/**
|
||||
* Short (tightly spaced) dots, ". . . ."
|
||||
*/
|
||||
SHORT_DOT("ShortDot"),
|
||||
|
||||
/**
|
||||
* Short (tightly spaced) dash and dots, "- . - . - ."
|
||||
*/
|
||||
SHORT_DASH_DOT("ShortDashDot"),
|
||||
|
||||
/**
|
||||
* Short (tightly spaced) dash and two dots, "- . . - . . - . ."
|
||||
*/
|
||||
SHORT_DASH_DOT_DOT("ShortDashDotDot"),
|
||||
|
||||
/**
|
||||
* Large (widely spaced) dots, ". . . . ."
|
||||
*/
|
||||
DOT("Dot"),
|
||||
|
||||
/**
|
||||
* Medium size dashes, "-- -- -- --"
|
||||
*/
|
||||
DASH("Dash"),
|
||||
|
||||
/**
|
||||
* Long dashes, "--- --- --- ---"
|
||||
*/
|
||||
LONG_DASH("LongDash"),
|
||||
|
||||
/**
|
||||
* Medium size dashes and a dot, "-- . -- . -- . --"
|
||||
*/
|
||||
DASH_DOT("DashDot"),
|
||||
|
||||
/**
|
||||
* Long dashes and a dot, "--- . --- . --- . ---"
|
||||
*/
|
||||
LONG_DASH_DOT("LongDashDot"),
|
||||
|
||||
/**
|
||||
* Long dashes and two dots, "--- .. --- .. --- .. ---"
|
||||
*/
|
||||
LONG_DASH_DOT_DOT("LongDashDotDot");
|
||||
|
||||
private DashStyle(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Axis axis;
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Use the {@link Axis#createPlotLine()} method to create new plot lines
|
||||
*
|
||||
* @param axis The axis instance that this plotline is being created within.
|
||||
*/
|
||||
PlotLine(Axis axis) {
|
||||
this.axis = axis;
|
||||
id = Document.get().createUniqueId();
|
||||
setOption("id", id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'color' option of the plot line to an RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLine.setOption("color", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The RGB color for the plot line. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setColor(Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param color The value to set as the 'color' option on the plot line.
|
||||
* @return A reference to this {@link PlotLine} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLine setColor(String color) {
|
||||
return this.setOption("color", color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'color' option of the plot line, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLine.setOption("color", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* The color or gradient for the plot line. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setColor(String)} version instead.
|
||||
*
|
||||
* @param color The color gradient or color with an alpha channel to set as the 'color' option on the plot line.
|
||||
* @return A reference to this {@link PlotLine} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLine setColor(Color color) {
|
||||
return this.setOption("color", color != null ? color.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'dashStyle' plot line optoin. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLine.setOption("dashStyle", DashStyle.DOT);
|
||||
* </code></pre>
|
||||
* The dashing or dot style for the plot line. Defaults to {@link DashStyle#SOLID}. See this
|
||||
* <a href="http://jsfiddle.net/cSrgA/">demonstration</a> for a visible reference
|
||||
* of the available dash styles.
|
||||
*
|
||||
* @param dashStyle The dash style to use for this plot line, or null to use the default.
|
||||
* @return A reference to this {@link PlotLine} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLine setDashStyle(PlotLine.DashStyle dashStyle) {
|
||||
return this.setOption("dashStyle", dashStyle != null ? dashStyle.toString() : null);
|
||||
}
|
||||
|
||||
// TODO: Add events
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'label' options of the plot line. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLine.setOption("/label/align", PlotLineLabel.Align.LEFT);
|
||||
* plotLine.setOption("/label/x", 20);
|
||||
* etc....
|
||||
* </code></pre>
|
||||
*
|
||||
* @param plotLineLabel The options for the label on the plot line.
|
||||
* @return A reference to this {@link PlotLine} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLine setLabel(PlotLineLabel plotLineLabel) {
|
||||
return this.setOption("label", plotLineLabel != null ? plotLineLabel.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'value' option of the plot line. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLine.setOption("value", 40);
|
||||
* </code></pre>
|
||||
* The position of the line in axis units. Defaults to null.
|
||||
*
|
||||
* @param value The position of the line in axis units.
|
||||
* @return A reference to this {@link PlotLine} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLine setValue(Number value) {
|
||||
return this.setOption("value", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'width' option of the plot line. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLine.setOption("width", 2);
|
||||
* </code></pre>
|
||||
* The width or thickness of the plot line. Defaults to null.
|
||||
*
|
||||
* @param width The width or thickness of the plot line.
|
||||
* @return A reference to this {@link PlotLine} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLine setWidth(Number width) {
|
||||
return this.setOption("width", width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'zIndex' option of the plot line. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLine.setOption("zIndex", 100);
|
||||
* </code></pre>
|
||||
* The z index of the plot line within the chart. Defaults to null.
|
||||
*
|
||||
* @param zIndex The z index of the plot line within the chart.
|
||||
* @return A reference to this {@link PlotLine} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLine setZIndex(Number zIndex) {
|
||||
return this.setOption("zIndex", zIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used to retrieve the unique id generated for this plot line.
|
||||
*
|
||||
* @return The unique id of this plot line
|
||||
* @since 1.1.3
|
||||
*/
|
||||
String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+699
@@ -0,0 +1,699 @@
|
||||
/*
|
||||
* 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.JSONObject;
|
||||
import org.moxieapps.gwt.highcharts.client.plotOptions.Marker;
|
||||
|
||||
/**
|
||||
* Represents a single data point that can be added to a {@link Series}. As an extension
|
||||
* of {@link Configurable} each point instance can also optionally have configuration options set on it.
|
||||
* Standard example:
|
||||
* <code><pre>
|
||||
* chart.addSeries(chart.createSeries()
|
||||
* .setName("Browser share")
|
||||
* .setPoints(new Point[] {
|
||||
* new Point(15, 45.0),
|
||||
* new Point(25, 26.8),
|
||||
* new Point(35, 12.8),
|
||||
* new Point(46, 8.5),
|
||||
* new Point(55, 6.2),
|
||||
* new Point(65, 0.7)
|
||||
* })
|
||||
* );
|
||||
* </pre></code>
|
||||
* </p>
|
||||
* Advanced pie chart example (where the points represent categories and values for each category):
|
||||
* <code><pre>
|
||||
* 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)
|
||||
* })
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Point extends Configurable<Point> {
|
||||
|
||||
private Number y;
|
||||
private Number x;
|
||||
|
||||
/**
|
||||
* Create a new point, setting only the Y axis value that the point should be
|
||||
* rendered at within the series.
|
||||
*
|
||||
* @param y The Y value that the point should be rendered at within the series.
|
||||
*/
|
||||
public Point(Number y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new point, setting both the value that the point should be rendered
|
||||
* at on the X and Y axis within the series.
|
||||
*
|
||||
* @param x The X value that the point should be rendered at within the series.
|
||||
* @param y The Y value that the point should be rendered at within the series.
|
||||
*/
|
||||
public Point(Number x, Number y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new point, setting the Y axis value that the point should be
|
||||
* rendered at within the series as well as the "name" property of the point.
|
||||
*
|
||||
* @param name The value to set as the "property" of the point.
|
||||
* @param y The Y value that the point should be rendered at within the series.
|
||||
*/
|
||||
public Point(String name, Number y) {
|
||||
setName(name);
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private JavaScriptObject nativePoint;
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use, and provides the ability to construct a GWT Point
|
||||
* instance from the native JS Point instance managed within Highcharts.
|
||||
*
|
||||
* @param nativePoint The native javascript object containing the details of the point
|
||||
*/
|
||||
public Point(JavaScriptObject nativePoint) {
|
||||
this.nativePoint = nativePoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Y value of where point should be rendered at within the series.
|
||||
*
|
||||
* @return The Y value of the point (should always be non null).
|
||||
*/
|
||||
public Number getY() {
|
||||
if (this.nativePoint != null) {
|
||||
return nativeGetNumber(this.nativePoint, "y");
|
||||
} else {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the X value of where point should be rendered at within the series.
|
||||
*
|
||||
* @return The X value of the point, or null if no X value was set.
|
||||
*/
|
||||
public Number getX() {
|
||||
if (this.nativePoint != null) {
|
||||
return nativeGetNumber(this.nativePoint, "x");
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'color' option of the point. Equivalent to:
|
||||
* <pre><code>
|
||||
* point.setOption("color", "#CC0000");
|
||||
* </code></pre>
|
||||
* 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.
|
||||
* <pre><code>
|
||||
* new Point(10, 30)
|
||||
* .setMarker(
|
||||
* new Marker()
|
||||
* .setEnabled(true)
|
||||
* .setFillColor("#CC0000")
|
||||
* .setRadius(4)
|
||||
* );
|
||||
* <p/>
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* point.setOption("name", "Green Bears");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* point.setOption("selected", true);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* point.setOption("sliced", false);
|
||||
* </code></pre>
|
||||
* 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. <p/>
|
||||
* 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. <p/>
|
||||
* 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. <p/>
|
||||
* 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;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
Executable
+36
@@ -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<RangeSelector> {
|
||||
|
||||
public RangeSelector setSelected(Number selected) {
|
||||
return this.setOption("selected", selected);
|
||||
}
|
||||
|
||||
public RangeSelector setInputEnabled(boolean inputEnabled) {
|
||||
return this.setOption("inputEnabled", inputEnabled);
|
||||
}
|
||||
|
||||
}
|
||||
+798
@@ -0,0 +1,798 @@
|
||||
/*
|
||||
* 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.dom.client.Document;
|
||||
import com.google.gwt.json.client.JSONArray;
|
||||
import com.google.gwt.json.client.JSONNumber;
|
||||
import com.google.gwt.json.client.JSONObject;
|
||||
import com.google.gwt.json.client.JSONValue;
|
||||
import org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Manages a data series (and its options) that can then be added to a {@link Chart}. As an extension
|
||||
* of {@link Configurable} each series instance can also optionally have configuration options set on it.
|
||||
* In order to create a new series, utilize the {@link Chart#createSeries()} method, configure it, add data
|
||||
* to it, and then add it to the chart via the {@link Chart#addSeries(Series)} method. Note that a series
|
||||
* can be modified after the chart has been rendered as well, which allows for support of dynamic charts or series
|
||||
* that change in some way based on user behavior. Simple example of setting up a series on a chart:
|
||||
* <code><pre>
|
||||
* Series series = chart.createSeries()
|
||||
* .setName("Random Stuff")
|
||||
* .addPoint(40)
|
||||
* .addPoint(35)
|
||||
* .addPoint(60);
|
||||
* chart.addSeries(series);
|
||||
* </pre></code>
|
||||
* Example of updating all of the points in a series at once:
|
||||
* <code><pre>
|
||||
* chart.addSeries(chart.createSeries()
|
||||
* .setName("Random Stuff")
|
||||
* .setPoints(new Number[] { 40, 35, 60 })
|
||||
* );
|
||||
* </pre></code>
|
||||
* Example of changing the options for one point in the series:
|
||||
* <code><pre>
|
||||
* chart.addSeries(chart.createSeries()
|
||||
* .setName("Random Stuff")
|
||||
* .addPoint(40)
|
||||
* .addPoint(new Point(35).setColor("#BF0B23"))
|
||||
* .addPoint(60)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Series extends Configurable<Series> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported series types, which can be passed to methods such as
|
||||
* {@link Series#setType(Series.Type)} or {@link Chart#setType(Series.Type)}.
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* Show the series as an area filled in beneath a non-curved line
|
||||
*/
|
||||
AREA("area"),
|
||||
|
||||
/**
|
||||
* Show the series as an area filled in beneath a curved line
|
||||
*/
|
||||
|
||||
AREA_SPLINE("areaspline"),
|
||||
|
||||
/**
|
||||
* Show the series as horizontal bars
|
||||
*/
|
||||
BAR("bar"),
|
||||
|
||||
/**
|
||||
* Show the series as vertical bars
|
||||
*/
|
||||
COLUMN("column"),
|
||||
|
||||
/**
|
||||
* Show the series as a sequence of connected straight lines
|
||||
*/
|
||||
LINE("line"),
|
||||
|
||||
/**
|
||||
* Show the series as a pie chart
|
||||
*/
|
||||
PIE("pie"),
|
||||
|
||||
/**
|
||||
* Show the series as a scatter plot
|
||||
*/
|
||||
SCATTER("scatter"),
|
||||
|
||||
/**
|
||||
* Show the series as a sequence of lines that are rendered as a spline to appear as a smooth curve
|
||||
*/
|
||||
SPLINE("spline"),
|
||||
|
||||
/**
|
||||
* Show the series as a sequence of bars that show the open, high, low, and close values.
|
||||
* Only available when you're using the {@link StockChart} widget type.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
OHLC("ohlc"),
|
||||
|
||||
/**
|
||||
* Show the series as a sequence of candlesticks, where each candlestick represents four values.
|
||||
* Only available when you're using the {@link StockChart} widget type.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
CANDLESTICK("candlestick");
|
||||
|
||||
private Type(String optionName) {
|
||||
this.optionName = optionName;
|
||||
}
|
||||
|
||||
private final String optionName;
|
||||
|
||||
public String toString() {
|
||||
return optionName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Purposefully set to package scope
|
||||
BaseChart chart;
|
||||
|
||||
// The unique id for this series, that we can use to access the native series instance later if changes
|
||||
// come into the series after it is rendered
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Use the {@link Chart#createSeries()} method to create new series instances.
|
||||
*
|
||||
* @param chart The chart instance that this series is being created within.
|
||||
*/
|
||||
protected Series(BaseChart chart) {
|
||||
this.chart = chart;
|
||||
id = Document.get().createUniqueId();
|
||||
setOption("id", id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'name' option of the series. Equivalent to:
|
||||
* <pre><code>
|
||||
* series.setOption("name", "My Chart");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* series.setOption("stack", "Stack 1");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* series.setOption("stack", 1);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* series.setOption("type", "line");
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* series.setOption("xAxis", 1);
|
||||
* </code></pre>
|
||||
* 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:
|
||||
* <pre><code>
|
||||
* series.setOption("yAxis", 1);
|
||||
* </code></pre>
|
||||
* 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.
|
||||
* <p/>
|
||||
* 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.).
|
||||
* <p/>
|
||||
* 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 <code>addPoint()</code> 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 <code>addPoint()</code> 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<Point> convertedPoints = points;
|
||||
if (isRendered()) {
|
||||
convertedPoints = new ArrayList<Point>();
|
||||
// After the series has been rendered, convert the live JS data series back into GWT objects
|
||||
final JavaScriptObject nativeSeries = chart.get(this.id);
|
||||
if (nativeSeries != null) {
|
||||
JsArray<JavaScriptObject> nativePoints = nativeGetData(nativeSeries);
|
||||
for (int i = 0; i < nativePoints.length(); i++) {
|
||||
JavaScriptObject nativePoint = nativePoints.get(i);
|
||||
convertedPoints.add(new Point(nativePoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
return convertedPoints.toArray(new Point[points.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this series from the chart it is a part of.
|
||||
*
|
||||
* @return 'true' if the series was a part of an active chart and successfully removed, or 'false' if the
|
||||
* given series had not yet been added to any chart.
|
||||
*/
|
||||
public boolean remove() {
|
||||
return chart.removeSeries(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the series if hidden. Only applies after the chart has been rendered.
|
||||
*
|
||||
* @return A reference to this {@link Series} instance for convenient method chaining.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public Series show() {
|
||||
if (isRendered()) {
|
||||
final JavaScriptObject nativeSeries = chart.get(this.id);
|
||||
if (nativeSeries != null) {
|
||||
nativeShow(nativeSeries);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the series if visible. If the {@link BaseChart#setIgnoreHiddenSeries(boolean)} option is true,
|
||||
* the chart is automatically redrawn without this series. Only applies after the chart has been rendered.
|
||||
*
|
||||
* @return A reference to this {@link Series} instance for convenient method chaining.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public Series hide() {
|
||||
if (isRendered()) {
|
||||
final JavaScriptObject nativeSeries = chart.get(this.id);
|
||||
if (nativeSeries != null) {
|
||||
nativeHide(nativeSeries);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select or unselect the series. This means it's selected property is set, the checkbox in the legend is
|
||||
* toggled and when selected, the series is returned in the {@link BaseChart#getSelectedSeries()} method.
|
||||
*
|
||||
* @param select When true, the series is selected. When false it is unselected. See the {@link #selectToggle()}
|
||||
* method to instead toggle the selection state.
|
||||
* @return A reference to this {@link Series} instance for convenient method chaining.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public Series select(boolean select) {
|
||||
if (isRendered()) {
|
||||
final JavaScriptObject nativeSeries = chart.get(this.id);
|
||||
if (nativeSeries != null) {
|
||||
nativeSelect(nativeSeries, select);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the series if it is currently unselected, or unselect the series if it is currently selected.
|
||||
* See the {@link #select(boolean)} method for more explicit control over the selection state of a series.
|
||||
*
|
||||
* @return A reference to this {@link Series} instance for convenient method chaining.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public Series selectToggle() {
|
||||
if (isRendered()) {
|
||||
final JavaScriptObject nativeSeries = chart.get(this.id);
|
||||
if (nativeSeries != null) {
|
||||
nativeSelectToggle(nativeSeries);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used to retrieve the unique id generated for this series.
|
||||
*
|
||||
* @return The unique id of this series
|
||||
*/
|
||||
String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
// Purposefully not using the generic "List" interface here in order optimize GWT performance.
|
||||
private ArrayList<Point> points = new ArrayList<Point>();
|
||||
|
||||
// Purposefully setting to package scope
|
||||
void clearInternalPointsList() {
|
||||
this.points.clear();
|
||||
}
|
||||
|
||||
boolean rendered = false;
|
||||
|
||||
// Purposefully restricting to package scope
|
||||
void setRendered(boolean flag) {
|
||||
this.rendered = flag;
|
||||
}
|
||||
|
||||
private boolean isRendered() {
|
||||
return this.rendered;
|
||||
}
|
||||
|
||||
private static native JavaScriptObject nativeAddPoint(JavaScriptObject series, JavaScriptObject options, boolean redraw, boolean shift, JavaScriptObject animation) /*-{
|
||||
series.addPoint(options, redraw, shift, animation);
|
||||
}-*/;
|
||||
|
||||
private static native JavaScriptObject nativeAddPoint(JavaScriptObject series, JavaScriptObject options, boolean redraw, boolean shift, boolean animation) /*-{
|
||||
series.addPoint(options, redraw, shift, animation);
|
||||
}-*/;
|
||||
|
||||
private static native JavaScriptObject nativeAddPoint(JavaScriptObject series, Number value, boolean redraw, boolean shift, JavaScriptObject animation) /*-{
|
||||
series.addPoint(value, redraw, shift, animation);
|
||||
}-*/;
|
||||
|
||||
private static native JavaScriptObject nativeAddPoint(JavaScriptObject series, Number value, boolean redraw, boolean shift, boolean animation) /*-{
|
||||
series.addPoint(value, redraw, shift, animation);
|
||||
}-*/;
|
||||
|
||||
private static native void nativeSetData(JavaScriptObject series, JavaScriptObject data, boolean redraw) /*-{
|
||||
series.setData(data, redraw);
|
||||
}-*/;
|
||||
|
||||
private static native void nativeShow(JavaScriptObject series) /*-{
|
||||
series.show();
|
||||
}-*/;
|
||||
|
||||
private static native void nativeHide(JavaScriptObject series) /*-{
|
||||
series.hide();
|
||||
}-*/;
|
||||
|
||||
private static native void nativeSelect(JavaScriptObject series, boolean select) /*-{
|
||||
series.select(select);
|
||||
}-*/;
|
||||
|
||||
private static native void nativeSelectToggle(JavaScriptObject series) /*-{
|
||||
series.select(null);
|
||||
}-*/;
|
||||
|
||||
private static native JsArray<JavaScriptObject> nativeGetData(JavaScriptObject series) /*-{
|
||||
return series.data;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* BETA! The main GWT widget that can be constructed and then configured in order to add a Highstock
|
||||
* chart into a GWT layout container. Note that for more basic chart types just make use of the
|
||||
* {@link Chart} widget instead.
|
||||
* Basic usage is as follows:
|
||||
* <pre><code>
|
||||
* 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);
|
||||
* </code></pre>
|
||||
* For details on available options see the <a href="http://www.highcharts.com/ref/">Highcharts reference</a>.
|
||||
* <p/>
|
||||
* 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.:
|
||||
* <pre><code>
|
||||
* <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>
|
||||
* </code></pre><pre><code>
|
||||
* <!-- Optionally, add a highcharts theme file -->
|
||||
* <script type="text/javascript" src="js/themes/gray.js"></script>
|
||||
* </code></pre><pre><code>
|
||||
* <!-- Optionally, include the highcharts exporting module -->
|
||||
* <script type="text/javascript" src="js/modules/exporting.js"></script>
|
||||
* </code></pre>
|
||||
* 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.
|
||||
* <p/>
|
||||
* 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
|
||||
* <a href="http://www.highcharts.com/documentation/how-to-use#installation">installation docs</a>
|
||||
* on the Highcharts site for more details.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class StockChart extends BaseChart<StockChart> {
|
||||
|
||||
/**
|
||||
* Create a new Highstock chart instance as a GWT Widget that can then be added to
|
||||
* a GWT layout like any other widget. Note that the various methods that support
|
||||
* setting properties of the chart (e.g. {@link #setType(org.moxieapps.gwt.highcharts.client.Series.Type)},
|
||||
* {@link #setBackgroundColor(String)}, {@link #setOption(String, Object)}, etc.)
|
||||
* then support method chaining, allowing for syntax like the following:
|
||||
* <pre><code>
|
||||
* StockChart chart = new StockChart()
|
||||
* .setChartTitleText("Nice Chart")
|
||||
* .setMarginRight(10);
|
||||
* RootPanel.get().add(chart);
|
||||
* </code></pre>
|
||||
*/
|
||||
public StockChart() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getChartTypeName() {
|
||||
return "StockChart";
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'rangeSelector' chart options. Equivalent to:
|
||||
* <pre><code>
|
||||
* stockChart.setOption("/rangeSelector/selected", 1);
|
||||
* stockChart.setOption("/rangeSelector/inputEnabled", false);
|
||||
* etc...
|
||||
* </code></pre>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+214
@@ -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:
|
||||
* <code><pre>
|
||||
* chart.setStyle(
|
||||
* new Style()
|
||||
* .setOption("fontFamily", "serif")
|
||||
* );
|
||||
* </pre></code>
|
||||
* 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:
|
||||
* <code><pre>
|
||||
* style.setFontFamily("serif");
|
||||
* style.setOption("fontFamily", "serif");
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Style extends Configurable<Style> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "bottom" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("bottom", "10px");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param bottom The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setBottom(String bottom) {
|
||||
return this.setOption("bottom", bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "color" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("color", "#FF0000");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param color The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setColor(String color) {
|
||||
return this.setOption("color", color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "cursor" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("cursor", "pointer");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param cursor The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setCursor(String cursor) {
|
||||
return this.setOption("cursor", cursor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "font" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("font", "normal 13px Verdana, sans-serif");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param font The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setFont(String font) {
|
||||
return this.setOption("font", font);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "fontFamily" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("fontFamily", "serif");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param fontFamily The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setFontFamily(String fontFamily) {
|
||||
return this.setOption("fontFamily", fontFamily);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "fontSize" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("fontSize", "16px");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param fontSize The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setFontSize(String fontSize) {
|
||||
return this.setOption("fontSize", fontSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "fontStyle" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("fontStyle", "italic");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param fontStyle The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setFontStyle(String fontStyle) {
|
||||
return this.setOption("fontStyle", fontStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "fontWeight" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("fontWeight", "bold");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param fontWeight The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setFontWeight(String fontWeight) {
|
||||
return this.setOption("fontWeight", fontWeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "left" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("left", "10px");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param left The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setLeft(String left) {
|
||||
return this.setOption("left", left);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "margin" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("margin", "0px");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param margin The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setMargin(String margin) {
|
||||
return this.setOption("margin", margin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "position" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("position", "absolute");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param position The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setPosition(String position) {
|
||||
return this.setOption("position", position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "right" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("right", "10px");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param right The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setRight(String right) {
|
||||
return this.setOption("right", right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the "top" CSS style option. Equivalent to:
|
||||
* <pre><code>
|
||||
* chart.setOption("top", "10px");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param top The value to use for the CSS style option.
|
||||
* @return A reference to this {@link Style} instance for convenient method chaining.
|
||||
*/
|
||||
public Style setTop(String top) {
|
||||
return this.setOption("top", top);
|
||||
}
|
||||
|
||||
}
|
||||
+296
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* 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.JSONBoolean;
|
||||
|
||||
/**
|
||||
* A configurable class that can be used to represent custom ToolTip options for the
|
||||
* chart, which can then be set on the chart (via the {@link Chart#setToolTip(ToolTip)} method.)
|
||||
* The tooltip appears when the user hovers over a series or point.
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* chart.setToolTip(
|
||||
* new ToolTip()
|
||||
* .setBorderColor("#CC0000")
|
||||
* .setShadow(true)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ToolTip extends Configurable<ToolTip> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'backgroundColor' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("backgroundColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The RGB background color for the tooltip. Defaults to white with a slight opacity.
|
||||
* <p/>
|
||||
* 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)} method.
|
||||
*
|
||||
* @param backgroundColor The RGB background color for the tooltip.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setBackgroundColor(String backgroundColor) {
|
||||
return this.setOption("backgroundColor", backgroundColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'backgroundColor' option for the tool tips to a gradient or color with
|
||||
* an alpha channel . Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("backgroundColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* ));
|
||||
* </code></pre>
|
||||
* The background color for the tooltip (as a gradient or color with an alpha channel). Defaults to "rgba(255, 255, 255, .85)".
|
||||
* <p/>
|
||||
* Note that this method is intended for setting the background to a gradient or color with an alpha
|
||||
* channel. If you instead want to just set the color to a standard RGB hex value use the
|
||||
* {@link #setBackgroundColor(String)} method instead.
|
||||
*
|
||||
* @param backgroundColor The color gradient or color with an alpha channel to set as the 'backgroundColor' option on the tool tip.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setBackgroundColor(Color backgroundColor) {
|
||||
return this.setOption("backgroundColor", backgroundColor != null ? backgroundColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderColor' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("borderColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The color of the tooltip border. When null, the border takes the color of the corresponding series or point.
|
||||
* Defaults to "auto".
|
||||
* <p/>
|
||||
* 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)} method.
|
||||
*
|
||||
* @param borderColor The color of the tooltip border.
|
||||
* @return A borderColor to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setBorderColor(String borderColor) {
|
||||
return this.setOption("borderColor", borderColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderColor' option for the tool tips to a gradient or color with
|
||||
* an alpha channel . Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("borderColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* ));
|
||||
* </code></pre>
|
||||
* The border color for the tooltip (as a gradient or color with an alpha channel). When null, the border
|
||||
* takes the color of the corresponding series or point. Defaults to "auto".
|
||||
* <p/>
|
||||
* Note that this method is intended for setting the border to a gradient or color with an alpha
|
||||
* channel. If you instead want to just set the color to a standard RGB hex value use the
|
||||
* {@link #setBackgroundColor(String)} method instead.
|
||||
*
|
||||
* @param borderColor The color gradient or color with an alpha channel to set as the 'borderColor' option on the tool tip.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setBorderColor(Color borderColor) {
|
||||
return this.setOption("borderColor", borderColor != null ? borderColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderRadius' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("borderRadius", 8);
|
||||
* </code></pre>
|
||||
* The radius of the rounded border corners. Defaults to 5.
|
||||
*
|
||||
* @param borderRadius The radius of the rounded border corners.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setBorderRadius(Number borderRadius) {
|
||||
return this.setOption("borderRadius", borderRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderWidth' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("borderWidth", 3);
|
||||
* </code></pre>
|
||||
* The pixel width of the tooltip border. Defaults to 2.
|
||||
*
|
||||
* @param borderWidth The pixel width of the tooltip border.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setBorderWidth(Number borderWidth) {
|
||||
return this.setOption("borderWidth", borderWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'crosshairs' option for the tool tips for both axis. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("crosshairs", true);
|
||||
* </code></pre>
|
||||
* Display crosshairs to connect the points with their corresponding axis values. Crosshairs are disabled
|
||||
* by default.
|
||||
* <p/>
|
||||
* Note that see the overloaded versions of this method for other ways to control the crosshair configurations.
|
||||
*
|
||||
* @param crosshairs Whether or not to display crosshairs to connect the points with their corresponding axis values.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setCrosshairs(boolean crosshairs) {
|
||||
return this.setOption("crosshairs", crosshairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'crosshairs' option for the tool tips for each axis separately. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("crosshairs", true, true);
|
||||
* </code></pre>
|
||||
* Display crosshairs to connect the points with their corresponding axis values. Crosshairs are disabled
|
||||
* by default.
|
||||
* <p/>
|
||||
* Note that see the overloaded versions of this method for other ways to control the crosshair configurations.
|
||||
*
|
||||
* @param xCrosshairs Whether or not to display the x axis crosshair.
|
||||
* @param yCrosshairs Whether or not to display the y axis crosshair.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setCrosshairs(boolean xCrosshairs, boolean yCrosshairs) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
jsonArray.set(0, JSONBoolean.getInstance(xCrosshairs));
|
||||
jsonArray.set(0, JSONBoolean.getInstance(yCrosshairs));
|
||||
return this.setOption("crosshairs", jsonArray);
|
||||
}
|
||||
|
||||
// TODO: Add crosshairs options for taking an array of objects
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'enabled' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("enabled", false);
|
||||
* </code></pre>
|
||||
* Enable or disable the tool tips. Defaults to true.
|
||||
*
|
||||
* @param enabled Whether or not to enable or disable the tool tips.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setEnabled(boolean enabled) {
|
||||
return this.setOption("enabled", enabled);
|
||||
}
|
||||
|
||||
private ToolTipFormatter toolTipFormatter;
|
||||
|
||||
/**
|
||||
* Sets a custom formatter on the tooltip that can be used to control the contents and styling
|
||||
* of the text that appears in the tooltip. See the {@link ToolTipFormatter} interface, and
|
||||
* in particular the {@link ToolTipFormatter#format(ToolTipData)} method for more details on
|
||||
* the capabilities available to custom formatters.
|
||||
*
|
||||
* @param toolTipFormatter The custom formatter to use for the tooltips (if not given a built-in
|
||||
* generic formatter is used when tooltips are enabled).
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setFormatter(ToolTipFormatter toolTipFormatter) {
|
||||
this.toolTipFormatter = toolTipFormatter;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Purposefully restricted to package scope
|
||||
ToolTipFormatter getToolTipFormatter() {
|
||||
return this.toolTipFormatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'shadow' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("shadow", false);
|
||||
* </code></pre>
|
||||
* Whether to apply a drop shadow to the tooltip. Defaults to true.
|
||||
*
|
||||
* @param shadow Whether to apply a drop shadow to the tooltip.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setShadow(boolean shadow) {
|
||||
return this.setOption("shadow", shadow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'shared' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("shared", true);
|
||||
* </code></pre>
|
||||
* When the tooltip is shared, the entire plot area will capture mouse movement, and tooltip
|
||||
* texts for all series will be shown in a single bubble. This is recommended for single series
|
||||
* charts and for iPad optimized sites. Defaults to false.
|
||||
*
|
||||
* @param shared Whether or not to shared the same tool tip between points.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setShared(boolean shared) {
|
||||
return this.setOption("shared", shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'snap' option for the tool tips. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("snap", 40);
|
||||
* </code></pre>
|
||||
* Proximity snap for graphs or single points. Does not apply to bars, columns and pie slices.
|
||||
* It defaults to 10 for mouse-powered devices and 25 for touch devices.
|
||||
*
|
||||
* @param snap The proximity snap for graphs or single points.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setSnap(Number snap) {
|
||||
return this.setOption("snap", snap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'style' options of the tooltip. Equivalent to:
|
||||
* <pre><code>
|
||||
* toolTip.setOption("/style/fontWeight", "bold");
|
||||
* toolTip.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for the tooltip. The tooltip can also be styled through the CSS
|
||||
* class ".highcharts-tooltip". Default value:
|
||||
* <ul>
|
||||
* <li>color: '#333333'</li>
|
||||
* <li>fontSize: '9pt'</li>
|
||||
* <li>padding: '5px'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param style CSS styles for the tooltip.
|
||||
* @return A reference to this {@link ToolTip} instance for convenient method chaining.
|
||||
*/
|
||||
public ToolTip setStyle(Style style) {
|
||||
return this.setOption("style", style != null ? style.getOptions() : null);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+361
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* An object that represents the state information that will be passed to any custom
|
||||
* {@link ToolTipFormatter} to allow for custom strings to be included within the tooltip area.
|
||||
* See the {@link ToolTipFormatter#format(ToolTipData)} method for more details on the capabilities
|
||||
* that custom formatters can provide.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ToolTipData {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private JavaScriptObject data;
|
||||
|
||||
// Purposefully restricted to package scope
|
||||
ToolTipData(JavaScriptObject data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the percentage value of the point (which represents the point's percentage
|
||||
* of the total). Stacked series and pies only.
|
||||
*
|
||||
* @return The percentage value of the point.
|
||||
*/
|
||||
public native double getPercentage() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.percentage;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the percentage value of the point at a given index (for shared tooltips), which
|
||||
* represents the point's percentage of the total. Stacked series and pies only.
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve.
|
||||
* @return The percentage value of the point at the given index.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native double getPercentage(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].percentage;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Retrieve the unique id of the series that the point is a part of. This id can then be used
|
||||
* to obtain the Series instance itself via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.BaseChart#getSeries(String)} method.
|
||||
*
|
||||
* @return The unique id of the series that the event was triggered on.
|
||||
*/
|
||||
public native String getSeriesId() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.series.options.id;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Retrieve the unique id of the series that a point at the given index (for shared tooltips)
|
||||
* is a part of. This id can then be used to obtain the Series instance itself via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.BaseChart#getSeries(String)} method.
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the series from.
|
||||
* @return The unique id of the series that the event was triggered on for the given indexed point.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native String getSeriesId(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].series.options.id;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the series that the point is a part of.
|
||||
*
|
||||
* @return The name of the series that the point is a part of
|
||||
*/
|
||||
public native String getSeriesName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.series.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the series that the point at a given index (for shared tooltips) is a part of.
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the series from.
|
||||
* @return The name of the series that the point at the given index is a part of
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native String getSeriesName(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].series.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Create a new GWT point instance that is connected to the Highcharts JS point instance associated
|
||||
* with this tooltip.
|
||||
*
|
||||
* @return A Point instance that is connected to the Highcharts data point associated with the tooltip.
|
||||
*/
|
||||
public Point getPoint() {
|
||||
return new Point(getNativePoint());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new GWT point instance that is connected to the Highcharts JS point instance at a
|
||||
* given index (for shared tooltips) associated with this tooltip.
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve.
|
||||
* @return A Point instance that is connected to the Highcharts data point associated with the tooltip.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public Point getPoint(int index) {
|
||||
JsArray<JavaScriptObject> nativePoints = getNativePoints();
|
||||
return new Point(nativePoints.get(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new GWT point instance for each values in the array of values provided that are
|
||||
* connected to the Highcharts JS point instances associated with this tooltip (shared tooltips only).
|
||||
* Note that if you simply need to iterate over the data points to retrieve the values for
|
||||
* rendering the tooltip, it's more efficient to use the {@link #getPointsLength()} method instead.
|
||||
*
|
||||
* @return A Point instance that is connected to the Highcharts data point associated with the tooltip.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public Point[] getPoints() {
|
||||
JsArray<JavaScriptObject> nativePoints = getNativePoints();
|
||||
Point[] points = new Point[nativePoints.length()];
|
||||
for (int i = 0; i < nativePoints.length(); i++) {
|
||||
points[i] = new Point(nativePoints.get(i));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* For shared tool tips only, returns the number of points that are available in the collection
|
||||
* of data points that were passed to the tooltip (which should reflect the number of series
|
||||
* in the chart.)
|
||||
*
|
||||
* @return The number of points available as data to the tool tip
|
||||
*/
|
||||
public int getPointsLength() {
|
||||
return getNativePoints().length();
|
||||
}
|
||||
|
||||
private native JavaScriptObject getNativePoint() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.point;
|
||||
}-*/;
|
||||
|
||||
private native JsArray<JavaScriptObject> getNativePoints() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the point (e.g. "point.name").
|
||||
*
|
||||
* @return The name of the point that the tooltip is over.
|
||||
*/
|
||||
public native String getPointName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.point.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the point (e.g. "point[i].name") at the given index (for shared tooltips).
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the name from.
|
||||
* @return The name of the point at the given index that the tooltip is over.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native String getPointName(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.point[index].name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the total value at this point's x value. Stacked series only.
|
||||
*
|
||||
* @return The total value at this point's x value (only applicable in stacked series).
|
||||
*/
|
||||
public native double getTotal() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.total;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the total value at a point at a given index's x value (for shared tooltips). Stacked series only.
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the value from.
|
||||
* @return The total value at the given indexed point's x value (only applicable in stacked series).
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native double getTotal(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].total;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the total value at this point's x value as a long. Stacked series only.
|
||||
*
|
||||
* @return Return the total value at this point's x value as a long.
|
||||
*/
|
||||
public long getTotalAsLong() {
|
||||
return ((Double) getTotal()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total value at a point at a given index's x value as a long (for shared tooltips).
|
||||
* Stacked series only.
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the value from.
|
||||
* @return Return the total value at the given indexed point's x value as a long.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public long getTotalAsLong(int index) {
|
||||
return ((Double) getTotal(index)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the point as a double.
|
||||
*/
|
||||
public native double getXAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the point at the given index as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number. (For shared tool tips.)
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the value from.
|
||||
* @return The x value of the point at the given index as a double.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native double getXAsDouble(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the point as a long.
|
||||
*/
|
||||
public long getXAsLong() {
|
||||
return ((Double) getXAsDouble()).longValue();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Return the x value of the point at the given index as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number. (For shared tool tips.)
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the value from.
|
||||
* @return The x value of the point at the given index as a long.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public long getXAsLong(int index) {
|
||||
return ((Double) getXAsDouble(index)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The x value of the point as a string.
|
||||
*/
|
||||
public native String getXAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the point at the given index as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string. (For shared tool tips.)
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve the value from.
|
||||
* @return The x value of the point at the given index as a string.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native String getXAsString(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the point as a double.
|
||||
*/
|
||||
public native double getYAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.y;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a double given the index of a specific
|
||||
* point to retrieve (shared tooltips only). An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve.
|
||||
* @return The y value of the point as a double.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native double getYAsDouble(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].y;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the point as a long.
|
||||
*/
|
||||
public long getYAsLong() {
|
||||
return ((Double) getYAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the y value of the point at a given index as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number. (For shared tooltips only.)
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve.
|
||||
* @return The y value of the point as a long.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public long getYAsLong(int index) {
|
||||
return ((Double) getYAsDouble(index)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The y value of the point as a string.
|
||||
*/
|
||||
public native String getYAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.y;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point at a given index as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string. (For shared tooltips only.)
|
||||
*
|
||||
* @param index The index of the point in the array to retrieve.
|
||||
* @return The y value of the point at the given index as a string.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native String getYAsString(int index) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.ToolTipData::data.points[index].y;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
Executable
+103
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* An interface that can be used to control the information of the tooltip area to contain
|
||||
* custom text or formatting. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setToolTip(
|
||||
* new ToolTip()
|
||||
* .setToolTipFormatter(new ToolTipFormatter() {
|
||||
* public String format(ToolTipData toolTipData) {
|
||||
* return toolTipData.getXAsLong() + " degrees";
|
||||
* }
|
||||
* })
|
||||
* );
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link #format(ToolTipData)} function for more details on the
|
||||
* capabilities available within custom formatters.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface ToolTipFormatter {
|
||||
|
||||
/**
|
||||
* Callback function to format the text of the tooltip. Return null to disable tooltip for a specific
|
||||
* point on series.
|
||||
* <p/>
|
||||
* A subset of HTML is supported. The HTML of the tooltip is parsed and converted to SVG, therefore
|
||||
* this isn't a complete HTML renderer. The following tags are supported: <b>, <strong>, <i>,
|
||||
* <em>, <br/>, and <span>. Spans can be styled with a style attribute, but only text-related
|
||||
* CSS that is shared with SVG is handled.
|
||||
* <p/>
|
||||
* Since version 2.1 the tooltip can be shared between multiple series through the
|
||||
* {@link ToolTip#setShared(boolean)} option. The available data in the formatter differ a bit depending
|
||||
* on whether the tooltip is shared or not. In a shared tooltip, all properties except x, which is common
|
||||
* for all points, are kept in an array, this.points.
|
||||
* <p/>
|
||||
* Available data provided in the given "ToolTipData" object are:
|
||||
* <ul>
|
||||
* <li>
|
||||
* <b>percentage</b> (not shared) or <b>points[i].percentage</b> (shared) :
|
||||
* Stacked series and pies only. The point's percentage of the total.
|
||||
* </li>
|
||||
* <!--
|
||||
* <li>
|
||||
* <b>point</b> (not shared) or <b>points[i].point</b> (shared) :
|
||||
* The point object. The point name, if defined, is available through {@link Point#getName()}.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>points</b> :
|
||||
* In a shared tooltip, this is an array containing all other properties for each point.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>series</b> (not shared) or <b>points[i].series</b> (shared) :
|
||||
* The series object. The series name is available through this.series.name.
|
||||
* </li>
|
||||
* -->
|
||||
* <li>
|
||||
* <b>point.name</b> (not shared) or <b>points[i].point.name</b> (shared) :
|
||||
* The "name" property of the point object that hte tooltip is hovering over.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>series.name</b> (not shared) or <b>points[i].series.name</b> (shared) :
|
||||
* The name of the series that the point is a part of.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>total</b> (not shared) or <b>points[i].total</b> (shared) :
|
||||
* Stacked series only. The total value at this point's x value.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>x</b> :
|
||||
* The x value. This property is the same regardless of the tooltip being shared or not.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>y</b> (not shared) or <b>points[i].y</b> (shared) :
|
||||
* The y value.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param toolTipData An object containing all of the data available to the formatter that it can
|
||||
* use to determine which text and styling to use in the tooltip.
|
||||
* @return The text to include in the tooltip (including any styling), or null to disable the tooltip
|
||||
* for the data point.
|
||||
*/
|
||||
public String format(ToolTipData toolTipData);
|
||||
|
||||
}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* 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.JsArrayNumber;
|
||||
import com.google.gwt.core.client.JsArrayString;
|
||||
import com.google.gwt.json.client.JSONArray;
|
||||
import org.moxieapps.gwt.highcharts.client.labels.XAxisLabels;
|
||||
|
||||
/**
|
||||
* Provides access to an object that can abe used to configure and manage the x-axis of the chart.
|
||||
* Note that you can not instance an instance of this object directly, and instead should use the
|
||||
* {@link Chart#getXAxis()} method to gain a reference to this
|
||||
* object. Example usage:
|
||||
* <pre><code>
|
||||
* XAxis xAxis = chart.getXAxis()
|
||||
* .setType(Axis.Type.DATE_TIME)
|
||||
* .setStartOfWeek(Axis.WeekDay.SUNDAY)
|
||||
* .setAxisTitleText("Year")
|
||||
* .setAlternateGridColor("#CCCCCC");
|
||||
* </code></pre>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class XAxis extends Axis<XAxis> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported tickmark placements for when categories are in use, which can be passed to
|
||||
* the {@link XAxis#setTickmarkPlacement(XAxis.TickmarkPlacement)} method.
|
||||
*/
|
||||
public enum TickmarkPlacement {
|
||||
|
||||
/**
|
||||
* Display the tick marks in the center of the category.
|
||||
*/
|
||||
ON("on"),
|
||||
|
||||
/**
|
||||
* Display the tick marks between categories.
|
||||
*/
|
||||
BETWEEN("between");
|
||||
|
||||
private TickmarkPlacement(String optionValue) {
|
||||
this.optionvalue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionvalue;
|
||||
|
||||
public String toString() {
|
||||
return optionvalue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the {@link Chart#getXAxis()} method to get access to the XAxis of the chart.
|
||||
*
|
||||
* @param chart The chart instance that this axis is being created within.
|
||||
*/
|
||||
XAxis(BaseChart chart) {
|
||||
super(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets category names to use for the xAxis (instead of using numbers). If categories are present for the
|
||||
* xAxis, names are used instead of numbers for that axis. Example: setCategories("Apples", "Bananas", "Oranges").
|
||||
* Defaults to an empty array, which will use numbers for the categories instead of names when categories
|
||||
* are present.
|
||||
* <p/>
|
||||
* Note that this method will automatically redraw the categories on the chart if invoked after the
|
||||
* chart has been rendered. For more control over when the categories are redrawn, you can utilize
|
||||
* the {@link #setCategories(boolean, String...)} method instead.
|
||||
*
|
||||
* @param categories An array of category names to use for the axis.
|
||||
* @return A reference to this {@link XAxis} instance for convenient method chaining.
|
||||
*/
|
||||
public XAxis setCategories(String... categories) {
|
||||
return this.setCategories(true, categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets category names to use for the xAxis (instead of using numbers), explicitly controlling whether
|
||||
* or not the axis will be redrawn in the case that the chart has already been rendered to the DOM.
|
||||
* If categories are present for the xAxis, names are used instead of numbers for that axis.
|
||||
* Example: setCategories("Apples", "Bananas", "Oranges"). Defaults to an empty array, which will
|
||||
* use numbers for the categories instead of names when categories are present.
|
||||
* <p/>
|
||||
*
|
||||
* @param redraw Whether to redraw the axis or wait for an explicit call to {@link org.moxieapps.gwt.highcharts.client.BaseChart#redraw()}
|
||||
* @param categories An array of category names to use for the axis.
|
||||
* @return A reference to this {@link XAxis} instance for convenient method chaining.
|
||||
* @since 1.1.1
|
||||
*/
|
||||
public XAxis setCategories(boolean redraw, String... categories) {
|
||||
final JavaScriptObject nativeAxis = getNativeAxis();
|
||||
if (nativeAxis != null) {
|
||||
JsArrayString jsArray = JavaScriptObject.createArray().<JsArrayString>cast();
|
||||
for (int i = 0; i < categories.length; i++) {
|
||||
String category = categories[i];
|
||||
jsArray.set(i, category);
|
||||
}
|
||||
nativeSetCategories(nativeAxis, jsArray, redraw);
|
||||
return this;
|
||||
} else {
|
||||
return this.setOption("categories", categories);
|
||||
}
|
||||
}
|
||||
|
||||
private XAxisLabels xAxisLabels;
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'labels' options of the axis. Equivalent to code like:
|
||||
* <pre><code>
|
||||
* axis.setOption("/labels/align", Labels.Align.LEFT);
|
||||
* axis.setOption("/labels/enabled", true);
|
||||
* etc...
|
||||
* </code></pre>
|
||||
* Configuration object for the axis labels, usually displaying the number for each tick.
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* axis.setLabels(
|
||||
* new XAxisLabels()
|
||||
* .setAlign(Labels.Align.LEFT)
|
||||
* .setEnabled(true)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @param labels The configuration object for the axis labels, or null to use the defaults.
|
||||
* @return A reference to this {@link XAxis} instance for convenient method chaining.
|
||||
*/
|
||||
public XAxis setLabels(XAxisLabels labels) {
|
||||
this.xAxisLabels = labels;
|
||||
return this.setOption("labels", labels != null ? labels.getOptions() : null);
|
||||
}
|
||||
|
||||
// Purposefully restricted to package scope
|
||||
XAxisLabels getLabels() {
|
||||
return xAxisLabels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'tickmarkPlacement' option for the axis. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("tickmarkPlacement", TickmarkPlacement.ON);
|
||||
* </code></pre>
|
||||
* For categorized axes only. If {@link XAxis.TickmarkPlacement#ON} the tick mark is placed in the center of the category,
|
||||
* if {@link XAxis.TickmarkPlacement#BETWEEN} the tick mark is placed between categories. Defaults to {@link XAxis.TickmarkPlacement#BETWEEN}.
|
||||
*
|
||||
* @param tickmarkPlacement Whether or not to place the tickmark in the center or between categories.
|
||||
* @return A reference to this {@link Axis} instance for convenient method chaining.
|
||||
*/
|
||||
public XAxis setTickmarkPlacement(TickmarkPlacement tickmarkPlacement) {
|
||||
return this.setOption("tickmarkPlacement", tickmarkPlacement != null ? tickmarkPlacement.toString() : null);
|
||||
}
|
||||
|
||||
private static native void nativeSetCategories(JavaScriptObject nativeAxis, JsArrayString categories, boolean redraw) /*-{
|
||||
return nativeAxis.setCategories(categories, redraw);
|
||||
}-*/;
|
||||
|
||||
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 org.moxieapps.gwt.highcharts.client.labels.StackLabels;
|
||||
import org.moxieapps.gwt.highcharts.client.labels.YAxisLabels;
|
||||
|
||||
/**
|
||||
* Provides access to an object that can abe used to configure and manage the y-axis of the chart.
|
||||
* Note that you can not instance an instance of this object directly, and instead should use the
|
||||
* {@link Chart#getYAxis()} method to gain a reference to this
|
||||
* object. Example usage:
|
||||
* <pre><code>
|
||||
* chart.getYAxis()
|
||||
* .setType(Axis.Type.LINEAR)
|
||||
* .setAxisTitleText("Sales")
|
||||
* .setLineWidth(3);
|
||||
* </code></pre>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class YAxis extends Axis<YAxis> {
|
||||
|
||||
/**
|
||||
* Use the {@link Chart#getYAxis()} method to get access to the YAxis of the chart.
|
||||
*
|
||||
* @param chart The chart instance that this axis is being created within.
|
||||
*/
|
||||
YAxis(BaseChart chart) {
|
||||
super(chart);
|
||||
}
|
||||
|
||||
private YAxisLabels yAxisLabels;
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'labels' options of the axis. Equivalent to code like:
|
||||
* <pre><code>
|
||||
* axis.setOption("/labels/align", Labels.Align.LEFT);
|
||||
* axis.setOption("/labels/enabled", true);
|
||||
* etc...
|
||||
* </code></pre>
|
||||
* Configuration object for the axis labels, usually displaying the number for each tick.
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* axis.setLabels(
|
||||
* new XAxisLabels()
|
||||
* .setAlign(Labels.Align.LEFT)
|
||||
* .setEnabled(true)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @param labels The configuration object for the axis labels, or null to use the defaults.
|
||||
* @return A reference to this {@link YAxis} instance for convenient method chaining.
|
||||
*/
|
||||
public YAxis setLabels(YAxisLabels labels) {
|
||||
this.yAxisLabels = labels;
|
||||
return this.setOption("labels", labels != null ? labels.getOptions() : null);
|
||||
}
|
||||
|
||||
// Purposefully restricted to package scope
|
||||
YAxisLabels getLabels() {
|
||||
return yAxisLabels;
|
||||
}
|
||||
|
||||
private StackLabels stackLabels;
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'stackLabels' options of the axis. Equivalent to code like:
|
||||
* <pre><code>
|
||||
* axis.setOption("/stackLabels/align", Labels.Align.LEFT);
|
||||
* axis.setOption("/stackLabels/enabled", true);
|
||||
* etc...
|
||||
* </code></pre>
|
||||
* The stack labels show the total value for each bar in a stacked column or bar chart. The label
|
||||
* will be placed on top of positive columns and below negative columns. In case of an inverted
|
||||
* column chart or a bar chart the label is placed to the right of positive bars and to the left
|
||||
* of negative bars.
|
||||
* <p/>
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* axis.setStackLabels(
|
||||
* new StackLabels()
|
||||
* .setAlign(Labels.Align.LEFT)
|
||||
* .setEnabled(true)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @param stackLabels The configuration object for the axis stack labels, or null to use the defaults.
|
||||
* @return A reference to this {@link YAxis} instance for convenient method chaining.
|
||||
*/
|
||||
public YAxis setStackLabels(StackLabels stackLabels) {
|
||||
this.stackLabels = stackLabels;
|
||||
return this.setOption("stackLabels", stackLabels != null ? stackLabels.getOptions() : null);
|
||||
}
|
||||
|
||||
// Purposefully restricted to package scope
|
||||
StackLabels getStackLabels() {
|
||||
return stackLabels;
|
||||
}
|
||||
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user clicks on the
|
||||
* plot area of the chart, including the axis values of the click. This class should
|
||||
* not be instantiated directly, but instead you should create a {@link ChartClickEventHandler} and
|
||||
* register it via the {@link org.moxieapps.gwt.highcharts.client.BaseChart#setClickEventHandler(ChartClickEventHandler)}
|
||||
* method in order to access click events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class ChartClickEvent extends MouseEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create click events
|
||||
* directly, but instead should register a {@link ChartClickEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
*/
|
||||
public ChartClickEvent(JavaScriptObject event) {
|
||||
super(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the first X axis at the click event location. See the
|
||||
* {@link #getXAxisValue(int)} method if you need the value of a different X axis.
|
||||
*
|
||||
* @return The value of the first X axis at the click event location.
|
||||
*/
|
||||
public double getXAxisValue() {
|
||||
return getXAxisValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the first X axis at the click event location, converting the
|
||||
* value to a long value first. See the {@link #getXAxisValueAsLong(int)} method
|
||||
* if you need the value of a different X axis, or the {@link #getXAxisValue()}
|
||||
* method if you need a floating point value instead.
|
||||
*
|
||||
* @return The value of the first X axis at the click event location, as a long.
|
||||
*/
|
||||
public long getXAxisValueAsLong() {
|
||||
return ((Double) getXAxisValue()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the requested X axis at the click event location. Will
|
||||
* throw an exception if the given axis index is invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the X axis for which you'd like
|
||||
* to retrieve the value of the click event.
|
||||
* @return The value of the requested X axis at the click event location.
|
||||
*/
|
||||
public native double getXAxisValue(int axisIndex) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.xAxis[axisIndex].value;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the value of the requested X axis at the click event location, converting
|
||||
* the value to a long before returning it. Will throw an exception if the given axis
|
||||
* index is invalid. See the {@link #getXAxisValue(int)} method if you need the value
|
||||
* as a floating point number instead.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the X axis for which you'd like
|
||||
* to retrieve the value of the click event.
|
||||
* @return The value of the requested X axis at the click event location, as a long.
|
||||
*/
|
||||
public long getXAxisValueAsLong(int axisIndex) {
|
||||
return ((Double) getXAxisValue(axisIndex)).longValue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the value of the first Y axis at the click event location. See the
|
||||
* {@link #getYAxisValue(int)} method if you need the value of a different Y axis.
|
||||
*
|
||||
* @return The value of the first Y axis at the click event location.
|
||||
*/
|
||||
public double getYAxisValue() {
|
||||
return getYAxisValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the first Y axis at the click event location, converting the
|
||||
* value to a long value first. See the {@link #getYAxisValueAsLong(int)} method
|
||||
* if you need the value of a different Y axis, or the {@link #getYAxisValue()}
|
||||
* method if you need a floating point value instead.
|
||||
*
|
||||
* @return The value of the first Y axis at the click event location, as a long.
|
||||
*/
|
||||
public long getYAxisValueAsLong() {
|
||||
return ((Double) getYAxisValue()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the requested Y axis at the click event location. Will
|
||||
* throw an exception if the given axis index is invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the Y axis for which you'd like
|
||||
* to retrieve the value of the click event.
|
||||
* @return The value of the requested Y axis at the click event location.
|
||||
*/
|
||||
public native double getYAxisValue(int axisIndex) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.yAxis[axisIndex].value;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the value of the requested Y axis at the click event location, converting
|
||||
* the value to a long before returning it. Will throw an exception if the given axis
|
||||
* index is invalid. See the {@link #getYAxisValue(int)} method if you need the value
|
||||
* as a floating point number instead.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the Y axis for which you'd like
|
||||
* to retrieve the value of the click event.
|
||||
* @return The value of the requested Y axis at the click event location, as a long.
|
||||
*/
|
||||
public long getYAxisValueAsLong(int axisIndex) {
|
||||
return ((Double) getYAxisValue(axisIndex)).longValue();
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when click events are fired anywhere on the
|
||||
* plot area of the chart. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setClickEventHandler(new ChartClickEventHandler() {
|
||||
* public boolean onClick(ChartClickEvent clickEvent) {
|
||||
* Window.alert("User clicked at " + clickEvent.getXAxisValue() + ", " + clickEvent.getYAxisValue());
|
||||
* return true;
|
||||
* }
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link ChartClickEvent} class for more details on the data
|
||||
* available when a click event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface ChartClickEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a click event occurs on the plot area of the chart. See
|
||||
* the {@link ChartClickEvent} class for more details on the data available when this event is fired.
|
||||
*
|
||||
* @param chartClickEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onClick(ChartClickEvent chartClickEvent);
|
||||
|
||||
}
|
||||
java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/events/ChartLoadEvent.java
Executable
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a load event occurs.
|
||||
* This class is really provided for symmetry and future proofing the API, as in the current
|
||||
* version no information is provided on load events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class ChartLoadEvent {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private JavaScriptObject event;
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create load events
|
||||
* directly, but instead should register a {@link ChartLoadEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
*/
|
||||
public ChartLoadEvent(JavaScriptObject event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler whenever the core chart's "load" event is fired.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setLoadEventHandler(new ChartLoadEventHandler() {
|
||||
* public boolean onLoad(ChartLoadEvent loadEvent) {
|
||||
* Window.alert("The chart has been loaded");
|
||||
* return true;
|
||||
* }
|
||||
* });
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface ChartLoadEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever the chart's load event occurs.
|
||||
*
|
||||
* @param chartLoadEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onLoad(ChartLoadEvent chartLoadEvent);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a chart redraw event occurs.
|
||||
* This class is really provided for symmetry and future proofing the API, as in the current
|
||||
* version no information is provided on redraw events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class ChartRedrawEvent {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private JavaScriptObject event;
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create redraw events
|
||||
* directly, but instead should register a {@link ChartRedrawEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
*/
|
||||
public ChartRedrawEvent(JavaScriptObject event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler whenever the core chart's "redraw" event is fired.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setRedrawEventHandler(new ChartRedrawEventHandler() {
|
||||
* public boolean onRedraw(ChartRedrawEvent redrawEvent) {
|
||||
* Window.alert("The chart has been redrawn");
|
||||
* return true;
|
||||
* }
|
||||
* });
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface ChartRedrawEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever the chart's redraw event occurs.
|
||||
*
|
||||
* @param chartRedrawEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onRedraw(ChartRedrawEvent chartRedrawEvent);
|
||||
|
||||
}
|
||||
+230
@@ -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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user selects a portion
|
||||
* of the chart, including the axis values of the selection. This class should
|
||||
* not be instantiated directly, but instead you should create a {@link ChartSelectionEventHandler} and
|
||||
* register it via the {@link org.moxieapps.gwt.highcharts.client.BaseChart#setSelectionEventHandler(ChartSelectionEventHandler)}
|
||||
* method in order to access selection events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class ChartSelectionEvent extends MouseEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create selection events
|
||||
* directly, but instead should register a {@link ChartSelectionEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
*/
|
||||
public ChartSelectionEvent(JavaScriptObject event) {
|
||||
super(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range of the first X axis. See the
|
||||
* {@link #getXAxisMin(int)} method if you need the value of a different X axis.
|
||||
*
|
||||
* @return The minimum value of the selected range on the first X axis.
|
||||
*/
|
||||
public double getXAxisMin() {
|
||||
return getXAxisMin(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range of the first X axis, converting the
|
||||
* value to a long value first. See the {@link #getXAxisMinAsLong(int)} method
|
||||
* if you need the value of a different X axis, or the {@link #getXAxisMin()}
|
||||
* method if you need a floating point value instead.
|
||||
*
|
||||
* @return The minimum value of the selected range on the first X axis, as a long.
|
||||
*/
|
||||
public long getXAxisMinAsLong() {
|
||||
return ((Double)getXAxisMin()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range on the requested X axis. Will
|
||||
* throw an exception if the given axis index is invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the X axis for which you'd like
|
||||
* to retrieve the minimum value of the selection event.
|
||||
* @return The minimum value of the selection range on the requested X axis.
|
||||
*/
|
||||
public native double getXAxisMin(int axisIndex) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.xAxis[axisIndex].min;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range on the requested X axis, converting
|
||||
* the value to a long value first. Will throw an exception if the given axis index is
|
||||
* invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the X axis for which you'd like
|
||||
* to retrieve the minimum value of the selection event.
|
||||
* @return The minimum value of the selection range on the requested X axis, as a long.
|
||||
*/
|
||||
public long getXAxisMinAsLong(int axisIndex) {
|
||||
return ((Double)getXAxisMin(axisIndex)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range of the first X axis. See the
|
||||
* {@link #getXAxisMax(int)} method if you need the value of a different X axis.
|
||||
*
|
||||
* @return The maximum value of the selected range on the first X axis.
|
||||
*/
|
||||
public double getXAxisMax() {
|
||||
return getXAxisMax(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range of the first X axis, converting the
|
||||
* value to a long value first. See the {@link #getXAxisMaxAsLong(int)} method
|
||||
* if you need the value of a different X axis, or the {@link #getXAxisMax()}
|
||||
* method if you need a floating point value instead.
|
||||
*
|
||||
* @return The maximum value of the selected range on the first X axis, as a long.
|
||||
*/
|
||||
public long getXAxisMaxAsLong() {
|
||||
return ((Double)getXAxisMax()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range on the requested X axis. Will
|
||||
* throw an exception if the given axis index is invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the X axis for which you'd like
|
||||
* to retrieve the maximum value of the selection event.
|
||||
* @return The maximum value of the selection range on the requested X axis.
|
||||
*/
|
||||
public native double getXAxisMax(int axisIndex) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.xAxis[axisIndex].max;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range on the requested X axis, converting
|
||||
* the value to a long value first. Will throw an exception if the given axis index is
|
||||
* invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the X axis for which you'd like
|
||||
* to retrieve the maximum value of the selection event.
|
||||
* @return The maximum value of the selection range on the requested X axis, as a long.
|
||||
*/
|
||||
public long getXAxisMaxAsLong(int axisIndex) {
|
||||
return ((Double)getXAxisMax(axisIndex)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range of the first Y axis. See the
|
||||
* {@link #getYAxisMin(int)} method if you need the value of a different Y axis.
|
||||
*
|
||||
* @return The minimum value of the selected range on the first Y axis.
|
||||
*/
|
||||
public double getYAxisMin() {
|
||||
return getYAxisMin(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range of the first Y axis, converting the
|
||||
* value to a long value first. See the {@link #getYAxisMinAsLong(int)} method
|
||||
* if you need the value of a different Y axis, or the {@link #getYAxisMin()}
|
||||
* method if you need a floating point value instead.
|
||||
*
|
||||
* @return The minimum value of the selected range on the first Y axis, as a long.
|
||||
*/
|
||||
public long getYAxisMinAsLong() {
|
||||
return ((Double)getYAxisMin()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range on the requested Y axis. Will
|
||||
* throw an exception if the given axis index is invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the Y axis for which you'd like
|
||||
* to retrieve the minimum value of the selection event.
|
||||
* @return The minimum value of the selection range on the requested Y axis.
|
||||
*/
|
||||
public native double getYAxisMin(int axisIndex) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.yAxis[axisIndex].min;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the minimum value of the selection range on the requested Y axis, converting
|
||||
* the value to a long value first. Will throw an exception if the given axis index is
|
||||
* invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the Y axis for which you'd like
|
||||
* to retrieve the minimum value of the selection event.
|
||||
* @return The minimum value of the selection range on the requested Y axis, as a long.
|
||||
*/
|
||||
public long getYAxisMinAsLong(int axisIndex) {
|
||||
return ((Double)getYAxisMin(axisIndex)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range of the first Y axis. See the
|
||||
* {@link #getYAxisMax(int)} method if you need the value of a different Y axis.
|
||||
*
|
||||
* @return The maximum value of the selected range on the first Y axis.
|
||||
*/
|
||||
public double getYAxisMax() {
|
||||
return getYAxisMax(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range of the first Y axis, converting the
|
||||
* value to a long value first. See the {@link #getYAxisMaxAsLong(int)} method
|
||||
* if you need the value of a different Y axis, or the {@link #getYAxisMax()}
|
||||
* method if you need a floating point value instead.
|
||||
*
|
||||
* @return The maximum value of the selected range on the first Y axis, as a long.
|
||||
*/
|
||||
public long getYAxisMaxAsLong() {
|
||||
return ((Double)getYAxisMax()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range on the requested Y axis. Will
|
||||
* throw an exception if the given axis index is invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the Y axis for which you'd like
|
||||
* to retrieve the maximum value of the selection event.
|
||||
* @return The maximum value of the selection range on the requested Y axis.
|
||||
*/
|
||||
public native double getYAxisMax(int axisIndex) /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.yAxis[axisIndex].max;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the maximum value of the selection range on the requested Y axis, converting
|
||||
* the value to a long value first. Will throw an exception if the given axis index is
|
||||
* invalid.
|
||||
*
|
||||
* @param axisIndex The index (zero based) of the Y axis for which you'd like
|
||||
* to retrieve the maximum value of the selection event.
|
||||
* @return The maximum value of the selection range on the requested Y axis, as a long.
|
||||
*/
|
||||
public long getYAxisMaxAsLong(int axisIndex) {
|
||||
return ((Double)getYAxisMax(axisIndex)).longValue();
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when selection events are fired by the chart.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSelectionEventHandler(new ChartSelectionEventHandler() {
|
||||
* public boolean onSelection(ChartSelectionEvent selectionEvent) {
|
||||
* Window.alert("User selected from " + selectionEvent.getXAxisMin() + " to " + selectionEvent.getXAxisMax());
|
||||
* return true;
|
||||
* }
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link ChartSelectionEvent} class for more details on the data
|
||||
* available when a selection event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface ChartSelectionEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a selection event occurs on the plot area of the chart. See
|
||||
* the {@link ChartSelectionEvent} class for more details on the data available when this event is fired.
|
||||
*
|
||||
* @param chartSelectionEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onSelection(ChartSelectionEvent chartSelectionEvent);
|
||||
|
||||
}
|
||||
Executable
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
|
||||
/**
|
||||
* The base class of all events that are triggered by the user's mouse, and includes methods for accessing the general
|
||||
* state of the event, such as if the user was holding down the "Shift" or "Control" key,
|
||||
* or the x/y coordinates of the click.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public abstract class MouseEvent {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private JavaScriptObject event;
|
||||
|
||||
/**
|
||||
* We can only be created by instantiating one of our sub classes.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
*/
|
||||
protected MouseEvent(JavaScriptObject event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mouse x-position within the browser window's client area.
|
||||
*
|
||||
* @return the mouse x-position
|
||||
*/
|
||||
public native int getClientX() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.clientX || 0;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Gets the mouse y-position within the browser window's client area.
|
||||
*
|
||||
* @return the mouse y-position
|
||||
*/
|
||||
public native int getClientY() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.clientY || 0;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Gets the button value. Compare it to
|
||||
* {@link com.google.gwt.dom.client.NativeEvent#BUTTON_LEFT},
|
||||
* {@link com.google.gwt.dom.client.NativeEvent#BUTTON_RIGHT},
|
||||
* {@link com.google.gwt.dom.client.NativeEvent#BUTTON_MIDDLE}
|
||||
*
|
||||
* @return the button value
|
||||
*/
|
||||
public native int getNativeButton() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.button || 0;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Gets the mouse x-position relative to a given element.
|
||||
*
|
||||
* @param target the element whose coordinate system is to be used
|
||||
* @return the relative x-position
|
||||
*/
|
||||
public int getRelativeX(Element target) {
|
||||
return getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() +
|
||||
target.getOwnerDocument().getScrollLeft();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mouse y-position relative to a given element.
|
||||
*
|
||||
* @param target the element whose coordinate system is to be used
|
||||
* @return the relative y-position
|
||||
*/
|
||||
public int getRelativeY(Element target) {
|
||||
return getClientY() - target.getAbsoluteTop() + target.getScrollTop() +
|
||||
target.getOwnerDocument().getScrollTop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mouse x-position on the user's display.
|
||||
*
|
||||
* @return the mouse x-position
|
||||
*/
|
||||
public native int getScreenX() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.screenX || 0;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Gets the mouse y-position on the user's display.
|
||||
*
|
||||
* @return the mouse y-position
|
||||
*/
|
||||
public native int getScreenY() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.screenY || 0;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Is <code>alt</code> key down.
|
||||
*
|
||||
* @return whether the alt key is down
|
||||
*/
|
||||
public native boolean isAltKeyDown() /*-{
|
||||
return !!this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.altKey;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Is <code>control</code> key down.
|
||||
*
|
||||
* @return whether the control key is down
|
||||
*/
|
||||
public native boolean isControlKeyDown() /*-{
|
||||
return !!this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.ctrlKey;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Is <code>meta</code> key down.
|
||||
*
|
||||
* @return whether the meta key is down
|
||||
*/
|
||||
public native boolean isMetaKeyDown() /*-{
|
||||
return !!this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.metaKey;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Is <code>shift</code> key down.
|
||||
*
|
||||
* @return whether the shift key is down
|
||||
*/
|
||||
public native boolean isShiftKeyDown() /*-{
|
||||
return !!this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.shiftKey;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user clicks on a specific
|
||||
* point in a series. This class should not be instantiated directly, but instead you should create
|
||||
* a {@link PointClickEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setPointClickEventHandler(PointClickEventHandler)}
|
||||
* method in order to access click events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PointClickEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create click events
|
||||
* directly, but instead should register a {@link PointClickEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointClickEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when click events are fired on the individual
|
||||
* points in a series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setPointClickEventHandler(new PointClickEventHandler() {
|
||||
* public boolean onClick(PointClickEvent clickEvent) {
|
||||
* Window.alert("User clicked on point: " + clickEvent.getXAsLong() + ", " + clickEvent.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointClickEvent} class for more details on the data
|
||||
* available when a point click event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface PointClickEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a click event occurs on an individual point. See
|
||||
* the {@link PointClickEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
* If the {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setAllowPointSelect(boolean)}
|
||||
* option is true, the default action for the point's click event is to toggle the point's select state.
|
||||
* Returning false cancel this action.
|
||||
*
|
||||
* @param pointClickEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to cancel the default
|
||||
* action of selecting the point when the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setAllowPointSelect(boolean)}
|
||||
* option is enabled.
|
||||
*/
|
||||
public boolean onClick(PointClickEvent pointClickEvent);
|
||||
|
||||
}
|
||||
Executable
+144
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import org.moxieapps.gwt.highcharts.client.Point;
|
||||
|
||||
/**
|
||||
* The base class of all events that are triggered on a point, and includes methods for accessing the general
|
||||
* properties of the point, such as its name or X and Y values.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public abstract class PointEvent extends MouseEvent {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private JavaScriptObject point;
|
||||
|
||||
/**
|
||||
* We can only be created by instantiating one of our sub classes.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
protected PointEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event);
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new GWT point instance that is connected to the Highcharts JS point instance associated
|
||||
* with this event.
|
||||
*
|
||||
* @return A Point instance that is connected to the Highcharts data point associated with this event
|
||||
*/
|
||||
public Point getPoint() {
|
||||
return new Point(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the unique id of the series that the point is a part of which received the event.
|
||||
* This id can then be used to obtain the Series instance itself via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.BaseChart#getSeries(String)} method.
|
||||
*
|
||||
* @return The unique id of the series that the point was a part of that the event was triggered on.
|
||||
*/
|
||||
public native String getSeriesId() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.PointEvent::point.series.options.id;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the series that the point is a part of which the event was received on.
|
||||
*
|
||||
* @return The name of the series that the point was a part of that the event was received on.
|
||||
*/
|
||||
public native String getSeriesName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.PointEvent::point.series.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the point on which the event occurred.
|
||||
*
|
||||
* @return The name of the point on which the event occurred.
|
||||
*/
|
||||
public native String getPointName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.PointEvent::point.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the point as a double.
|
||||
*/
|
||||
public native double getXAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.PointEvent::point.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the point as a long.
|
||||
*/
|
||||
public long getXAsLong() {
|
||||
return ((Double)getXAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The x value of the point as a string.
|
||||
*/
|
||||
public native String getXAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.PointEvent::point.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the point as a double.
|
||||
*/
|
||||
public native double getYAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.PointEvent::point.y;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the point as a long.
|
||||
*/
|
||||
public long getYAsLong() {
|
||||
return ((Double)getYAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The y value of the point as a string.
|
||||
*/
|
||||
public native String getYAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.PointEvent::point.y;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a specific legend item point
|
||||
* in a pie series is clicked. This class should not be instantiated directly, but
|
||||
* instead you should create a {@link PointLegendItemClickEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.PiePlotOptions#setPointLegendItemClickEventHandler(PointLegendItemClickEventHandler)}
|
||||
* method in order to access legend item click events in a pie series.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.2
|
||||
*/
|
||||
public class PointLegendItemClickEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create legend click events
|
||||
* directly, but instead should register a {@link PointLegendItemClickEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointLegendItemClickEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when legend click events are fired on the individual
|
||||
* points in a pie series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setPiePlotOptions(new PiePlotOptions()
|
||||
* .setPointLegendItemClickEventHandler(new PointLegendItemClickEventHandler() {
|
||||
* public boolean onClick(PointLegendItemClickEvent event) {
|
||||
* Window.alert("Legend item clicked: " + event.getXAsLong() + ", " + event.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointLegendItemClickEvent} class for more details on the data
|
||||
* available when a point legend item click event occurs on a pie series.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.2
|
||||
*/
|
||||
public interface PointLegendItemClickEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a click event occurs on an individual legend item in a pie series. See
|
||||
* the {@link PointLegendItemClickEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
* Return false to prevent the selection from occurring.
|
||||
*
|
||||
* @param pointLegendItemClickEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to prevent the action.
|
||||
*/
|
||||
public boolean onClick(PointLegendItemClickEvent pointLegendItemClickEvent);
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user mouses out of a specific
|
||||
* point in a series. This class should not be instantiated directly, but instead you should create
|
||||
* a {@link PointMouseOutEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setPointMouseOutEventHandler(PointMouseOutEventHandler)}
|
||||
* method in order to access mouse out events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PointMouseOutEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create mouse out events
|
||||
* directly, but instead should register a {@link PointMouseOutEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointMouseOutEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when mouse out events are fired on the individual
|
||||
* points in a series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setPointMouseOutEventHandler(new PointMouseOutEventHandler() {
|
||||
* public boolean onMouseOut(PointMouseOutEvent event) {
|
||||
* Window.alert("User moused out of point: " + event.getXAsLong() + ", " + event.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointMouseOutEvent} class for more details on the data
|
||||
* available when a point mouse out event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface PointMouseOutEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a mouse out event occurs on an individual point. See
|
||||
* the {@link PointMouseOutEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
*
|
||||
* @param pointMouseOutEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function.
|
||||
*/
|
||||
public boolean onMouseOut(PointMouseOutEvent pointMouseOutEvent);
|
||||
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user mouses over a specific
|
||||
* point in a series. This class should not be instantiated directly, but instead you should create
|
||||
* a {@link PointMouseOverEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setPointMouseOverEventHandler(PointMouseOverEventHandler)}
|
||||
* method in order to access mouse over events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PointMouseOverEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create mouse over events
|
||||
* directly, but instead should register a {@link PointMouseOverEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointMouseOverEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when mouse over events are fired on the individual
|
||||
* points in a series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setPointMouseOverEventHandler(new PointMouseOverEventHandler() {
|
||||
* public boolean onMouseOver(PointMouseOverEvent event) {
|
||||
* Window.alert("User moused over point: " + event.getXAsLong() + ", " + event.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointMouseOverEvent} class for more details on the data
|
||||
* available when a point mouse over event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface PointMouseOverEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a mouse over event occurs on an individual point. See
|
||||
* the {@link PointMouseOverEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
*
|
||||
* @param pointMouseOverEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function.
|
||||
*/
|
||||
public boolean onMouseOver(PointMouseOverEvent pointMouseOverEvent);
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a specific point in a series
|
||||
* is removed via the Point.remove() method. This class should not be instantiated directly, but
|
||||
* instead you should create a {@link PointRemoveEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setPointRemoveEventHandler(PointRemoveEventHandler)}
|
||||
* method in order to access remove events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PointRemoveEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create remove events
|
||||
* directly, but instead should register a {@link PointRemoveEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointRemoveEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when remove events are fired on the individual
|
||||
* points in a series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setPointRemoveEventHandler(new PointRemoveEventHandler() {
|
||||
* public boolean onRemove(PointRemoveEvent removeEvent) {
|
||||
* Window.alert("Point removed: " + removeEvent.getXAsLong() + ", " + removeEvent.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointRemoveEvent} class for more details on the data
|
||||
* available when a point remove event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface PointRemoveEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a remove event occurs on an individual point. See
|
||||
* the {@link PointRemoveEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
* Return false to prevent the point from being removed.
|
||||
*
|
||||
* @param pointRemoveEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to prevent the action.
|
||||
*/
|
||||
public boolean onRemove(PointRemoveEvent pointRemoveEvent);
|
||||
|
||||
}
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a specific point in a series
|
||||
* is selected (either by the user or programatically). This class should not be instantiated directly, but
|
||||
* instead you should create a {@link PointSelectEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setPointSelectEventHandler(PointSelectEventHandler)}
|
||||
* method in order to access select events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PointSelectEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create select events
|
||||
* directly, but instead should register a {@link PointSelectEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointSelectEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when select events are fired on the individual
|
||||
* points in a series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setPointSelectEventHandler(new PointSelectEventHandler() {
|
||||
* public boolean onSelect(PointSelectEvent selectEvent) {
|
||||
* Window.alert("Point selectd: " + selectEvent.getXAsLong() + ", " + selectEvent.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointSelectEvent} class for more details on the data
|
||||
* available when a point select event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface PointSelectEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a select event occurs on an individual point. See
|
||||
* the {@link PointSelectEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
* Return false to prevent the selection from occurring.
|
||||
*
|
||||
* @param pointSelectEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to prevent the action.
|
||||
*/
|
||||
public boolean onSelect(PointSelectEvent pointSelectEvent);
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a specific point in a series
|
||||
* is Unselected (either by the user or programatically). This class should not be instantiated directly, but
|
||||
* instead you should create a {@link PointUnselectEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setPointUnselectEventHandler(PointUnselectEventHandler)}
|
||||
* method in order to access Unselect events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PointUnselectEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create Unselect events
|
||||
* directly, but instead should register a {@link PointUnselectEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointUnselectEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when unselect events are fired on the individual
|
||||
* points in a series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setPointUnselectEventHandler(new PointUnselectEventHandler() {
|
||||
* public boolean onUnselect(PointUnselectEvent unselectEvent) {
|
||||
* Window.alert("Point unselectd: " + unselectEvent.getXAsLong() + ", " + unselectEvent.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointUnselectEvent} class for more details on the data
|
||||
* available when a point unselect event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface PointUnselectEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a unselect event occurs on an individual point. See
|
||||
* the {@link PointUnselectEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
* Return false to prevent the unselection from occurring.
|
||||
*
|
||||
* @param pointUnselectEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to prevent the action.
|
||||
*/
|
||||
public boolean onUnselect(PointUnselectEvent pointUnselectEvent);
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a specific point in a series
|
||||
* is updated programatically. This class should not be instantiated directly, but
|
||||
* instead you should create a {@link PointUpdateEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setPointUpdateEventHandler(PointUpdateEventHandler)}
|
||||
* method in order to access update events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PointUpdateEvent extends PointEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create update events
|
||||
* directly, but instead should register a {@link PointUpdateEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param point The native javascript object that represents the point instance that the event was triggered on.
|
||||
*/
|
||||
public PointUpdateEvent(JavaScriptObject event, JavaScriptObject point) {
|
||||
super(event, point);
|
||||
}
|
||||
|
||||
// TODO: Add access to the new options of the point
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when update events are fired on the individual
|
||||
* points in a series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setPointUpdateEventHandler(new PointUpdateEventHandler() {
|
||||
* public boolean onUpdate(PointUpdateEvent updateEvent) {
|
||||
* Window.alert("Point updated: " + updateEvent.getXAsLong() + ", " + updateEvent.getYAsLong());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link PointUpdateEvent} class for more details on the data
|
||||
* available when a point update event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface PointUpdateEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a update event occurs on an individual point. See
|
||||
* the {@link PointUpdateEvent} class for more details on the data available when this event is fired.
|
||||
* <p/>
|
||||
* Return false to prevent the update from occurring.
|
||||
*
|
||||
* @param pointUpdateEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to prevent the action.
|
||||
*/
|
||||
public boolean onUpdate(PointUpdateEvent pointUpdateEvent);
|
||||
|
||||
}
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user clicks on the checkbox
|
||||
* next to a series' name in the chart. This class should
|
||||
* not be instantiated directly, but instead you should create a {@link SeriesCheckboxClickEventHandler} and
|
||||
* register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setSeriesCheckboxClickEventHandler(SeriesCheckboxClickEventHandler)}
|
||||
* method in order to access checkbox click events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SeriesCheckboxClickEvent extends SeriesEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create click events
|
||||
* directly, but instead should register a {@link SeriesCheckboxClickEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
public SeriesCheckboxClickEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event, series);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the checkbox state was checked on, or false if it was checked off.
|
||||
*
|
||||
* @return Whether or not the checkbox was checked or not.
|
||||
*/
|
||||
public native boolean isChecked() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.checked;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when checkbox click events are fired on the series
|
||||
* of a chart, which occurs when the checkbox next to the series' name in the legend is clicked. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setSeriesCheckboxClickEventHandler(new SeriesCheckboxClickEventHandler() {
|
||||
* public boolean onClick(SeriesCheckboxClickEvent clickEvent) {
|
||||
* Window.alert("User clicked the checkbox state of the series: " + clickEvent.getSeriesName());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link ChartClickEvent} class for more details on the data
|
||||
* available when a checkbox click event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface SeriesCheckboxClickEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a checkbox click event occurs on a series. See
|
||||
* the {@link SeriesCheckboxClickEvent} class for more details on the data available when this event is fired.
|
||||
* Return false to prevent the default action which is to toggle the select state of the series.
|
||||
*
|
||||
* @param seriesCheckboxClickEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to prevent
|
||||
* the default action which is to toggle the select state of the series.
|
||||
*/
|
||||
public boolean onClick(SeriesCheckboxClickEvent seriesCheckboxClickEvent);
|
||||
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import org.moxieapps.gwt.highcharts.client.Point;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user clicks on a series
|
||||
* in the chart, including the nearest point to the click. This class should
|
||||
* not be instantiated directly, but instead you should create a {@link SeriesClickEventHandler} and
|
||||
* register it via the {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setSeriesClickEventHandler(SeriesClickEventHandler)}
|
||||
* method in order to access click events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SeriesClickEvent extends SeriesEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create click events
|
||||
* directly, but instead should register a {@link SeriesClickEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
public SeriesClickEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event, series);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new GWT point instance that is connected to the Highcharts JS point instance associated
|
||||
* with the nearest point to the click (e.g. "event.point").
|
||||
*
|
||||
* @return A Point instance that is connected to the Highcharts data point associated with this event
|
||||
*/
|
||||
public Point getNearestPoint() {
|
||||
return new Point(nativeGetPoint());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the point nearest to the click (e.g. "event.point.name").
|
||||
*
|
||||
* @return The name of the point that was nearest to where the user clicked on the series.
|
||||
*/
|
||||
public native String getNearestPointName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.point.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the nearest point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the nearest point as a double.
|
||||
*/
|
||||
public native double getNearestXAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.point.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the nearest point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the nearest point as a long.
|
||||
*/
|
||||
public long getNearestXAsLong() {
|
||||
return ((Double)getNearestXAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the x value of the nearest point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The x value of the nearest point as a string.
|
||||
*/
|
||||
public native String getNearestXAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.point.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the nearest point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the nearest point as a double.
|
||||
*/
|
||||
public native double getNearestYAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.point.y;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the nearest point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the nearest point as a long.
|
||||
*/
|
||||
public long getNearestYAsLong() {
|
||||
return ((Double)getNearestYAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the y value of the nearest point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The y value of the nearest point as a string.
|
||||
*/
|
||||
public native String getNearestYAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.point.y;
|
||||
}-*/;
|
||||
|
||||
private native JavaScriptObject nativeGetPoint() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.MouseEvent::event.point;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when click events are fired on the series
|
||||
* of a chart. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setSeriesClickEventHandler(new SeriesClickEventHandler() {
|
||||
* public boolean onClick(SeriesClickEvent clickEvent) {
|
||||
* Window.alert("User clicked on the series near the point: " + clickEvent.getNearestPointName());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link ChartClickEvent} class for more details on the data
|
||||
* available when a click event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface SeriesClickEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a click event occurs on a series. See
|
||||
* the {@link SeriesClickEvent} class for more details on the data available when this event is fired.
|
||||
*
|
||||
* @param seriesClickEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onClick(SeriesClickEvent seriesClickEvent);
|
||||
|
||||
}
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* The base class of all events that are triggered on a series, and includes methods for accessing the general
|
||||
* properties of the series, such as its name or id.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public abstract class SeriesEvent extends MouseEvent {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
private JavaScriptObject series;
|
||||
|
||||
/**
|
||||
* We can only be created by instantiating one of our sub classes.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
protected SeriesEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event);
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the unique id of the series that received the event. This id can then be used
|
||||
* to obtain the Series instance itself via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.BaseChart#getSeries(String)} method.
|
||||
*
|
||||
* @return The unique id of the series that the event was triggered on.
|
||||
*/
|
||||
public native String getSeriesId() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.SeriesEvent::series.options.id;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the series that the event was received on.
|
||||
*
|
||||
* @return The name of the series that the event was received on.
|
||||
*/
|
||||
public native String getSeriesName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.SeriesEvent::series.name;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a series is hidden
|
||||
* in the chart. This class should not be instantiated directly, but instead you should
|
||||
* create a {@link SeriesHideEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setSeriesClickEventHandler(SeriesClickEventHandler)}
|
||||
* method in order to access series hide events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SeriesHideEvent extends SeriesEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create hide events
|
||||
* directly, but instead should register a {@link SeriesHideEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
public SeriesHideEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event, series);
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when series hide events are fired on the chart.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setSeriesHideEventHandler(new SeriesHideEventHandler() {
|
||||
* public boolean onHide(SeriesHideEvent event) {
|
||||
* Window.alert("Series hidden: " + event.getSeriesName());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface SeriesHideEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a series is hidden.
|
||||
*
|
||||
* @param seriesHideEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onHide(SeriesHideEvent seriesHideEvent);
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a user clicks on the legend item
|
||||
* associated with a series. This class should not be instantiated directly, but instead you should create
|
||||
* a {@link SeriesLegendItemClickEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setSeriesLegendItemClickEventHandler(SeriesLegendItemClickEventHandler)}
|
||||
* method in order to access legend item click events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SeriesLegendItemClickEvent extends SeriesEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create click events
|
||||
* directly, but instead should register a {@link SeriesLegendItemClickEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
public SeriesLegendItemClickEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event, series);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the series is now visible, false if it is invisible
|
||||
*
|
||||
* @return Whether or not the series is visible.
|
||||
*/
|
||||
public native boolean isVisible() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.events.SeriesEvent::series.visible;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when legend item belonging to the series is clicked.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setSeriesLegendItemClickEventHandler(new SeriesLegendItemClickEventHandler() {
|
||||
* public boolean onClick(SeriesLegendItemClickEvent seriesLegendItemClickEvent) {
|
||||
* Window.alert("User changed the visibility state of the series: " + clickEvent.getSeriesName());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link SeriesLegendItemClickEvent} class for more details on the data
|
||||
* available when a legend item click event occurs.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface SeriesLegendItemClickEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever the legend item belonging to the series is clicked. See
|
||||
* the {@link SeriesLegendItemClickEvent} class for more details on the data available when this event is fired.
|
||||
* The default action is to toggle the visibility of the series. This can be prevented by returning false.
|
||||
*
|
||||
* @param seriesLegendItemClickEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function. Return false to prevent
|
||||
* the default action which is to toggle the visibility of the series.
|
||||
*/
|
||||
public boolean onClick(SeriesLegendItemClickEvent seriesLegendItemClickEvent);
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a series mouse out event
|
||||
* occurs. This class should not be instantiated directly, but instead you should
|
||||
* create a {@link SeriesMouseOutEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setSeriesMouseOutEventHandler(SeriesMouseOutEventHandler)}
|
||||
* method in order to access series mouse out events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SeriesMouseOutEvent extends SeriesEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create mouse out events
|
||||
* directly, but instead should register a {@link SeriesMouseOutEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
public SeriesMouseOutEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event, series);
|
||||
}
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when series mouse out events are fired on the chart.
|
||||
* If the {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setStickyTracking(boolean)}
|
||||
* option is true, the mouse out eventd oesn't happen before the mouse enters another graph or leaves the plot area.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setSeriesMouseOutEventHandler(new SeriesMouseOutEventHandler() {
|
||||
* public boolean onMouseOut(SeriesMouseOutEvent event) {
|
||||
* Window.alert("Moused out series: " + event.getSeriesName());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface SeriesMouseOutEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a mouse out event occurs on a series. See
|
||||
* the {@link SeriesMouseOutEvent} class for more details on the data available when this event is fired.
|
||||
*
|
||||
* @param seriesMouseOutEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onMouseOut(SeriesMouseOutEvent seriesMouseOutEvent);
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a series mouse over event
|
||||
* occurs. This class should not be instantiated directly, but instead you should
|
||||
* create a {@link SeriesMouseOverEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setSeriesMouseOverEventHandler(SeriesMouseOverEventHandler)}
|
||||
* method in order to access series mouse over events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SeriesMouseOverEvent extends SeriesEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create mouse over events
|
||||
* directly, but instead should register a {@link SeriesMouseOverEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
public SeriesMouseOverEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event, series);
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when series mouse over events are fired on the chart.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setSeriesMouseOverEventHandler(new SeriesMouseOverEventHandler() {
|
||||
* public boolean onMouseOver(SeriesMouseOverEvent event) {
|
||||
* Window.alert("Moused over series: " + event.getSeriesName());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface SeriesMouseOverEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a mouse over event occurs on a series. See
|
||||
* the {@link SeriesMouseOverEvent} class for more details on the data available when this event is fired.
|
||||
*
|
||||
* @param seriesMouseOverEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onMouseOver(SeriesMouseOverEvent seriesMouseOverEvent);
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* Provides access to the raw information provided by Highcharts when a series is shown
|
||||
* in the chart. This class should not be instantiated directly, but instead you should
|
||||
* create a {@link SeriesShowEventHandler} and register it via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions#setSeriesClickEventHandler(SeriesClickEventHandler)}
|
||||
* method in order to access series show events.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class SeriesShowEvent extends SeriesEvent {
|
||||
|
||||
/**
|
||||
* This constructor is intended for internal use only. You should not create show events
|
||||
* directly, but instead should register a {@link SeriesShowEventHandler}.
|
||||
*
|
||||
* @param event The native javascript object containing the details of the original event that was fired.
|
||||
* @param series The native javascript object that represents the series instance that the event was triggered on.
|
||||
*/
|
||||
public SeriesShowEvent(JavaScriptObject event, JavaScriptObject series) {
|
||||
super(event, series);
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
/**
|
||||
* An interface that can be used as a callback handler when series show events are fired on the chart.
|
||||
* General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(new SeriesPlotOptions()
|
||||
* .setSeriesShowEventHandler(new SeriesShowEventHandler() {
|
||||
* public boolean onShow(SeriesShowEvent event) {
|
||||
* Window.alert("Series hidden: " + event.getSeriesName());
|
||||
* return true;
|
||||
* }
|
||||
* )
|
||||
* });
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public interface SeriesShowEventHandler {
|
||||
|
||||
/**
|
||||
* This method is fired whenever a series is hidden.
|
||||
*
|
||||
* @param seriesShowEvent The details of the event that occurred.
|
||||
* @return The response to send back to the event handler function
|
||||
*/
|
||||
public boolean onShow(SeriesShowEvent seriesShowEvent);
|
||||
|
||||
}
|
||||
java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/labels/AxisLabelsData.java
Executable
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* An object that represents the state information that will be passed to any custom
|
||||
* {@link AxisLabelsFormatter} to allow for custom strings to be rendered as the labels on an axis.
|
||||
* See the {@link AxisLabelsFormatter#format(AxisLabelsData)} method for more details on the capabilities
|
||||
* that custom formatters can provide.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AxisLabelsData {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private JavaScriptObject data;
|
||||
|
||||
/**
|
||||
* This constructor needs to be public scope but you should not construct this object directly, but
|
||||
* instead simply implement a custom {@link AxisLabelsFormatter} and this API will pass you the
|
||||
* appropriate instance of this object at runtime.
|
||||
*
|
||||
* @param data A reference to the native Highcharts javascript object.
|
||||
*/
|
||||
public AxisLabelsData(JavaScriptObject data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the label as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The value of the label as a double.
|
||||
*/
|
||||
public native double getValueAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.AxisLabelsData::data.value;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the value of the label as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The value of the label as a long.
|
||||
*/
|
||||
public long getValueAsLong() {
|
||||
return ((Double)getValueAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the label as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The value of the label as a string.
|
||||
*/
|
||||
public native String getValueAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.AxisLabelsData::data.value;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
/**
|
||||
* An interface that can be used to control the display of the X or Y axis labels to contain
|
||||
* custom text or formatting. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.getXAxis().setLabels(
|
||||
* new XAxisLabels()
|
||||
* .setFormatter(new AxisLabelsFormatter() {
|
||||
* public String format(AxisLabelsData axisLabelsData) {
|
||||
* return axisLabelsData.getValueAsLong() + " degrees";
|
||||
* }
|
||||
* })
|
||||
* );
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link #format(AxisLabelsData)} function for more details on the
|
||||
* capabilities available within custom formatters.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface AxisLabelsFormatter {
|
||||
|
||||
/**
|
||||
* Callback function to format the text of a label on an axis.
|
||||
* <p/>
|
||||
* A subset of HTML is supported. The HTML of the label is parsed and converted to SVG, therefore
|
||||
* this isn't a complete HTML renderer. The following tags are supported: <b>, <strong>, <i>,
|
||||
* <em>, <br/>, and <span>. Spans can be styled with a style attribute, but only text-related
|
||||
* CSS that is shared with SVG is handled.
|
||||
* <p/>
|
||||
* Available data provided in the given "AxisLabelsData" object are:
|
||||
* <ul>
|
||||
* <li>
|
||||
* <b>value</b> : The numeric or categorical string value to display.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param axisLabelsData An object containing all of the data available to the formatter that it can
|
||||
* use to determine which text and styling to use for the label.
|
||||
* @return The text to display for the label (including any styling).
|
||||
*/
|
||||
public String format(AxisLabelsData axisLabelsData);
|
||||
|
||||
}
|
||||
java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/labels/BaseDataLabels.java
Executable
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
/**
|
||||
* A common base class for both {@link DataLabels} and {@link PieDataLabels} to prevent code duplication
|
||||
* while still maintaining a cleaner way for the user to utilize the method chaining with the generics
|
||||
* in place. You should not use this class directly, but instead use one of the base classes.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public abstract class BaseDataLabels<T extends BaseDataLabels> extends Labels<T> {
|
||||
|
||||
private DataLabelsFormatter dataLabelsFormatter;
|
||||
|
||||
/**
|
||||
* Sets a custom formatter for the labels that can be used to control how the text of the
|
||||
* data labels will be displayed. See the {@link DataLabelsFormatter} interface, and
|
||||
* in particular the {@link DataLabelsFormatter#format(DataLabelsData)} method for more details on
|
||||
* the capabilities available to custom formatters.
|
||||
*
|
||||
* @param dataLabelsFormatter The custom formatter to use for the labels (if not given a built-in
|
||||
* generic formatter is used which simply returns the Y value of the point).
|
||||
* @return A reference to this {@link DataLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setFormatter(DataLabelsFormatter dataLabelsFormatter) {
|
||||
this.dataLabelsFormatter = dataLabelsFormatter;
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
final T instance = (T) this;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the custom data labels formatter that has been applied to the labels, or null if the
|
||||
* built-in generic formatter is being used instead.
|
||||
*
|
||||
* @return The custom data labels formatter that has been applied, or null if it has not been set.
|
||||
*/
|
||||
public DataLabelsFormatter getFormatter() {
|
||||
return this.dataLabelsFormatter;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.plotOptions.PlotOptions;
|
||||
|
||||
/**
|
||||
* A simple configurable class that can be used to represent custom data label display options, which
|
||||
* can then be set as the default data label display approach which can then be applied to a PlotOptions
|
||||
* (via the {@link PlotOptions#setDataLabels(org.moxieapps.gwt.highcharts.client.labels.DataLabels)} method).
|
||||
* <p/>
|
||||
* Note that PlotOptions can then be applied either to the entire chart (via the
|
||||
* {@link org.moxieapps.gwt.highcharts.client.Chart#setSeriesPlotOptions(org.moxieapps.gwt.highcharts.client.plotOptions.SeriesPlotOptions)}
|
||||
* method), or to a specific data series (via the {@link org.moxieapps.gwt.highcharts.client.Series#setPlotOptions(PlotOptions)}
|
||||
* method).
|
||||
* <p/>
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(
|
||||
* new SeriesPlotOptions()
|
||||
* .setDataLabels(
|
||||
* new DataLabels()
|
||||
* .setEnabled(true)
|
||||
* .setAlign(Labels.Align.CENTER)
|
||||
* .setColor("#CC0000")
|
||||
* )
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DataLabels extends BaseDataLabels<DataLabels> {
|
||||
|
||||
// Everything we need is inherited from our base class, so this class is really only needed to
|
||||
// handle setting the correct generic type (so the user doesn't need to deal with the type manually)
|
||||
|
||||
}
|
||||
java/org.moxieapps.gwt.highcharts/src/org/moxieapps/gwt/highcharts/client/labels/DataLabelsData.java
Executable
+174
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* An object that represents the state information that will be passed to any custom
|
||||
* {@link DataLabelsFormatter} to allow for custom strings to be rendered as the data labels of a series.
|
||||
* See the {@link DataLabelsFormatter#format(DataLabelsData)} method for more details on the capabilities
|
||||
* that custom formatters can provide.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DataLabelsData {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private JavaScriptObject data;
|
||||
|
||||
/**
|
||||
* This constructor needs to be public scope but you should not construct this object directly, but
|
||||
* instead simply implement a custom {@link DataLabelsFormatter} and this API will pass you the
|
||||
* appropriate instance of this object at runtime.
|
||||
*
|
||||
* @param data A reference to the native Highcharts javascript object.
|
||||
*/
|
||||
public DataLabelsData(JavaScriptObject data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the point's percentage of the total. Stacked series and pies only.
|
||||
*
|
||||
* @return The percentage value of the total.
|
||||
*/
|
||||
public native double getPercentage() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.percentage;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the series that the data label is a part of (e.g. "series.name").
|
||||
*
|
||||
* @return The name of the series that the data label is a part of
|
||||
*/
|
||||
public native String getSeriesName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.series.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the name of the point (e.g. "point.name") that the data label is associated with.
|
||||
*
|
||||
* @return The name of the point that the data label is associated with.
|
||||
*/
|
||||
public native String getPointName() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.point.name;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the total value at this point's x value. Stacked series only.
|
||||
*
|
||||
* @return The total value at this point's x value (only applicable in stacked series).
|
||||
*/
|
||||
public native double getTotal() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.total;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the total value at this point's x value as a long. Stacked series only.
|
||||
*
|
||||
* @return Return the total value at this point's x value as a long.
|
||||
*/
|
||||
public long getTotalAsLong() {
|
||||
return ((Double)getTotal()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the X value associated with this data label is non null. This method
|
||||
* is useful when rendering data labels in a chart that may contain null point values.
|
||||
*
|
||||
* @return 'true' if the X value is non null, 'false' otherwise.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native boolean hasXValue() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.x != null;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the point as a double.
|
||||
*/
|
||||
public native double getXAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The x value of the point as a long.
|
||||
*/
|
||||
public long getXAsLong() {
|
||||
return ((Double)getXAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the x value of the point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The x value of the point as a string.
|
||||
*/
|
||||
public native String getXAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.x;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Returns 'true' if the Y value associated with this data label is non null. This method
|
||||
* is useful when rendering data labels in a chart that may contain null point values.
|
||||
*
|
||||
* @return 'true' if the Y value is non null, 'false' otherwise.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public native boolean hasYValue() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.y != null;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a double. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the point as a double.
|
||||
*/
|
||||
public native double getYAsDouble() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.y;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a long. An exception will be thrown
|
||||
* if the native value of the object is not a number.
|
||||
*
|
||||
* @return The y value of the point as a long.
|
||||
*/
|
||||
public long getYAsLong() {
|
||||
return ((Double)getYAsDouble()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the y value of the point as a string. An exception will be thrown
|
||||
* if the native value of the object is not a string.
|
||||
*
|
||||
* @return The y value of the point as a string.
|
||||
*/
|
||||
public native String getYAsString() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.DataLabelsData::data.y;
|
||||
}-*/;
|
||||
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
/**
|
||||
* An interface that can be used to control the display of the data labels displayed within a
|
||||
* series. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.setSeriesPlotOptions(
|
||||
* new SeriesPlotOptions()
|
||||
* .setDataLabels(
|
||||
* new DataLabels()
|
||||
* .setFormatter(new DataLabelsFormatter() {
|
||||
* public String format(DataLabelsData dataLabelsData) {
|
||||
* return dataLabelsData.getYAsLong() + " degrees";
|
||||
* }
|
||||
* })
|
||||
* )
|
||||
* );
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link #format(DataLabelsData)} function for more details on the
|
||||
* capabilities available within custom formatters.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface DataLabelsFormatter {
|
||||
|
||||
/**
|
||||
* Callback function to format the text of a data label.
|
||||
* <p/>
|
||||
* A subset of HTML is supported. The HTML of the label is parsed and converted to SVG, therefore
|
||||
* this isn't a complete HTML renderer. The following tags are supported: <b>, <strong>, <i>,
|
||||
* <em>, <br/>, and <span>. Spans can be styled with a style attribute, but only text-related
|
||||
* CSS that is shared with SVG is handled.
|
||||
* <p/>
|
||||
* Available data provided in the given "DataLabelsData" object are:
|
||||
* <ul>
|
||||
* <li>
|
||||
* <b>percentage</b> : Stacked series and pies only. The point's percentage of the total.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>point.name</b> : The point objects name, if defined.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>series.name</b> : The name of the series that the data label is part of.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>total</b> : Stacked series only. The total value at this point's x value.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>x</b> : The X value of the point.
|
||||
* </li>
|
||||
* <li>
|
||||
* <b>y</b> : The Y value of the point.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param dataLabelsData An object containing all of the data available to the formatter that it can
|
||||
* use to determine which text and styling to use for the label.
|
||||
* @return The text to display for the label (including any styling).
|
||||
*/
|
||||
public String format(DataLabelsData dataLabelsData);
|
||||
|
||||
}
|
||||
Executable
+176
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Configurable;
|
||||
import org.moxieapps.gwt.highcharts.client.Style;
|
||||
|
||||
/**
|
||||
* Represents the common base class for all label configuration option types, which allows
|
||||
* for general options to be set via the inherited {@link org.moxieapps.gwt.highcharts.client.Configurable#setOption(String, Object)}
|
||||
* method. But also exposes type specific methods that the caller is encouraged to use instead,
|
||||
* such as {@link #setAlign(org.moxieapps.gwt.highcharts.client.labels.Labels.Align)}, {@link #setColor(String)}, etc.
|
||||
* <p/>
|
||||
* Note that this class is abstract and therefore can't be instantiated directly. Instead you
|
||||
* should create an instance of more specific sub type, such as {@link XAxisLabels}, {@link YAxisLabels},
|
||||
* or {@link DataLabels}.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public abstract class Labels<T extends Labels> extends Configurable<T> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported label alignment types, which can be passed to methods
|
||||
* like {@link org.moxieapps.gwt.highcharts.client.labels.Labels#setAlign(org.moxieapps.gwt.highcharts.client.labels.Labels.Align)} method.
|
||||
*/
|
||||
public enum Align {
|
||||
|
||||
/**
|
||||
* Align the data label to the left of the point
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Align the data label to the right of the point
|
||||
*/
|
||||
RIGHT("right"),
|
||||
|
||||
/**
|
||||
* Align the data label on the center of the point
|
||||
*/
|
||||
CENTER("center");
|
||||
|
||||
private Align(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option for the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("align", Labels.Align.CENTER);
|
||||
* </code></pre>
|
||||
* The alignment of the data label compared to the point. Can be one of "left", "center" or "right". Defaults to "center".
|
||||
*
|
||||
* @param align The alignment of the label compared to the point.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.Labels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setAlign(Align align) {
|
||||
return this.setOption("align", align != null ? align.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'color' option for the data labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("color", "#CC0000");
|
||||
* </code></pre>
|
||||
* The text color for the data labels. Defaults to null.
|
||||
*
|
||||
* @param color The text color to use for the labels.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.Labels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setColor(String color) {
|
||||
return this.setOption("color", color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'enabled' option for the data labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("enabled", true);
|
||||
* </code></pre>
|
||||
* Enable or disable the data labels. Defaults to false.
|
||||
*
|
||||
* @param enabled Whether or not to enable or disable the data labels.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.Labels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setEnabled(boolean enabled) {
|
||||
return this.setOption("enabled", enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'rotation' option for the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("rotation", 90.0f);
|
||||
* </code></pre>
|
||||
* Text rotation in degrees. Defaults to 0.
|
||||
*
|
||||
* @param rotation Text rotation in degrees.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.Labels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setRotation(Number rotation) {
|
||||
return this.setOption("rotation", rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'style' options of the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("/style/fontWeight", "bold");
|
||||
* labels.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
* CSS styles for the labels. Defaults to:
|
||||
* <ul>
|
||||
* <li>color: '#6D869F'</li>
|
||||
* <li>fontWeight: 'bold'</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param style CSS styles for the labels.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.Labels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setStyle(Style style) {
|
||||
return this.setOption("style", style != null ? style.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'x' position option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("x", 70);
|
||||
* </code></pre>
|
||||
* The x position offset of the label relative to the point. Defaults to 0 for series data labels,
|
||||
* -8 y-axis labels, and 0 x-axis labels.
|
||||
*
|
||||
* @param x The x position of the title, relative to the chart's spacing.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.Labels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setX(Number x) {
|
||||
return this.setOption("x", x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'y' position option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("y", -20);
|
||||
* </code></pre>
|
||||
* The y position offset of the label relative to the point. Defaults to -6 for series data labels,
|
||||
* 3 for y-axis labels, and 0 for x-axis labels.
|
||||
*
|
||||
* @param y The y position of the title, relative to the chart's spacing.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.Labels} instance for convenient method chaining.
|
||||
*/
|
||||
public T setY(Number y) {
|
||||
return this.setOption("y", y);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
/**
|
||||
* A configurable class that can be used to represent custom data label display options for pie charts, which
|
||||
* can then be set as the default data label display approach and applied to the PiePlotOptions
|
||||
* (via the {@link org.moxieapps.gwt.highcharts.client.plotOptions.PiePlotOptions#setPieDataLabels(PieDataLabels)} method).
|
||||
* <p/>
|
||||
* Example usage:
|
||||
* <code><pre>
|
||||
* chart.setPiePlotOptions(
|
||||
* new PiePlotOptions()
|
||||
* .setPieDataLabels(
|
||||
* new PieDataLabels()
|
||||
* .setEnabled(true)
|
||||
* .setConnectorColor("#FF0000)
|
||||
* .setConnectorWidth(4.0)
|
||||
* )
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class PieDataLabels extends BaseDataLabels<PieDataLabels> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'connectorColor' option for the data labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("connectorColor", "#CC0000");
|
||||
* </code></pre>
|
||||
* The color of the line connecting the data label to the pie slice. Defaults to #606060.
|
||||
*
|
||||
* @param connectorColor The color of the line connecting the data label to the pie slice.
|
||||
* @return A reference to this {@link PieDataLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public PieDataLabels setConnectorColor(String connectorColor) {
|
||||
return this.setOption("connectorColor", connectorColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'connectorPadding' option for the data labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("connectorPadding", 2.0);
|
||||
* </code></pre>
|
||||
* The distance from the data label to the connector. Defaults to 5.
|
||||
*
|
||||
* @param connectorPadding The The distance from the data label to the connector.
|
||||
* @return A reference to this {@link PieDataLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public PieDataLabels setConnectorPadding(Number connectorPadding) {
|
||||
return this.setOption("connectorPadding", connectorPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'connectorWidth' option for the data labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("connectorWidth", 2.0);
|
||||
* </code></pre>
|
||||
* The width of the line connecting the data label to the pie slice. Defaults to 1.
|
||||
*
|
||||
* @param connectorWidth The width of the line connecting the data label to the pie slice.
|
||||
* @return A reference to this {@link PieDataLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public PieDataLabels setConnectorWidth(Number connectorWidth) {
|
||||
return this.setOption("connectorWidth", connectorWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'distance' option for the data labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* labels.setOption("distance", 24);
|
||||
* </code></pre>
|
||||
* The distance of the data label from the pie's edge. Negative numbers put the data label
|
||||
* on top of the pie slices. Connectors are only shown for data labels outside the pie.
|
||||
* Defaults to 30.
|
||||
*
|
||||
* @param distance The distance of the data label from the pie's edge.
|
||||
* @return A reference to this {@link PieDataLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public PieDataLabels setDistance(Number distance) {
|
||||
return this.setOption("distance", distance);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+263
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Configurable;
|
||||
import org.moxieapps.gwt.highcharts.client.Style;
|
||||
|
||||
/**
|
||||
* Represents the configuration options that can be set for the labels of a {@link org.moxieapps.gwt.highcharts.client.PlotBand}, and
|
||||
* can then be passed to the {@link org.moxieapps.gwt.highcharts.client.PlotBand#setLabel(PlotBandLabel)} method. Example usage:
|
||||
* <code><pre>
|
||||
* XAxis xAxis = chart.getXAxis();
|
||||
* xAxis.setPlotBands(
|
||||
* xAxis.createPlotBand()
|
||||
* .setColor("#CC0000")
|
||||
* .setFrom(40)
|
||||
* .setTo(80)
|
||||
* .setPlotBandLabel(
|
||||
* new PlotBandLabel()
|
||||
* .setAlign(PlotBandLabel.LEFT)
|
||||
* .setX(20)
|
||||
* ),
|
||||
* xAxis.createPlotBand()
|
||||
* .setColor("#009900")
|
||||
* .setFrom(80)
|
||||
* .setTo(120)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class PlotBandLabel extends Configurable<PlotBandLabel> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported plot band label alignment types, which can be passed to methods
|
||||
* like {@link PlotBandLabel#setAlign(Align)} method.
|
||||
*/
|
||||
public enum Align {
|
||||
|
||||
/**
|
||||
* Align the label to the left of the plot band
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Align the label to the right of the plot band
|
||||
*/
|
||||
RIGHT("right"),
|
||||
|
||||
/**
|
||||
* Align the label on the center of the plot band
|
||||
*/
|
||||
CENTER("center");
|
||||
|
||||
private Align(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of supported plot band label text alignment types, which can be passed to methods
|
||||
* like {@link PlotBandLabel#setTextAlign(TextAlign)} method.
|
||||
*/
|
||||
public enum TextAlign {
|
||||
|
||||
/**
|
||||
* Left align the text within the label
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Right align the text within the label
|
||||
*/
|
||||
RIGHT("right"),
|
||||
|
||||
/**
|
||||
* Center the text within the label
|
||||
*/
|
||||
CENTER("center");
|
||||
|
||||
private TextAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of supported plot band label vertical alignment types, which can be passed to methods
|
||||
* like {@link PlotBandLabel#setVerticalAlign(PlotBandLabel.VerticalAlign)}.
|
||||
*/
|
||||
public enum VerticalAlign {
|
||||
|
||||
/**
|
||||
* Align the text at the top of the plot band
|
||||
*/
|
||||
TOP("top"),
|
||||
|
||||
/**
|
||||
* Align the text in the middle of the plot band
|
||||
*/
|
||||
MIDDLE("middle"),
|
||||
|
||||
/**
|
||||
* Align the text at the bottom of the plot band
|
||||
*/
|
||||
BOTTOM("bottom");
|
||||
|
||||
private VerticalAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("align", PlotBandLabel.Align.CENTER);
|
||||
* </code></pre>
|
||||
* Horizontal alignment of the label. Can be one of "left", "center" or "right". Defaults to "center".
|
||||
*
|
||||
* @param align The horizontal alignment of the label.
|
||||
* @return A reference to this {@link PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setAlign(Align align) {
|
||||
return this.setOption("align", align != null ? align.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'rotation' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("rotation", 90.0f);
|
||||
* </code></pre>
|
||||
* Rotation of the text label in degrees. Defaults to 0 for horizontal plot lines and 90 for vertical lines.
|
||||
*
|
||||
* @param rotation Rotation of the text label in degrees.
|
||||
* @return A reference to this {@link PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setRotation(Number rotation) {
|
||||
return this.setOption("rotation", rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'style' options of the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("/style/fontWeight", "bold");
|
||||
* plotBandLabel.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
*
|
||||
* @param style CSS styles for the text labels.
|
||||
* @return A reference to this {@link PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setStyle(Style style) {
|
||||
return this.setOption("style", style != null ? style.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'text' option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("text", "Hi Mom!");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param text The raw text to display as the label.
|
||||
* @return A reference to this {@link PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setText(String text) {
|
||||
return this.setOption("text", text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'textAlign' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("textAlign", PlotBandLabel.TextAlign.RIGHT);
|
||||
* </code></pre>
|
||||
* The text alignment for the label. While <code>align</code> determines where the texts anchor point
|
||||
* is placed within the plot band, <code>textAlign</code> determines how the text is aligned against
|
||||
* its anchor point. Possible values are "left", "center" and "right".
|
||||
* Defaults to the same as the <code>align</code> option.
|
||||
*
|
||||
* @param textAlign The text alignment for the label.
|
||||
* @return A reference to this {@link PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setTextAlign(TextAlign textAlign) {
|
||||
return this.setOption("textAlign", textAlign != null ? textAlign.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'verticalAlign' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("verticalAlign", PlotBandLabel.VerticalAlign.TOP);
|
||||
* </code></pre>
|
||||
* Vertical alignment of the label relative to the plot band. Can be one of "top", "middle" or "bottom". Defaults to "top".
|
||||
*
|
||||
* @param verticalAlign The vertical alignment of the label relative to the plot band.
|
||||
* @return A reference to this {@link PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setVerticalAlign(VerticalAlign verticalAlign) {
|
||||
return this.setOption("verticalAlign", verticalAlign != null ? verticalAlign.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'x' position option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("x", 70);
|
||||
* </code></pre>
|
||||
* Horizontal position relative the alignment. Default varies by orientation.
|
||||
*
|
||||
* @param x The horizontal position relative the alignment.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setX(Number x) {
|
||||
return this.setOption("x", x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'y' position option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotBandLabel.setOption("y", -20);
|
||||
* </code></pre>
|
||||
* Vertical position of the text baseline relative to the alignment. Default varies by orientation.
|
||||
*
|
||||
* @param y The vertical position of the text baseline relative to the alignment.
|
||||
* @return A reference to this {@link PlotBandLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotBandLabel setY(Number y) {
|
||||
return this.setOption("y", y);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+265
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Configurable;
|
||||
import org.moxieapps.gwt.highcharts.client.PlotLine;
|
||||
import org.moxieapps.gwt.highcharts.client.Style;
|
||||
|
||||
/**
|
||||
* Represents the configuration options that can be set for the labels of a {@link PlotLine}, and
|
||||
* can then be passed to the {@link PlotLine#setLabel(PlotLineLabel)} method. Example usage:
|
||||
* <code><pre>
|
||||
* XAxis xAxis = chart.getXAxis();
|
||||
* xAxis.setPlotLines(
|
||||
* xAxis.createPlotLine()
|
||||
* .setColor("#CC0000")
|
||||
* .setValue(40)
|
||||
* .setPlotLineLabel(
|
||||
* new PlotLineLabel()
|
||||
* .setAlign(PlotLineLabel.LEFT)
|
||||
* .setX(20)
|
||||
* ),
|
||||
* xAxis.createPlotLine()
|
||||
* .setColor("#009900")
|
||||
* .setValue(60)
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class PlotLineLabel extends Configurable<PlotLineLabel> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported plot line label alignment types, which can be passed to methods
|
||||
* like {@link PlotLineLabel#setAlign(Align)} method.
|
||||
*/
|
||||
public enum Align {
|
||||
|
||||
/**
|
||||
* Align the label to the left of the plot band
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Align the label to the right of the plot band
|
||||
*/
|
||||
RIGHT("right"),
|
||||
|
||||
/**
|
||||
* Align the label on the center of the plot band
|
||||
*/
|
||||
CENTER("center");
|
||||
|
||||
private Align(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enumeration of supported plot line label text alignment types, which can be passed to methods
|
||||
* like {@link PlotLineLabel#setTextAlign(TextAlign)} method.
|
||||
*/
|
||||
public enum TextAlign {
|
||||
|
||||
/**
|
||||
* Left align the text within the label
|
||||
*/
|
||||
LEFT("left"),
|
||||
|
||||
/**
|
||||
* Right align the text within the label
|
||||
*/
|
||||
RIGHT("right"),
|
||||
|
||||
/**
|
||||
* Center the text within the label
|
||||
*/
|
||||
CENTER("center");
|
||||
|
||||
private TextAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of supported plot line label vertical alignment types, which can be passed to methods
|
||||
* like {@link PlotLineLabel#setVerticalAlign(PlotLineLabel.VerticalAlign)}.
|
||||
*/
|
||||
public enum VerticalAlign {
|
||||
|
||||
/**
|
||||
* Align the text at the top of the plot band
|
||||
*/
|
||||
TOP("top"),
|
||||
|
||||
/**
|
||||
* Align the text in the middle of the plot band
|
||||
*/
|
||||
MIDDLE("middle"),
|
||||
|
||||
/**
|
||||
* Align the text at the bottom of the plot band
|
||||
*/
|
||||
BOTTOM("bottom");
|
||||
|
||||
private VerticalAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'align' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("align", PlotLineLabel.Align.CENTER);
|
||||
* </code></pre>
|
||||
* Horizontal alignment of the label. Can be one of "left", "center" or "right". Defaults to "center".
|
||||
*
|
||||
* @param align The horizontal alignment of the label.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLineLabel setAlign(Align align) {
|
||||
return this.setOption("align", align != null ? align.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'rotation' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("rotation", 90.0f);
|
||||
* </code></pre>
|
||||
* Rotation of the text label in degrees. Defaults to 0 for horizontal plot lines and 90 for vertical lines.
|
||||
*
|
||||
* @param rotation Rotation of the text label in degrees.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLineLabel setRotation(Number rotation) {
|
||||
return this.setOption("rotation", rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'style' options of the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("/style/fontWeight", "bold");
|
||||
* plotLineLabel.setOption("/style/fontFamily", "serif");
|
||||
* etc.
|
||||
* </code></pre>
|
||||
*
|
||||
* @param style CSS styles for the text labels.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLineLabel setStyle(Style style) {
|
||||
return this.setOption("style", style != null ? style.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'text' option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("text", "Hi Mom!");
|
||||
* </code></pre>
|
||||
*
|
||||
* @param text The raw text to display as the label.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
* @since 1.1.1
|
||||
*/
|
||||
public PlotLineLabel setText(String text) {
|
||||
return this.setOption("text", text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'textAlign' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("textAlign", PlotLineLabel.TextAlign.RIGHT);
|
||||
* </code></pre>
|
||||
* The text alignment for the label. While <code>align</code> determines where the texts anchor point
|
||||
* is placed within the plot band, <code>textAlign</code> determines how the text is aligned against
|
||||
* its anchor point. Possible values are "left", "center" and "right".
|
||||
* Defaults to the same as the <code>align</code> option.
|
||||
*
|
||||
* @param textAlign The text alignment for the label.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLineLabel setTextAlign(TextAlign textAlign) {
|
||||
return this.setOption("textAlign", textAlign != null ? textAlign.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'verticalAlign' option for the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("verticalAlign", PlotLineLabel.VerticalAlign.TOP);
|
||||
* </code></pre>
|
||||
* Vertical alignment of the label relative to the plot band. Can be one of "top", "middle" or "bottom". Defaults to "top".
|
||||
*
|
||||
* @param verticalAlign The vertical alignment of the label relative to the plot band.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLineLabel setVerticalAlign(VerticalAlign verticalAlign) {
|
||||
return this.setOption("verticalAlign", verticalAlign != null ? verticalAlign.toString() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'x' position option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("x", 70);
|
||||
* </code></pre>
|
||||
* Horizontal position relative the alignment. Default varies by orientation.
|
||||
*
|
||||
* @param x The horizontal position relative the alignment.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLineLabel setX(Number x) {
|
||||
return this.setOption("x", x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'y' position option of the label. Equivalent to:
|
||||
* <pre><code>
|
||||
* plotLineLabel.setOption("y", -20);
|
||||
* </code></pre>
|
||||
* Vertical position of the text baseline relative to the alignment. Default varies by orientation.
|
||||
*
|
||||
* @param y The vertical position of the text baseline relative to the alignment.
|
||||
* @return A reference to this {@link PlotLineLabel} instance for convenient method chaining.
|
||||
*/
|
||||
public PlotLineLabel setY(Number y) {
|
||||
return this.setOption("y", y);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+129
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
/**
|
||||
* Represents the configuration options that can be set for the stack labels on the y-axis of a chart, and
|
||||
* can then be passed to the {@link org.moxieapps.gwt.highcharts.client.YAxis#setStackLabels(StackLabels)}
|
||||
* method. Example usage:
|
||||
* <code><pre>
|
||||
* chart.getYAxis().setStackLabels(
|
||||
* new StackLabels()
|
||||
* .setAlign(Labels.Align.LEFT)
|
||||
* .setColor("#CC0000")
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class StackLabels extends Labels<StackLabels> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported stack labels vertical alignment types, which can be passed to methods
|
||||
* like {@link StackLabels#setVerticalAlign(StackLabels.VerticalAlign)} method.
|
||||
*/
|
||||
public enum VerticalAlign {
|
||||
|
||||
/**
|
||||
* Show the labels at the top of the column
|
||||
*/
|
||||
TOP("top"),
|
||||
|
||||
/**
|
||||
* Show the labels in the middle of the column
|
||||
*/
|
||||
MIDDLE("middle"),
|
||||
|
||||
/**
|
||||
* Show the labels at the bottom of the column
|
||||
*/
|
||||
BOTTOM("bottom");
|
||||
|
||||
private VerticalAlign(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private StackLabelsFormatter stackLabelsFormatter;
|
||||
|
||||
/**
|
||||
* Sets a custom formatter for the stack labels on the axis that can be used to control how the text of the
|
||||
* stack labels will be displayed. See the {@link StackLabelsFormatter} interface, and
|
||||
* in particular the {@link StackLabelsFormatter#format(StackLabelsData)} method for more details on
|
||||
* the capabilities available to custom formatters.
|
||||
*
|
||||
* @param stackLabelsFormatter The custom formatter to use for the stack labels (if not given a built-in
|
||||
* generic formatter is used which simply returns the total value of the stack).
|
||||
* @return A reference to this {@link StackLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public StackLabels setFormatter(StackLabelsFormatter stackLabelsFormatter) {
|
||||
this.stackLabelsFormatter = stackLabelsFormatter;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the custom stack labels formatter that has been applied to the y-axis, or null if the
|
||||
* built-in generic formatter is being used instead.
|
||||
*
|
||||
* @return The custom axis labels formatter that has been applied to the y-axis, or null if it has not been set.
|
||||
*/
|
||||
public StackLabelsFormatter getFormatter() {
|
||||
return this.stackLabelsFormatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'textAlign' option for the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* stackLabels.setOption("textAlign", Labels.Align.CENTER);
|
||||
* </code></pre>
|
||||
* The text alignment for the label. While {@link StackLabels#setAlign(Align)} determines where the text's
|
||||
* anchor point is placed with regards to the stack, 'textAlign' determines how the text is aligned
|
||||
* against its anchor point. Possible values are "left", "center" and "right". The default value is
|
||||
* calculated at runtime and depends on orientation and whether the stack is positive or negative.
|
||||
*
|
||||
* @param textAlign The text alignment for the label.
|
||||
* @return A reference to this {@link StackLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public StackLabels setTextAlign(Align textAlign) {
|
||||
return this.setOption("textAlign", textAlign != null ? textAlign.toString() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'verticalAlign' option for the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* stackLabels.setOption("verticalAlign", StackLabels.VerticalAlign.MIDDLE);
|
||||
* </code></pre>
|
||||
* Defines the vertical alignment of the stack total label. Can be one of "top", "middle" or
|
||||
* "bottom". The default value is calculated at runtime and depends on orientation and whether
|
||||
* the stack is positive or negative.
|
||||
*
|
||||
* @param verticalAlign The vertical alignment of the stack total label.
|
||||
* @return A reference to this {@link StackLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public StackLabels setVerticalAlign(VerticalAlign verticalAlign) {
|
||||
return this.setOption("verticalAlign", verticalAlign != null ? verticalAlign.toString() : null);
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* An object that represents the state information that will be passed to any custom
|
||||
* {@link StackLabelsFormatter} to allow for custom strings to be rendered as the stack labels on a Y axis.
|
||||
* See the {@link StackLabelsFormatter#format(StackLabelsData)} method for more details on the capabilities
|
||||
* that custom formatters can provide.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class StackLabelsData {
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
private JavaScriptObject data;
|
||||
|
||||
/**
|
||||
* This constructor needs to be public scope but you should not construct this object directly, but
|
||||
* instead simply implement a custom {@link StackLabelsFormatter} and this API will pass you the
|
||||
* appropriate instance of this object at runtime.
|
||||
*
|
||||
* @param data A reference to the native Highcharts javascript object.
|
||||
*/
|
||||
public StackLabelsData(JavaScriptObject data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total value at this point's x value. Stacked series only.
|
||||
*
|
||||
* @return The total value at this point's x value (only applicable in stacked series).
|
||||
*/
|
||||
public native double getTotal() /*-{
|
||||
return this.@org.moxieapps.gwt.highcharts.client.labels.StackLabelsData::data.total;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Return the total value at this point's x value as a long. Stacked series only.
|
||||
*
|
||||
* @return Return the total value at this point's x value as a long.
|
||||
*/
|
||||
public long getTotalAsLong() {
|
||||
return ((Double)getTotal()).longValue();
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
/**
|
||||
* An interface that can be used to control the display of the Y axis stack labels to contain
|
||||
* custom text or formatting. General usage is as follows:
|
||||
* <code><pre>
|
||||
* chart.getYAxis().setLabels(
|
||||
* new YAxisLabels()
|
||||
* .setFormatter(new StackLabelsFormatter() {
|
||||
* public String format(StackLabelsData stackLabelsData) {
|
||||
* return stackLabelsData.getValueAsLong() + " degrees";
|
||||
* }
|
||||
* })
|
||||
* );
|
||||
* </pre></code>
|
||||
* See the documentation on the {@link #format(StackLabelsData)} function for more details on the
|
||||
* capabilities available within custom formatters.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface StackLabelsFormatter {
|
||||
|
||||
/**
|
||||
* Callback function to format the text of a stack label on a Y axis.
|
||||
* <p/>
|
||||
* A subset of HTML is supported. The HTML of the label is parsed and converted to SVG, therefore
|
||||
* this isn't a complete HTML renderer. The following tags are supported: <b>, <strong>, <i>,
|
||||
* <em>, <br/>, and <span>. Spans can be styled with a style attribute, but only text-related
|
||||
* CSS that is shared with SVG is handled.
|
||||
* <p/>
|
||||
* Available data provided in the given "StackLabelsData" object are:
|
||||
* <ul>
|
||||
* <li>
|
||||
* <b>total</b> : The total value of the stack at this point.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param stackLabelsData An object containing all of the data available to the formatter that it can
|
||||
* use to determine which text and styling to use for the label.
|
||||
* @return The text to display for the label (including any styling).
|
||||
*/
|
||||
public String format(StackLabelsData stackLabelsData);
|
||||
|
||||
}
|
||||
Executable
+93
@@ -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.labels;
|
||||
|
||||
/**
|
||||
* Represents the configuration options that can be set for the labels on the x-axis of a chart, and
|
||||
* can then be passed to the {@link org.moxieapps.gwt.highcharts.client.XAxis#setLabels(org.moxieapps.gwt.highcharts.client.labels.XAxisLabels)}
|
||||
* method. Example usage:
|
||||
* <code><pre>
|
||||
* chart.getXAxis().setLabels(
|
||||
* new XAxisLabels()
|
||||
* .setAlign(Labels.Align.LEFT)
|
||||
* .setColor("#CC0000")
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class XAxisLabels extends Labels<XAxisLabels> {
|
||||
|
||||
private AxisLabelsFormatter axisLabelsFormatter;
|
||||
|
||||
/**
|
||||
* Sets a custom formatter for the labels on the axis that can be used to control how the text of the
|
||||
* labels will be displayed. See the {@link AxisLabelsFormatter} interface, and
|
||||
* in particular the {@link AxisLabelsFormatter#format(AxisLabelsData)} method for more details on
|
||||
* the capabilities available to custom formatters.
|
||||
*
|
||||
* @param axisLabelsFormatter The custom formatter to use for the labels (if not given a built-in
|
||||
* generic formatter is used which simply returns the value as a string).
|
||||
* @return A reference to this {@link XAxisLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public XAxisLabels setFormatter(AxisLabelsFormatter axisLabelsFormatter) {
|
||||
this.axisLabelsFormatter = axisLabelsFormatter;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the custom axis labels formatter that has been applied to the x-axis, or null if the
|
||||
* built-in generic formatter is being used instead.
|
||||
*
|
||||
* @return The custom axis labels formatter that has been applied to the x-axis, or null if it has not been set.
|
||||
*/
|
||||
public AxisLabelsFormatter getFormatter() {
|
||||
return this.axisLabelsFormatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'staggerLines' option for the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* xAxisLabels.setOption("staggerLines", 2);
|
||||
* </code></pre>
|
||||
* Horizontal axes only. The number of lines to spread the labels over to make room or tighter labels. Defaults to null.
|
||||
*
|
||||
* @param staggerLines The number of lines to spread the labels over to make room or tighter labels.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.XAxisLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public XAxisLabels setStaggerLines(Number staggerLines) {
|
||||
return this.setOption("staggerLines", staggerLines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'step' option for the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* xAxisLabels.setOption("step", 2);
|
||||
* </code></pre>
|
||||
* To show only every n'th label on the axis, set the step to n. E.g. - setting the step to
|
||||
* 2 shows every other label. Defaults to null.
|
||||
*
|
||||
* @param step o show only every n'th label on the axis, set the step to n.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.XAxisLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public XAxisLabels setStep(Number step) {
|
||||
return this.setOption("step", step);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.labels;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the configuration options that can be set for the labels on the x-axis of a chart, and
|
||||
* can then be passed to the {@link org.moxieapps.gwt.highcharts.client.YAxis#setLabels(org.moxieapps.gwt.highcharts.client.labels.YAxisLabels)}
|
||||
* method. Example usage:
|
||||
* <code><pre>
|
||||
* chart.getYAxis().setLabels(
|
||||
* new YAxisLabels()
|
||||
* .setAlign(Labels.Align.LEFT)
|
||||
* .setColor("#CC0000")
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class YAxisLabels extends Labels<YAxisLabels> {
|
||||
|
||||
private AxisLabelsFormatter axisLabelsFormatter;
|
||||
|
||||
/**
|
||||
* Sets a custom formatter for the labels on the axis that can be used to control how the text of the
|
||||
* labels will be displayed. See the {@link AxisLabelsFormatter} interface, and
|
||||
* in particular the {@link AxisLabelsFormatter#format(AxisLabelsData)} method for more details on
|
||||
* the capabilities available to custom formatters.
|
||||
*
|
||||
* @param axisLabelsFormatter The custom formatter to use for the labels (if not given a built-in
|
||||
* generic formatter is used which simply returns the value as a string).
|
||||
* @return A reference to this {@link YAxisLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public YAxisLabels setFormatter(AxisLabelsFormatter axisLabelsFormatter) {
|
||||
this.axisLabelsFormatter = axisLabelsFormatter;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the custom axis labels formatter that has been applied to the y-axis, or null if the
|
||||
* built-in generic formatter is being used instead.
|
||||
*
|
||||
* @return The custom axis labels formatter that has been applied to the y-axis, or null if it has not been set.
|
||||
*/
|
||||
public AxisLabelsFormatter getFormatter() {
|
||||
return this.axisLabelsFormatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'step' option for the labels. Equivalent to:
|
||||
* <pre><code>
|
||||
* yAxisLabels.setOption("step", 2);
|
||||
* </code></pre>
|
||||
* To show only every n'th label on the axis, set the step to n. E.g. - setting the step to
|
||||
* 2 shows every other label. Defaults to null.
|
||||
*
|
||||
* @param step o show only every n'th label on the axis, set the step to n.
|
||||
* @return A reference to this {@link org.moxieapps.gwt.highcharts.client.labels.YAxisLabels} instance for convenient method chaining.
|
||||
*/
|
||||
public YAxisLabels setStep(Number step) {
|
||||
return this.setOption("step", step);
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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.plotOptions;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Chart;
|
||||
import org.moxieapps.gwt.highcharts.client.Color;
|
||||
import org.moxieapps.gwt.highcharts.client.Series;
|
||||
|
||||
/**
|
||||
* Represents the general plot options available for all area type series, which can be set either generically
|
||||
* on the chart via the {@link Chart#setAreaPlotOptions(AreaPlotOptions)} )} method or directly on a
|
||||
* series via the {@link Series#setPlotOptions(PlotOptions)} method.
|
||||
* <p/>
|
||||
* Note that these options are only needed if you want to specifically control the general options
|
||||
* for all area type series in the entire chart. If you instead want to control the options for all
|
||||
* series in the chart (not just those of an area type), then you can use the {@link SeriesPlotOptions}
|
||||
* class instead. Or, if you want to control the plot options for just one series (and not all area type
|
||||
* series in the chart), use the {@link org.moxieapps.gwt.highcharts.client.Series#setPlotOptions(PlotOptions)} method.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AreaPlotOptions extends PlotOptions<AreaPlotOptions> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillColor' option of the area plot options
|
||||
* to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaPlotOptions.setOption("fillColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* Fill color or gradient for the area. When null, the series' color is used with the series' fillOpacity. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setFillColor(Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param fillColor The value to set as the 'fillColor' option of the area plots.
|
||||
* @return A reference to this {@link AreaPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaPlotOptions setFillColor(String fillColor) {
|
||||
return this.setOption("fillColor", fillColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillColor' option of the area plot options, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaPlotOptions.setOption("fillColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* Fill color or gradient for the area. When null, the series' color is used with the series' fillOpacity. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setFillColor(String)} version instead.
|
||||
*
|
||||
* @param fillColor The color gradient or color with an alpha channel to set as the 'fillColor' option of the area plot.
|
||||
* @return A reference to this {@link AreaPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaPlotOptions setFillColor(Color fillColor) {
|
||||
return this.setOption("fillColor", fillColor != null ? fillColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillOpacity' option of the area plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaPlotOptions.setOption("fillOpacity", 0.5);
|
||||
* </code></pre>
|
||||
* Fill opacity for the area. Defaults to .75.
|
||||
*
|
||||
* @param fillOpacity Fill opacity for the area.
|
||||
* @return A reference to this {@link AreaPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaPlotOptions setFillOpacity(Number fillOpacity) {
|
||||
return this.setOption("fillOpacity", fillOpacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'lineColor' option of the area plot options to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaPlotOptions.setOption("lineColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* A separate color for the graph line. By default the line takes the color of the series, but the
|
||||
* lineColor setting allows setting a separate color for the line without altering the fillColor. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setLineColor(Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param lineColor The value to set as the 'lineColor' option of the area plots.
|
||||
* @return A reference to this {@link AreaPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaPlotOptions setLineColor(String lineColor) {
|
||||
return this.setOption("lineColor", lineColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'lineColor' option of the area plot options, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaPlotOptions.setOption("lineColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* A separate color for the graph line. By default the line takes the color of the series, but the
|
||||
* lineColor setting allows setting a separate color for the line without altering the fillColor. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setLineColor(String)} version instead.
|
||||
*
|
||||
* @param lineColor The color gradient or color with an alpha channel to set as the 'lineColor' option of the area plots.
|
||||
* @return A reference to this {@link AreaPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaPlotOptions setLineColor(Color lineColor) {
|
||||
return this.setOption("lineColor", lineColor != null ? lineColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'threshold' option of the area plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaPlotOptions.setOption("threshold", 0.5);
|
||||
* </code></pre>
|
||||
* The Y axis value to serve as the base for the area, for distinguishing between values above and
|
||||
* below a threshold. Defaults to 0.
|
||||
*
|
||||
* @param threshold The Y axis value to serve as the base for the area, for distinguishing between
|
||||
* values above and below a threshold.
|
||||
* @return A reference to this {@link AreaPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaPlotOptions setThreshold(String threshold) {
|
||||
return this.setOption("threshold", threshold);
|
||||
}
|
||||
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* 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.plotOptions;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Chart;
|
||||
import org.moxieapps.gwt.highcharts.client.Color;
|
||||
import org.moxieapps.gwt.highcharts.client.Series;
|
||||
|
||||
/**
|
||||
* Represents the general plot options available for all area spline type series, which can be set either generically
|
||||
* on the chart via the {@link Chart#setAreaSplinePlotOptions(AreaSplinePlotOptions)} )} method or directly on a
|
||||
* series via the {@link Series#setPlotOptions(PlotOptions)} method.
|
||||
* <p/>
|
||||
* Note that these options are only needed if you want to specifically control the general options
|
||||
* for all area spline type series in the entire chart. If you instead want to control the options for all
|
||||
* series in the chart (not just those of an area spline type), then you can use the {@link SeriesPlotOptions}
|
||||
* class instead. Or, if you want to control the plot options for just one series (and not all area spline type
|
||||
* series in the chart), use the {@link org.moxieapps.gwt.highcharts.client.Series#setPlotOptions(PlotOptions)} method.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class AreaSplinePlotOptions extends PlotOptions<AreaSplinePlotOptions> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillColor' option of the area plot options
|
||||
* to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaSplinePlotOptions.setOption("fillColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* Fill color or gradient for the area. When null, the series' color is used with the series' fillOpacity. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setFillColor(org.moxieapps.gwt.highcharts.client.Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param fillColor The value to set as the 'fillColor' option of the area plots.
|
||||
* @return A reference to this {@link AreaSplinePlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaSplinePlotOptions setFillColor(String fillColor) {
|
||||
return this.setOption("fillColor", fillColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillColor' option of the area plot options, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaSplinePlotOptions.setOption("fillColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* Fill color or gradient for the area. When null, the series' color is used with the series' fillOpacity. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setFillColor(String)} version instead.
|
||||
*
|
||||
* @param fillColor The color gradient or color with an alpha channel to set as the 'fillColor' option of the area plot.
|
||||
* @return A reference to this {@link AreaSplinePlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaSplinePlotOptions setFillColor(Color fillColor) {
|
||||
return this.setOption("fillColor", fillColor != null ? fillColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillOpacity' option of the area plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaSplinePlotOptions.setOption("fillOpacity", 0.5);
|
||||
* </code></pre>
|
||||
* Fill opacity for the area. Defaults to .75.
|
||||
*
|
||||
* @param fillOpacity Fill opacity for the area.
|
||||
* @return A reference to this {@link AreaSplinePlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaSplinePlotOptions setFillOpacity(Number fillOpacity) {
|
||||
return this.setOption("fillOpacity", fillOpacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'lineColor' option of the area plot options to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaSplinePlotOptions.setOption("lineColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* A separate color for the graph line. By default the line takes the color of the series, but the
|
||||
* lineColor setting allows setting a separate color for the line without altering the fillColor. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setLineColor(Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param lineColor The value to set as the 'lineColor' option of the area plots.
|
||||
* @return A reference to this {@link AreaSplinePlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaSplinePlotOptions setLineColor(String lineColor) {
|
||||
return this.setOption("lineColor", lineColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'lineColor' option of the area plot options, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaSplinePlotOptions.setOption("lineColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* A separate color for the graph line. By default the line takes the color of the series, but the
|
||||
* lineColor setting allows setting a separate color for the line without altering the fillColor. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setLineColor(String)} version instead.
|
||||
*
|
||||
* @param lineColor The color gradient or color with an alpha channel to set as the 'lineColor' option of the area plots.
|
||||
* @return A reference to this {@link AreaSplinePlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaSplinePlotOptions setLineColor(Color lineColor) {
|
||||
return this.setOption("lineColor", lineColor != null ? lineColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'threshold' option of the area plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* areaSplinePlotOptions.setOption("threshold", 0.5);
|
||||
* </code></pre>
|
||||
* The Y axis value to serve as the base for the area, for distinguishing between values above and
|
||||
* below a threshold. Defaults to 0.
|
||||
*
|
||||
* @param threshold The Y axis value to serve as the base for the area, for distinguishing between
|
||||
* values above and below a threshold.
|
||||
* @return A reference to this {@link AreaSplinePlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public AreaSplinePlotOptions setThreshold(String threshold) {
|
||||
return this.setOption("threshold", threshold);
|
||||
}
|
||||
|
||||
}
|
||||
+194
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* 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.plotOptions;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Chart;
|
||||
import org.moxieapps.gwt.highcharts.client.Color;
|
||||
import org.moxieapps.gwt.highcharts.client.Series;
|
||||
|
||||
/**
|
||||
* Represents the general plot options available for all bar type series, which can be set either generically
|
||||
* on the chart via the {@link Chart#setBarPlotOptions(BarPlotOptions)} )} method or directly on a
|
||||
* series via the {@link Series#setPlotOptions(PlotOptions)} method.
|
||||
* <p/>
|
||||
* Note that these options are only needed if you want to specifically control the general options
|
||||
* for all bar type series in the entire chart. If you instead want to control the options for all
|
||||
* series in the chart (not just those of a bar type), then you can use the {@link SeriesPlotOptions}
|
||||
* class instead. Or, if you want to control the plot options for just one series (and not all bar type
|
||||
* series in the chart), use the {@link org.moxieapps.gwt.highcharts.client.Series#setPlotOptions(PlotOptions)} method.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class BarPlotOptions extends PlotOptions<BarPlotOptions> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderColor' option of the bar plot options
|
||||
* to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("borderColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The color of the border surrounding each column or bar. Defaults to "#FFFFFF".
|
||||
* <p/>
|
||||
* 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(org.moxieapps.gwt.highcharts.client.Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param borderColor The value to set as the 'borderColor' option of the bar plots.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setBorderColor(String borderColor) {
|
||||
return this.setOption("borderColor", borderColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderColor' option of the bar plot options, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("borderColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* The color of the border surrounding each column or bar. Defaults to "#FFFFFF".
|
||||
* <p/>
|
||||
* 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 of the area plot.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setBorderColor(Color borderColor) {
|
||||
return this.setOption("borderColor", borderColor != null ? borderColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderRadius' option of the bar plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("borderRadius", 4);
|
||||
* </code></pre>
|
||||
* The corner radius of the border surrounding each column or bar. Defaults to 0.
|
||||
*
|
||||
* @param borderRadius The corner radius of the border surrounding each column or bar.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setBorderRadius(Number borderRadius) {
|
||||
return this.setOption("borderRadius", borderRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderWidth' option of the bar plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("borderWidth", 4);
|
||||
* </code></pre>
|
||||
* The width of the border surrounding each column or bar. Defaults to 1.
|
||||
*
|
||||
* @param borderWidth The width of the border surrounding each column or bar.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setBorderWidth(Number borderWidth) {
|
||||
return this.setOption("borderWidth", borderWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'colorByPoint' option of the bar plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("colorByPoint", true);
|
||||
* </code></pre>
|
||||
* When using automatic point colors pulled from the options.colors collection, this option determines
|
||||
* whether the chart should receive one color per series or one color per point. Defaults to false.
|
||||
*
|
||||
* TODO: Fix javadoc reference to "options.colors".
|
||||
*
|
||||
* @param colorByPoint Whether the chart should receive one color per series or one color per point.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setColorByPoint(boolean colorByPoint) {
|
||||
return this.setOption("colorByPoint", colorByPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'groupPadding' option of the bar plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("groupPadding", 4);
|
||||
* </code></pre>
|
||||
* Padding between each value groups, in x axis units. Defaults to 0.2.
|
||||
*
|
||||
* @param groupPadding Padding between each value groups, in x axis units.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setGroupPadding(Number groupPadding) {
|
||||
return this.setOption("groupPadding", groupPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'minPointLength' option of the bar plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("minPointLength", 4);
|
||||
* </code></pre>
|
||||
* The minimal height for a column or width for a bar. By default, 0 values are not shown. To visualize
|
||||
* a 0 (or close to zero) point, set the minimal point length to a pixel value like 3. In stacked column
|
||||
* charts, minPointLength might not be respected for tightly packed values. Defaults to 0.
|
||||
*
|
||||
* @param minPointLength The minimal height for a column or width for a bar.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setMinPointLength(Number minPointLength) {
|
||||
return this.setOption("minPointLength", minPointLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'pointPadding' option of the bar plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("pointPadding", 0.5);
|
||||
* </code></pre>
|
||||
* Padding between each column or bar, in x axis units. Defaults to 0.1.
|
||||
*
|
||||
* @param pointPadding Padding between each column or bar, in x axis units.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setPointPadding(Number pointPadding) {
|
||||
return this.setOption("pointPadding", pointPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'pointWidth' option of the bar plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* barPlotOptions.setOption("pointWidth", 2.0);
|
||||
* </code></pre>
|
||||
* A pixel value specifying a fixed width for each column or bar. When null, the width is calculated
|
||||
* from the {@link #setPointPadding(Number)} and {@link #setGroupPadding(Number)}. Defaults to null.
|
||||
*
|
||||
* @param pointWidth A pixel value specifying a fixed width for each column or bar.
|
||||
* @return A reference to this {@link BarPlotOptions} instance for convenient method chaining.
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public BarPlotOptions setPointWidth(Number pointWidth) {
|
||||
return this.setOption("pointWidth", pointWidth);
|
||||
}
|
||||
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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.plotOptions;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Chart;
|
||||
import org.moxieapps.gwt.highcharts.client.Color;
|
||||
import org.moxieapps.gwt.highcharts.client.Series;
|
||||
|
||||
/**
|
||||
* Represents the general plot options available for all column type series, which can be set either generically
|
||||
* on the chart via the {@link Chart#setColumnPlotOptions(ColumnPlotOptions)} )} method or directly on a
|
||||
* series via the {@link Series#setPlotOptions(PlotOptions)} method.
|
||||
* <p/>
|
||||
* Note that these options are only needed if you want to specifically control the general options
|
||||
* for all column type series in the entire chart. If you instead want to control the options for all
|
||||
* series in the chart (not just those of a column type), then you can use the {@link SeriesPlotOptions}
|
||||
* class instead. Or, if you want to control the plot options for just one series (and not all column type
|
||||
* series in the chart), use the {@link org.moxieapps.gwt.highcharts.client.Series#setPlotOptions(PlotOptions)} method.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ColumnPlotOptions extends PlotOptions<ColumnPlotOptions> {
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderColor' option of the column plot options
|
||||
* to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("borderColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The color of the border surrounding each column or bar. Defaults to "#FFFFFF".
|
||||
* <p/>
|
||||
* 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 of the column plots.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setBorderColor(String borderColor) {
|
||||
return this.setOption("borderColor", borderColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderColor' option of the column plot options, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("borderColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* The color of the border surrounding each column or bar. Defaults to "#FFFFFF".
|
||||
* <p/>
|
||||
* 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 of the area plot.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setBorderColor(Color borderColor) {
|
||||
return this.setOption("borderColor", borderColor != null ? borderColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderRadius' option of the column plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("borderRadius", 4);
|
||||
* </code></pre>
|
||||
* The corner radius of the border surrounding each column or bar. Defaults to 0.
|
||||
*
|
||||
* @param borderRadius The corner radius of the border surrounding each column or bar.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setBorderRadius(Number borderRadius) {
|
||||
return this.setOption("borderRadius", borderRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'borderWidth' option of the column plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("borderWidth", 4);
|
||||
* </code></pre>
|
||||
* The width of the border surrounding each column or bar. Defaults to 1.
|
||||
*
|
||||
* @param borderWidth The width of the border surrounding each column or bar.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setBorderWidth(Number borderWidth) {
|
||||
return this.setOption("borderWidth", borderWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'colorByPoint' option of the column plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("colorByPoint", true);
|
||||
* </code></pre>
|
||||
* When using automatic point colors pulled from the options.colors collection, this option determines
|
||||
* whether the chart should receive one color per series or one color per point. Defaults to false.
|
||||
*
|
||||
* TODO: Fix javadoc reference to "options.colors".
|
||||
*
|
||||
* @param colorByPoint Whether the chart should receive one color per series or one color per point.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setColorByPoint(boolean colorByPoint) {
|
||||
return this.setOption("colorByPoint", colorByPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'groupPadding' option of the column plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("groupPadding", 4);
|
||||
* </code></pre>
|
||||
* Padding between each value groups, in x axis units. Defaults to 0.2.
|
||||
*
|
||||
* @param groupPadding Padding between each value groups, in x axis units.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setGroupPadding(Number groupPadding) {
|
||||
return this.setOption("groupPadding", groupPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'minPointLength' option of the column plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("minPointLength", 4);
|
||||
* </code></pre>
|
||||
* The minimal height for a column or width for a bar. By default, 0 values are not shown. To visualize
|
||||
* a 0 (or close to zero) point, set the minimal point length to a pixel value like 3. In stacked column
|
||||
* charts, minPointLength might not be respected for tightly packed values. Defaults to 0.
|
||||
*
|
||||
* @param minPointLength The minimal height for a column or width for a bar.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setMinPointLength(Number minPointLength) {
|
||||
return this.setOption("minPointLength", minPointLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'pointPadding' option of the column plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("pointPadding", 0.5);
|
||||
* </code></pre>
|
||||
* Padding between each column or bar, in x axis units. Defaults to 0.1.
|
||||
*
|
||||
* @param pointPadding Padding between each column or bar, in x axis units.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setPointPadding(Number pointPadding) {
|
||||
return this.setOption("pointPadding", pointPadding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'pointWidth' option of the column plot options. Equivalent to:
|
||||
* <pre><code>
|
||||
* columnPlotOptions.setOption("pointWidth", 2.0);
|
||||
* </code></pre>
|
||||
* A pixel value specifying a fixed width for each column or bar. When null, the width is calculated
|
||||
* from the {@link #setPointPadding(Number)} and {@link #setGroupPadding(Number)}. Defaults to null.
|
||||
*
|
||||
* @param pointWidth A pixel value specifying a fixed width for each column or bar.
|
||||
* @return A reference to this {@link ColumnPlotOptions} instance for convenient method chaining.
|
||||
*/
|
||||
public ColumnPlotOptions setPointWidth(Number pointWidth) {
|
||||
return this.setOption("pointWidth", pointWidth);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.plotOptions;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Chart;
|
||||
import org.moxieapps.gwt.highcharts.client.Series;
|
||||
|
||||
/**
|
||||
* Represents the general plot options available for all line type series, which can be set either generically
|
||||
* on the chart via the {@link Chart#setLinePlotOptions(LinePlotOptions)} )} method or directly on a
|
||||
* series via the {@link Series#setPlotOptions(PlotOptions)} method.
|
||||
* <p/>
|
||||
* Note that these options are only needed if you want to specifically control the general options
|
||||
* for all line type series in the entire chart. If you instead want to control the options for all
|
||||
* series in the chart (not just those of a line type), then you can use the {@link SeriesPlotOptions}
|
||||
* class instead. Or, if you want to control the plot options for just one series (and not all line type
|
||||
* series in the chart), use the {@link Series#setPlotOptions(PlotOptions)} method.
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LinePlotOptions extends PlotOptions<LinePlotOptions> {
|
||||
|
||||
// TODO:
|
||||
|
||||
}
|
||||
Executable
+257
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* 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.plotOptions;
|
||||
|
||||
import org.moxieapps.gwt.highcharts.client.Color;
|
||||
import org.moxieapps.gwt.highcharts.client.Configurable;
|
||||
|
||||
/**
|
||||
* Controls configuration options for the markers within a series. Can be set as a plot option on a series
|
||||
* via the {@link PlotOptions#setMarker(Marker)} method. Example usage:
|
||||
* <code><pre>
|
||||
* chart.setPlotOptions(new PlotOptions()
|
||||
* .setMarker(
|
||||
* new Marker()
|
||||
* .setEnabled(true)
|
||||
* .setFillColor("#CC0000")
|
||||
* .setRadius(4)
|
||||
* )
|
||||
* );
|
||||
* </pre></code>
|
||||
*
|
||||
* @author squinn@moxiegroup.com (Shawn Quinn)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class Marker extends Configurable<Marker> {
|
||||
|
||||
/**
|
||||
* An enumeration of supported marker symbol types, which can be passed to methods
|
||||
* like {@link Marker#setSymbol(Marker.Symbol)} method.
|
||||
*/
|
||||
public enum Symbol {
|
||||
|
||||
/**
|
||||
* Represent the marker with a circular shape
|
||||
*/
|
||||
CIRCLE("circle"),
|
||||
|
||||
/**
|
||||
* Represent the marker with a square shape
|
||||
*/
|
||||
SQUARE("square"),
|
||||
|
||||
/**
|
||||
* Represent the marker with a diamond shape
|
||||
*/
|
||||
DIAMOND("diamond"),
|
||||
|
||||
/**
|
||||
* Represent the marker with a triangular shape
|
||||
*/
|
||||
TRIANGLE("triangle"),
|
||||
|
||||
/**
|
||||
* Represent the marker with an upside down triangular shape
|
||||
*/
|
||||
TRIANGLE_DOWN("triangle-down");
|
||||
|
||||
private Symbol(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
}
|
||||
|
||||
private final String optionValue;
|
||||
|
||||
public String toString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'enabled' option for the markers. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("enabled", true);
|
||||
* </code></pre>
|
||||
* Enable or disable the point marker. Defaults to true.
|
||||
*
|
||||
* @param enabled Enable or disable the point marker.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setEnabled(boolean enabled) {
|
||||
return this.setOption("enabled", enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillColor' option of the markers to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("fillColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The fill color of the point marker. When null, the series' or point's color is used. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setFillColor(Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param fillColor The value to set as the 'fillColor' option of the markers.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setFillColor(String fillColor) {
|
||||
return this.setOption("fillColor", fillColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'fillColor' option of the markers, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("fillColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* The fill color of the point marker. When null, the series' or point's color is used. Defaults to null.
|
||||
* <p/>
|
||||
* 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 #setFillColor(String)} version instead.
|
||||
*
|
||||
* @param fillColor The color gradient or color with an alpha channel to set as the 'fillColor' option of the markers.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setFillColor(Color fillColor) {
|
||||
return this.setOption("fillColor", fillColor != null ? fillColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'lineColor' option of the markers to a RGB hex value. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("lineColor", "#CCCCCC");
|
||||
* </code></pre>
|
||||
* The color of the point marker's outline. When null, the series' or point's color is used. Defaults to "#FFFFFF".
|
||||
* <p/>
|
||||
* 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 #setLineColor(Color)}
|
||||
* version instead.
|
||||
*
|
||||
* @param lineColor The value to set as the 'lineColor' option of the markers.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setLineColor(String lineColor) {
|
||||
return this.setOption("lineColor", lineColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'lineColor' option of the markers, allowing for
|
||||
* colors with opacity or gradients. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("lineColor", new Color()
|
||||
* .setLinearGradient(0.0, 0.0, 1.0, 1.0)
|
||||
* .addStop(new Color(255, 255, 255))
|
||||
* .addStop(new Color(200, 200, 255))
|
||||
* );
|
||||
* </code></pre>
|
||||
* The color of the point marker's outline. When null, the series' or point's color is used. Defaults to "#FFFFFF".
|
||||
* <p/>
|
||||
* 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 #setLineColor(String)} version instead.
|
||||
*
|
||||
* @param lineColor The color gradient or color with an alpha channel to set as the 'lineColor' option of the markers.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setLineColor(Color lineColor) {
|
||||
return this.setOption("lineColor", lineColor != null ? lineColor.getOptionValue() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'lineWidth' option for the markers. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("lineWidth", 4);
|
||||
* </code></pre>
|
||||
* The width of the point marker's outline. Defaults to 0.
|
||||
*
|
||||
* @param lineWidth The width of the point marker's outline.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setLineWidth(Number lineWidth) {
|
||||
return this.setOption("lineWidth", lineWidth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'radius' option for the markers. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("radius", 4);
|
||||
* </code></pre>
|
||||
* The radius of the point marker. Defaults to 0.
|
||||
*
|
||||
* @param radius The radius of the point marker.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setRadius(Number radius) {
|
||||
return this.setOption("radius", radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the configuration options for the hovered point marker. Members are inherited
|
||||
* from the default line configuration, but single members can be overridden. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("/states/hover/enabled", true);
|
||||
* marker.setOption("/states/hover/radius", 8);
|
||||
* ...
|
||||
* </code></pre>
|
||||
*
|
||||
* @param hoverState The configuration options to use for the markers on mouse hover.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setHoverState(Marker hoverState) {
|
||||
return this.setOption("/states/hover", hoverState != null ? hoverState.getOptions() : null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the configuration options for the selected point marker. Members are inherited
|
||||
* from the default line configuration, but single members can be overridden. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("/states/select/enabled", true);
|
||||
* marker.setOption("/states/select/radius", 8);
|
||||
* ...
|
||||
* </code></pre>
|
||||
*
|
||||
* @param selectState The configuration options to use for the markers when selected.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setSelectState(Marker selectState) {
|
||||
return this.setOption("/states/select", selectState != null ? selectState.getOptions() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for setting the 'symbol' option for the markers. Equivalent to:
|
||||
* <pre><code>
|
||||
* marker.setOption("symbol", Marker.Symbol.DIAMOND);
|
||||
* </code></pre>
|
||||
* A predefined shape or symbol for the marker. When null, the symbol is pulled from the default
|
||||
* {@link org.moxieapps.gwt.highcharts.client.Chart#setSymbols(org.moxieapps.gwt.highcharts.client.plotOptions.Marker.Symbol[])}
|
||||
* options. Defaults to null.
|
||||
*
|
||||
* @param symbol The shape or symbol for the marker.
|
||||
* @return A reference to this {@link Marker} instance for convenient method chaining.
|
||||
*/
|
||||
public Marker setSymbol(Symbol symbol) {
|
||||
return this.setOption("symbol", symbol != null ? symbol.toString() : null);
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 105 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user