Empirical
Public Member Functions | Protected Attributes | List of all members
D3::Transition Class Reference

#include <selection.h>

Inheritance diagram for D3::Transition:
D3::SelectionOrTransition< Transition > D3::D3_Base

Public Member Functions

Transition Select (std::string selector) const
 
Transition SelectAll (std::string selector) const
 
TransitionCall (std::string function)
 
Transition Filter (std::string selector) const
 
TransitionEach (std::string function)
 
void Remove ()
 
Transition Merge (Transition &other)
 
int GetID () const
 
void Log () const
 
Constructors

Usually transitions are constructed from selections by calling the selection.MakeTransition() method. In rare cases you may want to construct a new transition, though.

 Transition ()
 Default constructor - construct empty transition. More...
 
 Transition (int id)
 Advanced: Construct new transition pointing to the [id]th element in js.objects. More...
 
Transition NewTransition (std::string name="") const
 
Setters

There are three main types of values you might want to change about a selection: attributes (use SetAttr), styles (use SetStyle), and properties (use SetProperty). The distinction between these types is rooted in how they are represented in web languages (Javascript, CSS, and HTML) and would ideally be abstracted in this wrapper but can't be.

Additional traits you can set include text and html.

Advanced note: In D3.js, the same functions are used to set and get values (depending on whether an argument is passed). Because C++ needs to have clearly defined return types we need separate getters for each return type.

TransitionSetAttr (std::string name, std::string value)
 
TransitionSetStyle (std::string name, std::string value, bool priority=false)
 
TransitionSetText (std::string text)
 
TransitionSetProperty (std::string name, std::string value)
 
TransitionSetHtml (std::string value)
 
TransitionSetClassed (std::string classname, bool value)
 
Getters

There are three main types of values you might want to access about a selection: attributes (use GetAttr), styles (use GetStyle), and properties (use GetProperty). The distinction between these types is rooted in how they are represented in web languages (Javascript, CSS, and HTML) and would ideally be abstracted in this wrapper but can't be.

Additional traits you can set include text and html.

Advanced note: In D3.js, the same functions are used to set and get values (depending on whether an argument is passed). Because C++ needs to have clearly defined return types (and because different macros are required to return different types from Javascript), we need separate getters for each return type.

std::string GetAttrString (std::string name) const
 Get the value of this object's [name] attribute when it's a string. More...
 
int GetAttrInt (std::string name) const
 Get the value of this object's [name] attribute when it's an int. More...
 
double GetAttrDouble (std::string name) const
 Get the value of this object's [name] attribute when it's a double. More...
 
std::string GetStyleString (std::string name) const
 Get the value of this object's [name] style when it's a string. More...
 
int GetStyleInt (std::string name) const
 Get the value of this object's [name] style when it's an int. More...
 
double GetStyleDouble (std::string name) const
 Get the value of this object's [name] style when it's a double. More...
 
std::string GetText () const
 Get this object's text. More...
 
std::string GetHtml ()
 
std::string GetPropertyString (std::string name)
 
int GetPropertyInt (std::string name)
 
double GetPropertyDouble (std::string name)
 
bool Empty () const
 Returns true if there are no elements in this selection (or all elements are null) More...
 
int Size () const
 Returns number of elements in this selection. More...
 

Protected Attributes

int id
 

Detailed Description

Transitions are similar to selections, but when you make a change to them (attr or style), it will be animated. For additional discussion of transitions in d3, see this article.

Constructor & Destructor Documentation

D3::Transition::Transition ( )
inline

Default constructor - construct empty transition.

D3::Transition::Transition ( int  id)
inline

Advanced: Construct new transition pointing to the [id]th element in js.objects.

Member Function Documentation

Transition & D3::SelectionOrTransition< Transition >::Call ( std::string  function)
inlineinherited

Call the given function once on the entire selection/transition. [function] can either be a C++ function or a string with the name of a Javascript function in the d3, emp, or current window namespace. To get around the problem of passing selections into C++, this function assumes that the function you are passing expects a single argument: an int, representing the id of the selection to be operated on (which you can then convert to a selection object with D3::Selection(i)).

Transition & D3::SelectionOrTransition< Transition >::Each ( std::string  function)
inlineinherited

Call the given function on each element of the selection/transition. [function] can either be a C++ function or a string with the name of a Javascript function in the d3, emp, or current window namespace.

bool D3::SelectionOrTransition< Transition >::Empty ( ) const
inlineinherited

Returns true if there are no elements in this selection (or all elements are null)

Transition D3::SelectionOrTransition< Transition >::Filter ( std::string  selector) const
inlineinherited

Returns a new selection/transition, representing the current selection/transition filtered by [selector]. [selector] can be a C++ function that returns a bool, a string representing a function in either the d3, emp, or window namespaces that returns a bool, or a string containing a selector to filter by.

For more information see the D3 documentation

double D3::SelectionOrTransition< Transition >::GetAttrDouble ( std::string  name) const
inlineinherited

Get the value of this object's [name] attribute when it's a double.

int D3::SelectionOrTransition< Transition >::GetAttrInt ( std::string  name) const
inlineinherited

Get the value of this object's [name] attribute when it's an int.

