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

An area is defined by two lines, with the area in between shaded. More...

#include <svg_shapes.h>

Inheritance diagram for D3::AreaGenerator:
D3::LineGenerator D3::BaseLineGenerator D3::SvgShapeGenerator D3::D3_Base

Public Member Functions

 AreaGenerator ()
 
template<typename T >
void SetX0 (T x)
 
template<typename T >
void SetY0 (T y)
 
void SetX0 (std::string x)
 
void SetY0 (std::string y)
 
template<typename T >
void SetX1 (T x)
 
template<typename T >
void SetY1 (T y)
 
void SetX1 (std::string x)
 
void SetY1 (std::string y)
 
template<typename X_SCALE_TYPE >
void AddXScale (X_SCALE_TYPE &scale)
 
template<typename Y_SCALE_TYPE >
void AddYScale (Y_SCALE_TYPE &scale)
 
void SetX (std::string x)
 
void SetY (std::string y)
 
void SetCurve (std::string curve)
 
void SetTension (float tension)
 
void SetDefined (std::string defined)
 
template<typename T , size_t SIZE>
std::string Generate (emp::array< emp::array< T, 2 >, SIZE > &data)
 
template<typename T , std::size_t SIZE>
Selection DrawShape (emp::array< emp::array< T, 2 >, SIZE > &data, Selection &s)
 
Selection DrawShape (Dataset data, Selection s)
 DrawShape will also accept a D3::Dataset. More...
 
template<typename T , std::size_t SIZE, std::size_t SIZE2>
Selection DrawShape (emp::array< emp::array< emp::array< T, 2 >, SIZE >, SIZE2 > &data)
 If you pass a triple-nested array, it will be treated as an array of paths. More...
 
int GetID () const
 
void Log () const
 

Protected Attributes

int id
 

Detailed Description

An area is defined by two lines, with the area in between shaded.

Constructor & Destructor Documentation

D3::AreaGenerator::AreaGenerator ( )
inline

Member Function Documentation

template<typename X_SCALE_TYPE >
void D3::LineGenerator::AddXScale ( X_SCALE_TYPE &  scale)
inlineinherited

Often, when you're drawing cartesion lines, you want to use a scale to transform numbers from range of your data to the range of pixels on your screen. Adding an X scale will cause the x-coordinates of all points on the line to be passed through that scale function. This stacks on top of whatever the current function for accessing x is (which means scales will also stack).

template<typename Y_SCALE_TYPE >
void D3::LineGenerator::AddYScale ( Y_SCALE_TYPE &  scale)
inlineinherited

Often, when you're drawing cartesion lines, you want to use a scale to transform numbers from range of your data to the range of pixels on your screen. Adding a Y scale will cause the y-coordinates of all points on the line to be passed through that scale function. This stacks on top of whatever the current function for accessing y is (which means scales will also stack).

template<typename T , std::size_t SIZE>
Selection D3::SvgShapeGenerator::DrawShape ( emp::array< emp::array< T, 2 >, SIZE > &  data,
Selection s 
)
inlineinherited

Draws the path associated with [data] onto the [s] selection (must contain a single SVG) element).

Selection D3::SvgShapeGenerator::DrawShape ( Dataset  data,
Selection  s 
)
inlineinherited

DrawShape will also accept a D3::Dataset.

template<typename T , std::size_t SIZE, std::size_t SIZE2>
Selection D3::SvgShapeGenerator::DrawShape ( emp::array< emp::array< emp::array< T, 2 >, SIZE >, SIZE2 > &  data)
inlineinherited

If you pass a triple-nested array, it will be treated as an array of paths.

template<typename T , size_t SIZE>
std::string D3::SvgShapeGenerator::Generate ( emp::array< emp::array< T, 2 >, SIZE > &  data)
inlineinherited

Generate the string describing the path associated with [data] Assumes [data] is an array of 2-element arrays describing (x,y) coordinates and makes the line that connects them

int D3::D3_Base::GetID ( ) const
inlineinherited
void D3::D3_Base::Log ( ) const
inlineinherited
void D3::BaseLineGenerator::SetCurve ( std::string  curve)
inlineinherited

Set the method used to interpolate a curve between points in the line. For allowed options, see the d3 documntation

void D3::BaseLineGenerator::SetDefined ( std::string  defined)
inlineinherited

Set a function indicating where the line is defined (i.e. valid) Can be a C++ function or a string indicating a Javascript function

void D3::BaseLineGenerator::SetTension ( float  tension)
inlineinherited

If interpolation is "bundle", "cardinal", "cardinal-open", or "cardinal-closed", a tension parameter is used.

void D3::LineGenerator::SetX ( std::string  x)
inlineinherited

If the data that you are generating lines from is anything more complicated than a sequence of pairs of numbers, representing x and y (in that order), you need to tell the line generator how it should figure out what the x coordinate of a point in the line is. The parameter you pass to SetX should be instructions for doing so. It can either be a function (as a string indicating a Javascript function or as a literal C++ function) that accepts an element of the data sequence you are generating the line from, or it can be a constant, in which case the x coordinate of every point will be that constant.

Note: This function will re-set any scales that you've added to the X coordinate

As an example, the default function expects data like this (array of arrays): [[0,0], [1,1], [2,2]] And has (a Javascript equivalent of) this accessor: int x(emp::array<int, 2> d) {return d[0];}

If your data instead looked like this (array of Javascript objects with x and y values): [{x:0, y:0}, {x:1, y:1}, {x:2, y:2}] You might want to use an accessor like this: int x(JSONObject d) {return d.x();} Where JSONObject is a struct designed to hold necessary data from the Javascript object: struct JSONObject { EMP_BUILD_INTROSPECTIVE_TUPLE( int, x, int, y ) };

template<typename T >
void D3::AreaGenerator::SetX0 ( x)
inline
void D3::AreaGenerator::SetX0 ( std::string  x)
inline
template<typename T >
void D3::AreaGenerator::SetX1 ( x)
inline
void D3::AreaGenerator::SetX1 ( std::string  x)
inline
void D3::LineGenerator::SetY ( std::string  y)
inlineinherited

If the data that you are generating lines from is anything more complicated than a sequence of pairs of numbers, representing x and y (in that order), you need to tell the line generator how it should figure out what the y coordinate of a point in the line is. The parameter you pass to SetY should be instructions for doing so. It can either be a function (as a string indicating a Javascript function or as a literal C++ function) that accepts an element of the data sequence you are generating the line from, or it can be a constant, in which case the y coordinate of every point will be that constant.

Note: This function will re-set any scales that you've added to the Y coordinate

As an example, the default function expects data like this (array of arrays): [[0,0], [1,1], [2,2]] And has (a Javascript equivalent of) this accessor: int x(emp::array<int, 2> d) {return d[1];}

If your data instead looked like this (array of Javascript objects with x and y values): [{x:0, y:0}, {x:1, y:1}, {x:2, y:2}] You might want to use an accessor like this: int x(JSONObject d) {return d.y();} Where JSONObject is a struct designed to hold necessary data from the Javascript object: struct JSONObject { EMP_BUILD_INTROSPECTIVE_TUPLE( int, x, int, y ) };

template<typename T >
void D3::AreaGenerator::SetY0 ( y)
inline
void D3::AreaGenerator::SetY0 ( std::string  y)
inline
template<typename T >
void D3::AreaGenerator::SetY1 ( y)
inline
void D3::AreaGenerator::SetY1 ( std::string  y)
inline

Member Data Documentation

int D3::D3_Base::id
protectedinherited

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