Empirical
Public Member Functions | Public Attributes | Protected Attributes | List of all members
D3::Axis< SCALE_TYPE > Class Template Reference

#include <axis.h>

Inheritance diagram for D3::Axis< SCALE_TYPE >:
D3::D3_Base

Public Member Functions

 Axis (std::string type, std::string label="")
 
AxisDraw (Selection &selection)
 
template<typename T >
AxisApplyAxis (const SelectionOrTransition< T > &selection)
 
AxisSetScale (SCALE_TYPE &scale)
 
SCALE_TYPE & GetScale ()
 Get a reference to this object's scale. More...
 
AxisAdjustLabelOffset (std::string offset)
 
AxisMove (int x, int y)
 
template<typename T , std::size_t SIZE>
AxisSetTickValues (emp::array< T, SIZE > values)
 
AxisSetTickSize (float size)
 
AxisSetTickSizeInner (float size)
 
AxisSetTickSizeOuter (float size)
 
AxisSetTickPadding (int padding)
 
AxisSetTicks (int count)
 Set the number of ticks along the axis. More...
 
AxisSetTickFormat (std::string format)
 
template<typename T >
AxisRescale (double new_min, double new_max, const D3::SelectionOrTransition< T > &svg)
 
int GetID () const
 
void Log () const
 

Public Attributes

Selection group
 

Protected Attributes

int id
 

Detailed Description

template<typename SCALE_TYPE = LinearScale>
class D3::Axis< SCALE_TYPE >

Axis objects are in charge of drawing graphical axes onto svg canvases. An axis depicts a scale, so every axis has a scale, and is templated off of the type of that scale.

Constructor & Destructor Documentation

template<typename SCALE_TYPE = LinearScale>
D3::Axis< SCALE_TYPE >::Axis ( std::string  type,
std::string  label = "" 
)
inline

Consruct an axis - this doesn't draw anything yet, but sets up the necessary infrastructure to draw it when you call the Draw method. Optionally takes a label to label the axis with. This label will also be used to create an id for the axis, to make it easier to select it later. The id will be the same as [label], but with all whitespace removed and "_axis" appended to the end.

For example, if your label was "Per capita mortality", you could select the axis with: D3::Select("#Percapitamortality_axis");.

Member Function Documentation

template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::AdjustLabelOffset ( std::string  offset)
inline

Adjust the location of the label text relative to the axis (helpful if numbers are overlapping it). Can be negative. Use "em" (e.g. "2em") to specify distance relative to font size.

template<typename SCALE_TYPE = LinearScale>
template<typename T >
Axis& D3::Axis< SCALE_TYPE >::ApplyAxis ( const SelectionOrTransition< T > &  selection)
inline
template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::Draw ( Selection selection)
inline

Draw axis on [selection] (must contain a single SVG element) with intelligent default positioning

int D3::D3_Base::GetID ( ) const
inlineinherited
template<typename SCALE_TYPE = LinearScale>
SCALE_TYPE& D3::Axis< SCALE_TYPE >::GetScale ( )
inline

Get a reference to this object's scale.

void D3::D3_Base::Log ( ) const
inlineinherited
template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::Move ( int  x,
int  y 
)
inline

Draw tries to make a good guess about where to place the axis, but sometimes you want to scoot it over. This method will move the axis to the x,y location specified.

template<typename SCALE_TYPE = LinearScale>
template<typename T >
Axis& D3::Axis< SCALE_TYPE >::Rescale ( double  new_min,
double  new_max,
const D3::SelectionOrTransition< T > &  svg 
)
inline

Adjust scale and axis to accomodate the new range of data specified by [new_min], and [new_max]. [svg] is a Selection or Transition containing the current axis. If it's a transition, then the rescaling will be animated.

template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::SetScale ( SCALE_TYPE &  scale)
inline

An axis must have a scale. By default, a scale of SCALE_TYPE will be constructed, but usually you want an axis to depict a specific scale. This method points this object's scale member variable at [scale].

template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::SetTickFormat ( std::string  format)
inline

Set the format for displaying numbers assoiated with ticks. [format] should be a format following the rules for d3.format()

template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::SetTickPadding ( int  padding)
inline
template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::SetTicks ( int  count)
inline

Set the number of ticks along the axis.

template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::SetTickSize ( float  size)
inline
template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::SetTickSizeInner ( float  size)
inline
template<typename SCALE_TYPE = LinearScale>
Axis& D3::Axis< SCALE_TYPE >::SetTickSizeOuter ( float  size)
inline
template<typename SCALE_TYPE = LinearScale>
template<typename T , std::size_t SIZE>
Axis& D3::Axis< SCALE_TYPE >::SetTickValues ( emp::array< T, SIZE >  values)
inline

Member Data Documentation

template<typename SCALE_TYPE = LinearScale>
Selection D3::Axis< SCALE_TYPE >::group

There are a lot of graphical elements associated with an axis, so it's best to group them all together into an html group element. This selection holds a pointer to the group for this axis

int D3::D3_Base::id
protectedinherited

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