colorLegendWidget

geo.gui. colorLegendWidget

new colorLegendWidget(argopt) → {geo.gui.colorLegendWidget}

Description:
  • A UI widget that enables display discrete colors or two-color continuous transition legend.

Source:
Parameters:
Name Type Attributes Description
arg object <optional>

Widget options.

Properties
Name Type Attributes Default Description
position geo.gui.widget.position <optional>

Position setting relatively to the map container.

categories Array.<geo.gui.colorLegendWidget.category> <optional>

An array of category definitions for the initial color legends

width number <optional>
300

The width of the widget in pixels.

ticks number <optional>
6

The maximum number of ticks on the axis of a legend, default is 6.

Returns:
Type
geo.gui.colorLegendWidget

Extends

Members

idle

Description:
  • Getter for the idle state. Read only.

Source:
Inherited From:
Properties:
Name Type Description
idle boolean

true if the object is idle (onIdle would call a handler immediately).

Getter for the idle state. Read only.

Methods

addCategories(categories) → {this}

Description:
  • Add additional categories.

Source:
Parameters:
Name Type Description
categories Array.<geo.gui.colorLegendWidget.category>

Append additional legend categories to the end the of the current list of legends.

Returns:

The current class instance.

Type
this

addChild(child) → {this}

Description:
  • Add a child (or an array of children) to the object.

Source:
Inherited From:
Parameters:
Name Type Description
child geo.object | Array.<geo.object>

A child object or array of child objects.

Returns:
Type
this

addPromise(promise) → {this}

Description:
  • Add the promise here and also propagate up the scene tree.

Source:
Inherited From:
Parameters:
Name Type Description
promise Promise

A promise object.

Returns:
Type
this

canvas(valopt) → {HTMLElement|this}

Description:
  • Get/Set the canvas for the widget.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
val HTMLElement <optional>

If specified, set the canvas, otherwise get the canvas.

Returns:

If getting the canvas, return the current value; otherwise, return this widget.

Type
HTMLElement | this

categories(categoriesopt) → {Array.<geo.gui.colorLegendWidget.category>|this}

Description:
  • Get or set categories.

Source:
Parameters:
Name Type Attributes Description
categories Array.<geo.gui.colorLegendWidget.category> <optional>

If undefined, return the current legend categories array. If an array is provided, remove current legends and recreate with the new categories.

Returns:

The current list of categories or the current class instance.

Type
Array.<geo.gui.colorLegendWidget.category> | this

children() → {Array.<geo.object>}

Description:
  • Get an array of the child objects.

Source:
Inherited From:
Returns:

A copy of the array of child objects.

Type
Array.<geo.object>

draw(arg) → {this}

Description:
  • Force redraw of a scene object, to be implemented by subclasses. Base class just calls draw of child objects.

Source:
Inherited From:
Parameters:
Name Type Description
arg object

Options to pass to the child draw functions.

Returns:
Type
this

geoIsOn(event, handleropt) → {boolean}

Description:
  • Report if an event handler is bound to this object.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
event string | Array.<string>

An event or list of events to check.

handler function <optional>

A function that might be bound. If undefined, this will report true if there is any handler for the specified event.

Returns:

true if any of the specified events are bound to the specified handler.

Type
boolean

geoOff(eventopt, argopt, nullable) → {this}

Description:
  • Remove handlers from one event or an array of events. If no event is provided all handlers will be removed.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
event string | Array.<string> <optional>

An event or a list of events from geo.event or defined by the user, or undefined to remove all events (in which case arg is ignored).

arg function | Array.<function()> <optional>
<nullable>

A function or array of functions to remove from the events or a falsy value to remove all handlers from the events.

Returns:
Type
this

geoOn(event, handler) → {this}

Description:
  • Bind an event handler to this object.

Source:
Inherited From:
Parameters:
Name Type Description
event string

An event from geo.event or a user-defined value.

handler function

A function that is called when event is triggered. The function is passed a geo.event object.

Returns:
Type
this

geoOnce(event, handler) → {function}

Description:
  • Bind an event handler to this object that will fire once and then deregister itself.

Source:
Inherited From:
Parameters:
Name Type Description
event string

An event from geo.event or a user-defined value.

handler function

A function that is called when event is triggered. The function is passed a geo.event object.

Returns:

The actual bound handler. This is a wrapper around the handler that was passed to the function.

Type
function

geoTrigger(event, args, childrenOnlyopt) → {this}

Description:
  • Trigger an event (or events) on this object and call all handlers.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
event string

The event to trigger.

args object

Arbitrary argument to pass to the handler.

childrenOnly boolean <optional>

If truthy, only propagate down the tree.

Returns:
Type
this

isInViewport() → {boolean}

Description:
  • Report if the top left of widget (or its current x, y position) is within the viewport.

Source:
Inherited From:
Returns:

True if the widget is within the viewport.

Type
boolean

layer() → {geo.layer}

Description:
  • Return the layer associated with this widget.

Source:
Inherited From:
Returns:
Type
geo.layer

modified() → {this}

Description:
  • Update the timestamp to the next global timestamp value.

Source:
Inherited From:
Returns:
Type
this

onIdle(handler) → {this}

Description:
  • Bind a handler that will be called one time when all internal promises are resolved. If there are no outstanding promises, this is invoked synchronously.

Source:
Inherited From:
Parameters:
Name Type Description
handler function

A function taking no arguments.

Returns:
Type
this

parent(argopt) → {this|geo.sceneObject}

Description:
  • Get/set parent of the object.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
arg geo.sceneObject <optional>

The new parent or undefined to get the current parent.

Returns:
Type
this | geo.sceneObject

parentCanvas() → {HTMLElement}

Description:
  • Get the parent canvas (top level widgets define their layer as their parent canvas).

Source:
Inherited From:
Returns:

The canvas of the widget's parent.

Type
HTMLElement

position(posopt, actualValueopt) → {geo.gui.widget.position|this}

Description:
  • Get or set the CSS positioning that a widget should be placed at.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
pos geo.gui.widget.position <optional>

If unspecified, return the current position. Otherwise, set the current position.

actualValue boolean <optional>

If getting the position, if this is truthy, always return the stored value, not a value adjusted for display.

Returns:

Either the position or the widget instance. If this is the position and actualValue is falsy, positions that specify an explicit x and y parameter will be converted to a value that can be used by the display css.

Type
geo.gui.widget.position | this

removeCategories(categories) → {this}

Description:
  • Remove categories.

Source:
Parameters:
Name Type Description
categories Array.<geo.gui.colorLegendWidget.category>

If a category object exists in the current legend categories, that category will be removed.

Returns:

The current class instance.

Type
this

removeChild(child) → {this}

Description:
  • Remove a child (or array of children) from the object.

Source:
Inherited From:
Parameters:
Name Type Description
child geo.object | Array.<geo.object>

A child object or array of child objects.

Returns:
Type
this

removePromise(promise) → {this}

Description:
  • Remove the promise here and also propagate up the scene tree.

Source:
Inherited From:
Parameters:
Name Type Description
promise Promise

A promise object.

Returns:
Type
this

reposition(positionopt) → {this}

Description:
  • Repositions a widget.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
position geo.gui.widget.position <optional>

The new position for the widget. undefined uses the stored position value.

Returns:
Type
this

repositionEvent() → {this}

Description:
  • If the position is based on map coordinates, this gets called when the map is panned to resposition the widget.

Source:
Inherited From:
Returns:
Type
this

timestamp() → {number}

Description:
  • Get time.

Source:
Inherited From:
Returns:

The timestamp. This is 0 if the timestamp has never been modified.

Type
number

Type Definitions

category

Source:
Properties:
Name Type Attributes Description
name string

The text label of the legend.

type string

The type of the legend, either discrete or continuous.

scale string

The scale of the legend. For discrete type, linear, log, sqrt, pow, ordinal, and quantile is supported. For continuous type, linear, log, sqrt, and pow is supported.

domain Array.<number> | Array.<string>

Only for ordinal scale legend, string values are acceptable. For ordinal legend, the number in the domain array should be the same number of colors. For quantile scale legend, the domain should be an array of all values. For other scales, the domain needs to be an array of two number for marking the upper bound and lower bound. This domain property will be used with d3 scale object internally.

colors Array.<geo.geoColor>

The colors of the legend. All valid svg color can be used. For discrete type, multiple values are accepted. For continuous type, an array of two values is supported.

base number <optional>

The base of log when log scale is used. default to 10.

exponent number <optional>

The exponent of power when power scale is used. default to 1.

endAxisLabelOnly boolean <optional>

Only show left most and right most axis label default to null.

Type:
  • object