std::string D3::SelectionOrTransition< Transition >::GetAttrString ( std::string  name) const
inlineinherited

Get the value of this object's [name] attribute when it's a string.

std::string D3::SelectionOrTransition< Transition >::GetHtml ( )
inlineinherited

Get this object's html

Advanced note: This is implemented differently for selection vs transitions. As such, calling it on a SelectionOrTransition object directly is not supported.

int D3::D3_Base::GetID ( ) const
inlineinherited
double D3::SelectionOrTransition< Transition >::GetPropertyDouble ( std::string  name)
inlineinherited

Get the value of this object's [name] property when it's a double

Advanced note: This is implemented differently for selection vs transitions. As such, calling it on a SelectionOrTransition object directly is not supported.

int D3::SelectionOrTransition< Transition >::GetPropertyInt ( std::string  name)
inlineinherited

Get the value of this object's [name] property when it's an int

Advanced note: This is implemented differently for selection vs transitions. As such, calling it on a SelectionOrTransition object directly is not supported.

std::string D3::SelectionOrTransition< Transition >::GetPropertyString ( std::string  name)
inlineinherited

Get the value of this object's [name] property when its a string

Advanced note: This is implemented differently for selection vs transitions. As such, calling it on a SelectionOrTransition object directly is not supported.

double D3::SelectionOrTransition< Transition >::GetStyleDouble ( std::string  name) const
inlineinherited

Get the value of this object's [name] style when it's a double.

int D3::SelectionOrTransition< Transition >::GetStyleInt ( std::string  name) const
inlineinherited

Get the value of this object's [name] style when it's an int.

std::string D3::SelectionOrTransition< Transition >::GetStyleString ( std::string  name) const
inlineinherited

Get the value of this object's [name] style when it's a string.

std::string D3::SelectionOrTransition< Transition >::GetText ( ) const
inlineinherited

Get this object's text.

void D3::D3_Base::Log ( ) const
inlineinherited
Transition D3::SelectionOrTransition< Transition >::Merge ( Transition other)
inlineinherited
Transition D3::Transition::NewTransition ( std::string  name = "") const
inline

Create a transition from the current transition. If a [name] is specified the transition will be given that name

Note: In D3.js this method is just called transition(), but in C++ that would cause a collision with the constructor

void D3::SelectionOrTransition< Transition >::Remove ( )
inlineinherited

Remove the elements in this selection/transition from the document For transitions, this happens at the end of the transition.

Transition D3::SelectionOrTransition< Transition >::Select ( std::string  selector) const
inlineinherited

Create a new selection/transition containing the first element matching the [selector] string that are within this current selection/transition

Transition D3::SelectionOrTransition< Transition >::SelectAll ( std::string  selector) const
inlineinherited

Create a new selection/transition containing all elements matching the [selector] string that are within this current selection/transition

Transition & D3::SelectionOrTransition< Transition >::SetAttr ( std::string  name,
std::string  value 
)
inlineinherited

Assigns [value] to the selection's [name] attribute. Value can be any primitive type, a string, a function object, or a lambda. If a string is passed, it can be a normal string, or the name of a function in d3, emp (such as one created with JSWrap), or the local window. If it is a function name, that function will be run, receiving bound data, if any, as input

Transition & D3::SelectionOrTransition< Transition >::SetClassed ( std::string  classname,
bool  value 
)
inlineinherited

Change whether or not element in this selection have the [classname] class. Example: Add the data-point class with selection.SetClassed("data-point", true); Advanced note: This is implemented differently for selection vs transitions. As such, calling it on a SelectionOrTransition object directly is not supported.

Transition & D3::SelectionOrTransition< Transition >::SetHtml ( std::string  value)
inlineinherited

Sets this selection's inner html to the specified string, or the string returned by running the specified function on the element's bound data

Advanced note: This is implemented differently for selection vs transitions. As such, calling it on a SelectionOrTransition object directly is not supported.

Transition & D3::SelectionOrTransition< Transition >::SetProperty ( std::string  name,
std::string  value 
)
inlineinherited

Sets special properties of DOM elements (e.g. "checked" for checkboxes) Value can be a number, function, string, or string naming a Javascript function See the d3 documentation for more information.

Advanced note: This is implemented differently for selection vs transitions. As such, calling it on a SelectionOrTransition object directly is not supported.

Transition & D3::SelectionOrTransition< Transition >::SetStyle ( std::string  name,
std::string  value,
bool  priority = false 
)
inlineinherited

Sets the selection's [name] style to [value]. This is the same idea as SetAttr, except for CSS styles. Value can be any primitive type, a string, a function object, or a lambda. If a string is passed, it can be a normal string, or the name of a function in d3, emp (such as one created with JSWrap), or the local window. If it is a function name, that function will be run, receiving bound data, if any, as input

There is a third optional argument, a boolean indicating whether you want to give this setting priority.

Transition & D3::SelectionOrTransition< Transition >::SetText ( std::string  text)
inlineinherited

Sets this selection's text to the specified string, or the string returned by running the specified function on the element's bound data

int D3::SelectionOrTransition< Transition >::Size ( ) const
inlineinherited

Returns number of elements in this selection.

Member Data Documentation

int D3::D3_Base::id
protectedinherited

The documentation for this class was generated from the following file: