Class D3RaphaelSelection
Raphael aware selection, intended to be used like d3.selection
.
caveats and differences documented below.
Unlike SVG, in Raphael, all elements are in a flat list, all peer to eachother, and all the direct child of the root Raphael element.
This changes the behavior of some of the methods below (noted as appropriate).
If you don't see a method documented, it probably doesn't exist yet.
Defined in: _documentation.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
append(type)
Appends an element of the specified primitive type for each of the
Raphael elements in the selection.
|
|
attr(name, value)
Manipulates the Raphael elements in this selection by changing the specified attribute to
the specified value.
|
|
call(func, arguments)
Invokes the specified function once, passing in the current selection along with any optional arguments.
|
|
classed(name, add)
Adds or removes the specified class name from the selections elements depending on the "truthness" of
value.
|
|
data(value, key_function)
Binds the provided data to the selected Raphael element(s).
|
|
datum(value)
Gets or sets the bound data for each selection element.
|
|
each(callback)
Iterate over the elements of the selection, executing the specified function.
|
|
empty()
Returns true if the current selection is empty.
|
|
node()
Returns the first non-null element in the current selection.
|
|
property(name, value)
Sets arbitrary properties on the selections Raphael elements.
|
|
select(type)
Performs a selection testing _all_ the elements in the Raphael paper that match the specified type, returning a new selection
with only the first element found (if any).
|
|
selectAll(type)
Performs a selection testing _all_ the elements in the Raphael paper that match the specified type, returning a new selection
with the found elements (if any).
|
|
text(value)
Changes the text of the selection's
text elements. |
Method Detail
{D3RaphaelSelection}
append(type)
Appends an element of the specified primitive type for each of the
Raphael elements in the selection.
NOTE: This method behaves similarly to the d3 version, except appended elements aren't children of the selection's existing elements. In Raphael, all elements are in a flat list, peer to eachother, a child of the root containing element.
Defined in: selection.js.
NOTE: This method behaves similarly to the d3 version, except appended elements aren't children of the selection's existing elements. In Raphael, all elements are in a flat list, peer to eachother, a child of the root containing element.
Defined in: selection.js.
- Parameters:
- {String} type
- Returns:
- {D3RaphaelSelection} with each existing element replaced with a appended element of the specified type.
- See:
- d3.selection.append()
- d3_raphael_paperShapes for a list of supported primitive types
{D3RaphaelSelection}
attr(name, value)
Manipulates the Raphael elements in this selection by changing the specified attribute to
the specified value.
Generally, it behaves similarly to the d3 version. Like d3, the
In addition to the attributes supported natively by Raphael, there are few additions:
Defined in: selection.js.
Generally, it behaves similarly to the d3 version. Like d3, the
value
parameter can be a function to provide an attribute value specific to each elements of the selection.In addition to the attributes supported natively by Raphael, there are few additions:
- d
- is an alias for Raphael attribute
path
. (Intended for compatibility with existing d3 code) - class
- Sets the element's class name (like d3 does for the same attribute name)
Defined in: selection.js.
- Parameters:
- {String} name
- Raphael attribute name
- {value of function} value
- the value (or a function that returns the value) to change the attribute to
- Returns:
- {D3RaphaelSelection} this
call(func, arguments)
Invokes the specified function once, passing in the current selection along with any optional arguments. The call operator always returns the current selection, regardless of the return value of the specified function.
Defined in: selection.js.
Defined in: selection.js.
- Parameters:
- {function} func
- {*} arguments
- optional arguments to pass to the function
- See:
- d3.selection.call()
{D3RaphaelSelection}
classed(name, add)
Adds or removes the specified class name from the selections elements depending on the "truthness" of
value.
NOTE: Only adding class names is supported now, you cannot remove a class name currently with this method.
Defined in: selection.js.
NOTE: Only adding class names is supported now, you cannot remove a class name currently with this method.
Defined in: selection.js.
- Parameters:
- {String} name
- class name
- {truthy or function} add
- Returns:
- {D3RaphaelSelection} this
{D3RaphaelUpdateSelection}
data(value, key_function)
Binds the provided data to the selected Raphael element(s).
IMPLEMENTATION NOTE: Usage identical to the native d3 version, except internally, instead of binding the data to the DOM objects (like d3 does), the data is bound to the Raphael wrapper element(s) of the DOM.
Defined in: selection.js.
IMPLEMENTATION NOTE: Usage identical to the native d3 version, except internally, instead of binding the data to the DOM objects (like d3 does), the data is bound to the Raphael wrapper element(s) of the DOM.
Defined in: selection.js.
- Parameters:
- value
- {function} key_function
- Returns:
- {D3RaphaelUpdateSelection}
- See:
- d3.selection.data()
{D3RaphaelSelection}
datum(value)
Gets or sets the bound data for each selection element.
Defined in: selection.js.
Defined in: selection.js.
- Parameters:
- {Array} value
- Returns:
- {D3RaphaelSelection} this
- See:
- d3.selection.datum()
each(callback)
Iterate over the elements of the selection, executing the specified function.
NOTE: This method iterates over the Raphael created wrapper element (which internally contains the native DOM element, either SVG or VML via
Defined in: selection.js.
NOTE: This method iterates over the Raphael created wrapper element (which internally contains the native DOM element, either SVG or VML via
element.node
.
Defined in: selection.js.
- Parameters:
- {function} callback
function(datum, index) { // this is the Raphael element }
empty()
Returns true if the current selection is empty.
Defined in: selection.js.
Defined in: selection.js.
- See:
- d3.selection.empty()
node()
Returns the first non-null element in the current selection. If the selection is empty, returns null.
Defined in: selection.js.
Defined in: selection.js.
- See:
- d3.selection.node()
{D3RaphaelSelection}
property(name, value)
Sets arbitrary properties on the selections Raphael elements.
Defined in: selection.js.
Defined in: selection.js.
- Parameters:
- {String} name
- property name
- value
- property value
- Returns:
- {D3RaphaelSelection} this
{D3RaphaelSelection}
select(type)
Performs a selection testing _all_ the elements in the Raphael paper that match the specified type, returning a new selection
with only the first element found (if any).
NOTE: This method behaves differently than the native d3 version. Since the Raphael paper is inherently a flat list of elements, there is no concept of a selection that is scoped by it's parent element (like in d3). Thus, every call to
NOTE: Currently, the selector string is limited in features. Right now, you can only specify the Raphael primitive type name you want to select, no other selector strings are supported (like css class name).
Defined in: selection.js.
NOTE: This method behaves differently than the native d3 version. Since the Raphael paper is inherently a flat list of elements, there is no concept of a selection that is scoped by it's parent element (like in d3). Thus, every call to
select
searches on all elements in the paper, regardless of the
existing content of the selection. NOTE: Currently, the selector string is limited in features. Right now, you can only specify the Raphael primitive type name you want to select, no other selector strings are supported (like css class name).
Defined in: selection.js.
- Parameters:
- {String} type
- Raphael primitive type name
- Returns:
- {D3RaphaelSelection} the new selection.
- See:
- d3.select()
- d3_raphael_paperShapes for a list of supported primitive types
{D3RaphaelSelection}
selectAll(type)
Performs a selection testing _all_ the elements in the Raphael paper that match the specified type, returning a new selection
with the found elements (if any).
NOTE: This method behaves differently than the native d3 version. Since the Raphael paper is inherently a flat list of elements, there is no concept of a selection that is scoped by it's parent element (like in d3). Thus, every call to
NOTE: Currently, the selector string is limited in features. Right now, you can only specify the Raphael primitive type name you want to select, no other selector strings are supported (like css class name).
Defined in: selection.js.
NOTE: This method behaves differently than the native d3 version. Since the Raphael paper is inherently a flat list of elements, there is no concept of a selection that is scoped by it's parent element (like in d3). Thus, every call to
select
searches on all elements in the paper, regardless of the
existing content of the selection. NOTE: Currently, the selector string is limited in features. Right now, you can only specify the Raphael primitive type name you want to select, no other selector strings are supported (like css class name).
Defined in: selection.js.
- Parameters:
- {String} type
- Raphael primitive type name
- Returns:
- {D3RaphaelSelection} the new selection.
- See:
- d3.selectAll()
- d3_raphael_paperShapes for a list of supported primitive types
{D3RaphaelSelection}
text(value)
Changes the text of the selection's
NOTE: This version behaves differently than the native d3 version, which changes the text content of the selection's DOM elements.
Defined in: selection.js.
text
elements. NOTE: This version behaves differently than the native d3 version, which changes the text content of the selection's DOM elements.
Defined in: selection.js.
- Parameters:
- value
- Returns:
- {D3RaphaelSelection} this
- See:
- d3.selection.text()