public class D3
extends com.google.gwt.core.client.JavaScriptObject
select(Element)
methods and Selection
- manipulate elements in the current document.
Array
and Arrays
classes.
Array
and Arrays
classes.
Interpolators
.
Modifier and Type | Field and Description |
---|---|
static Scales |
scale
The scale factory module.
|
Modifier | Constructor and Description |
---|---|
protected |
D3() |
Modifier and Type | Method and Description |
---|---|
static Behavior |
behavior() |
static <T> Dsv<T> |
csv() |
static <T> Dsv<T> |
csv(String url)
Issues an HTTP GET request for the comma-separated values (CSV) file at
the specified url.
|
static <T> Dsv<T> |
csv(String url,
DsvCallback<T> callback)
Issues an HTTP GET request for the comma-separated values (CSV) file at
the specified url.
|
static <T> Dsv<T> |
csv(String url,
DsvObjectAccessor<T> accessor)
Issues an HTTP GET request for the comma-separated values (CSV) file at
the specified url.
|
static <T> Dsv<T> |
csv(String url,
DsvObjectAccessor<T> accessor,
DsvCallback<T> callback)
Issues an HTTP GET request for the comma-separated values (CSV) file at
the specified url.
|
static Drag.DragEvent |
dragEvent()
Get the DragEvent from within a
Drag listener. |
static <T extends com.google.gwt.user.client.Event> |
event()
Retrieve the current event, if any.
|
static Coords |
eventAsCoords()
Retrieve the current event if any, as a
Coords object containing
the x and y of the mouse. |
static Coords |
eventAsDCoords()
Retrieve the current event if any, as a
Coords object containing
the dx and dy representing the element's coordinates relative to its
position at the beginning of the gesture. |
static Formatter |
format(String specifier)
Returns a new
Formatter function with the given string specifier. |
static Prefix |
formatPrefix(double value,
double precision)
Return the SI Prefix for the specified value at the specified precision.
|
static Geography |
geo() |
static Geometry |
geom() |
static com.google.gwt.core.client.JavaScriptObject |
identity()
Return the identity function:
function(d) { return d; } |
static <T> Array<String> |
keys(com.google.gwt.core.client.JavaScriptObject object)
Returns an array containing the property names of the specified object (an associative array).
|
static Layout |
layout() |
static com.google.gwt.core.client.JsArrayNumber |
mouse(com.google.gwt.dom.client.Node container)
Returns the x and y coordinates of the current d3.event, relative to the
specified container.
|
static Coords |
mouseAsCoords(com.google.gwt.dom.client.Node container)
Returns the x and y coordinates of the current d3.event, relative to the
specified container.
|
static double |
mouseX(com.google.gwt.dom.client.Node container)
Returns the x coordinate of the current d3.event, relative to the
specified container.
|
static double |
mouseY(com.google.gwt.dom.client.Node container)
Returns the y coordinate of the current d3.event, relative to the
specified container.
|
static String |
requote(String string)
Returns a quoted (escaped) version of the specified string such that the
string may be embedded in a regular expression as a string literal.
|
static double |
round(double value,
int digits)
Returns the value x rounded to n digits after the decimal point.
|
static Selection |
select(com.google.gwt.dom.client.Element element)
Selects the specified element.
|
static Selection |
select(String selector)
Selects the first element that matches the specified selector string,
returning a single-element selection.
|
static Selection |
select(com.google.gwt.user.client.ui.Widget widget)
Selects the specified widget.
|
static Selection |
selectAll(Array<com.google.gwt.dom.client.Element> nodes)
Selects the specified array of elements.
|
static Selection |
selectAll(Collection<com.google.gwt.dom.client.Element> nodes)
Selects the specified collection of elements.
|
static Selection |
selectAll(com.google.gwt.dom.client.Element... nodes)
Selects the specified array of elements.
|
static Selection |
selectAll(com.google.gwt.dom.client.NodeList<?> nodes)
Selects the list of elements.
|
static Selection |
selectAll(String selector)
Selects all elements that match the specified selector.
|
static Selection |
selectAll(com.google.gwt.user.client.ui.Widget... nodes)
Selects the elements corresponding to the root elements of the widgets in
the specified array.
|
static Selection |
selectAll(com.google.gwt.user.client.ui.WidgetCollection widgets)
Selects the specified collection of elements.
|
static void |
shuffle(char[] input) |
static void |
shuffle(int[] input) |
static void |
shuffle(List<?> objects)
Randomly shuffle the list of objects provided.
|
static SVG |
svg() |
static Time |
time() |
static void |
timer(TimerFunction command)
Alias for
timer(TimerFunction, int) with a delay equals to 0. |
static void |
timer(TimerFunction command,
int delayMillis)
Alias for
timer(TimerFunction, int, int) with a mark equals to
the "now" timestamp (i.e new Date().getTime() ). |
static void |
timer(TimerFunction command,
int delayMillis,
int markMillis)
Start a custom animation timer, invoking the specified
TimerFunction repeatedly until it returns true. |
static void |
timerFlush()
Immediately execute (invoke once) any active timers.
|
static com.google.gwt.core.client.JsArrayMixed |
touches(com.google.gwt.dom.client.Node container)
Returns the x and y coordinates of each touch associated with the current
d3.event, based on the touches attribute, relative to the specified
container.
|
static Transition |
transition()
Create an animated transition.
|
static <T> Dsv<T> |
tsv() |
static <T> Dsv<T> |
tsv(String url)
Issues an HTTP GET request for the comma-separated values (TSV) file at
the specified url.
|
static <T> Dsv<T> |
tsv(String url,
DsvCallback<T> callback)
Issues an HTTP GET request for the comma-separated values (TSV) file at
the specified url.
|
static <T> Dsv<T> |
tsv(String url,
DsvObjectAccessor<T> accessor)
Issues an HTTP GET request for the comma-separated values (TSV) file at
the specified url.
|
static <T> Dsv<T> |
tsv(String url,
DsvObjectAccessor<T> accessor,
DsvCallback<T> callback)
Issues an HTTP GET request for the comma-separated values (TSV) file at
the specified url.
|
static String |
version() |
static Zoom.ZoomEvent |
zoomEvent()
Get the ZoomEvent from within a
Zoom listener. |
public static final Scales scale
public static final String version()
public static final Selection select(String selector)
The selector is a valid CSS3 selector. For example, you can select by tag ("div"), class (".awesome"), unique identifier ("#foo"), attribute ("[color=red]"), or containment ("parent child"). Selectors can also be intersected (".this.that" for logical AND) or unioned (".this, .that" for logical OR)
selector
- a CSS3 selectorSelection
public static final Selection select(com.google.gwt.dom.client.Element element)
Document.getBody()
element
- the element to selectSelection
public static final Selection select(com.google.gwt.user.client.ui.Widget widget)
RootPanel.get()
widget
- the widget to selectSelection
public static final Selection selectAll(String selector)
selector
- public static final Selection selectAll(com.google.gwt.dom.client.NodeList<?> nodes)
nodes
- the elementspublic static final Selection selectAll(Array<com.google.gwt.dom.client.Element> nodes)
nodes
- the elementspublic static final Selection selectAll(com.google.gwt.dom.client.Element... nodes)
nodes
- the elementspublic static final Selection selectAll(Collection<com.google.gwt.dom.client.Element> nodes)
nodes
- the elementspublic static final Selection selectAll(com.google.gwt.user.client.ui.Widget... nodes)
nodes
- the elementspublic static final Selection selectAll(com.google.gwt.user.client.ui.WidgetCollection widgets)
nodes
- the elementspublic static final Transition transition()
This is equivalent to D3.select(document).transition()
. This method is used rarely, as it is typically easier to derive a transition
from an existing selection, rather than deriving a selection from an existing transition.
public static final void shuffle(List<?> objects)
Note: Collections.shuffle(List)
is not GWT compatible
objects
- the list to shufflepublic static final void shuffle(int[] input)
public static final void shuffle(char[] input)
public static final SVG svg()
public static final Layout layout()
public static final void timer(TimerFunction command)
timer(TimerFunction, int)
with a delay equals to 0.command
- the command to be executed until it returns true.delayMillis
- the delay to expires before the command should start being
invoked (may be negative if markMillis is in the future)public static final void timer(TimerFunction command, int delayMillis)
timer(TimerFunction, int, int)
with a mark equals to
the "now" timestamp (i.e new Date().getTime()
).command
- the command to be executed until it returns true.delayMillis
- the delay to expires before the command should start being
invoked (may be negative if markMillis is in the future)public static final void timer(TimerFunction command, int delayMillis, int markMillis)
TimerFunction
repeatedly until it returns true.
There is no way to cancel the timer after it starts, so make sure your timer function returns true when done! The optional numeric delay [unit: integer, millisecond] may be specified when the given function should only start to be invoked after delay milliseconds have expired after the specified mark timestamp [unit: integer, milliseconds since epoch].
When mark is omitted, Date.now() is assumed instead. Otherwise, you may use Date.getTime to convert your Date object to a suitable mark timestamp.
You may use delay and mark to specify relative and absolute moments in time when the function should start being invoked, e.g. a calendar-based event might be coded as
Date appointment = new Date(2012, 09, 29, 14, 0, 0); // @ 29/sep/2012, 1400 hours
...
// flash appointment on screen when it's due in 4 hours or less: note that negative (delay) is okay!
d3.timer(flash_appointments_due, -4 * 3600 * 1000, appointment);
command
- the command to be executed until it returns true.delayMillis
- the delay to expires before the command should start being
invoked (may be negative if markMillis is in the future)markMillis
- the timestamp from which the delay startspublic static final void timerFlush()
Normally, zero-delay transitions are executed after an instantaneous delay (<10ms).
This can cause a brief flicker if the browser renders the page twice: once at the end of the first event loop, then again immediately on the first timer callback.
By flushing the timer queue at the end of the first event loop, you can run any zero-delay transitions immediately and avoid the flicker.
Note: the original method is d3.timer.flush() but has been pushed here because the timer API is limited to this method
public static final Time time()
public static final <T extends com.google.gwt.user.client.Event> T event()
This global variable exists during an event listener callback registered with the on operator. The current event is reset after the listener is notified in a finally block. This allows the listener function to have the same form as other operator functions, being passed the current datum d and index i.
The event()
object is a DOM event and implements the standard event fields like timeStamp and keyCode
as well as methods like preventDefault() and stopPropagation(). While you can use the native event's pageX and
pageY, it is often more convenient to transform the event position to the local coordinate system of the
container that received the event. For example, if you embed an SVG in the normal flow of your page, you may want
the event position relative to the top-left corner of the SVG image. If your SVG contains transforms, you might
also want to know the position of the event relative to those transforms.
Use the d3.mouse operator for the standard mouse pointer, and use d3.touches for multitouch events on iOS.
You may get an instance of D3Event
by an auto-casting call:
D3Event d3e = D3.event();
//allow a call to d3e.sourceEvent();
Event
public static final Coords eventAsCoords()
Coords
object containing
the x and y of the mouse. This is useful when using Drag
behavior.public static final Coords eventAsDCoords()
Coords
object containing
the dx and dy representing the element's coordinates relative to its
position at the beginning of the gesture. This is useful when using Drag
behavior.public static final com.google.gwt.core.client.JsArrayNumber mouse(com.google.gwt.dom.client.Node container)
container
- public static final Coords mouseAsCoords(com.google.gwt.dom.client.Node container)
container
- public static final double mouseX(com.google.gwt.dom.client.Node container)
container
- public static final double mouseY(com.google.gwt.dom.client.Node container)
container
- public static final com.google.gwt.core.client.JsArrayMixed touches(com.google.gwt.dom.client.Node container)
The container may be an HTML or SVG container element, such as an svg:g or svg:svg.
The coordinates are returned as an array of two-element arrays [ [ x1, y1], [ x2, y2], … ].
container
- the node to get the coords relative topublic static final <T> Dsv<T> csv()
public static final <T> Dsv<T> csv(String url, DsvCallback<T> callback)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/csv". The request is processed asynchronously, such that this method returns immediately after opening the request. When the CSV data is available, the specified callback will be invoked with the parsed rows as the argument. If an error occurs, the callback function will instead be invoked with null.
public static final <T> Dsv<T> csv(String url, DsvObjectAccessor<T> accessor, DsvCallback<T> callback)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/csv". The request is processed asynchronously, such that this method returns immediately after opening the request. When the CSV data is available, the specified callback will be invoked with the parsed rows as the argument. If an error occurs, the callback function will instead be invoked with null. The accessor may be specified, which is then passed to d3.csv.parse; the accessor may also be specified by using the return request object’s row function.
public static final <T> Dsv<T> csv(String url, DsvObjectAccessor<T> accessor)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/csv". The request is processed asynchronously, such that this method returns immediately after opening the request. When the CSV data is available, the specified callback will be invoked with the parsed rows as the argument. If an error occurs, the callback function will instead be invoked with null. The accessor may be specified, which is then passed to d3.csv.parse; the accessor may also be specified by using the return request object’s row function.
public static final <T> Dsv<T> csv(String url)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/csv". The request is processed asynchronously, such that this method returns immediately after opening the request.
public static final <T> Dsv<T> tsv()
public static final <T> Dsv<T> tsv(String url, DsvCallback<T> callback)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/tsv". The request is processed asynchronously, such that this method returns immediately after opening the request. When the TSV data is available, the specified callback will be invoked with the parsed rows as the argument. If an error occurs, the callback function will instead be invoked with null.
public static final <T> Dsv<T> tsv(String url, DsvObjectAccessor<T> accessor, DsvCallback<T> callback)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/tsv". The request is processed asynchronously, such that this method returns immediately after opening the request. When the TSV data is available, the specified callback will be invoked with the parsed rows as the argument. If an error occurs, the callback function will instead be invoked with null. The accessor may be specified, which is then passed to d3.tsv.parse; the accessor may also be specified by using the return request object’s row function.
public static final <T> Dsv<T> tsv(String url, DsvObjectAccessor<T> accessor)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/tsv". The request is processed asynchronously, such that this method returns immediately after opening the request. When the TSV data is available, the specified callback will be invoked with the parsed rows as the argument. If an error occurs, the callback function will instead be invoked with null. The accessor may be specified, which is then passed to d3.tsv.parse; the accessor may also be specified by using the return request object’s row function.
public static final <T> Dsv<T> tsv(String url)
The file contents are assumed to be RFC4180-compliant. The mime type of the request will be "text/tsv". The request is processed asynchronously, such that this method returns immediately after opening the request.
public static final <T> Array<String> keys(com.google.gwt.core.client.JavaScriptObject object)
object
- the object to convert to an arraypublic static final Formatter format(String specifier)
Formatter
function with the given string specifier.
A format function takes a number as the only argument, and returns a
string representing the formatted number. Please see Formatter
javadoc for the specifier specification.specifier
- the given string specifier.public static final Prefix formatPrefix(double value, double precision)
This method is used by format(String)
for the %s format.
value
- the value to be prefixedprecision
- the precisionpublic static final double round(double value, int digits)
value
- digits
- public static final String requote(String string)
string
- the input stringpublic static final Behavior behavior()
public static final Zoom.ZoomEvent zoomEvent()
Zoom
listener.public static final Drag.DragEvent dragEvent()
Drag
listener.public static final com.google.gwt.core.client.JavaScriptObject identity()
function(d) { return d; }
Copyright © 2015 gwt-d3. All rights reserved.