Skip to content

Files

1046 lines (485 loc) · 14.9 KB

scl.md

File metadata and controls

1046 lines (485 loc) · 14.9 KB

scl

Definition of cdv scales


This module contains the various scales that can be used to create elements in cdv where a scale is essentially just a mapping from some domain to a codomain. The scale types, the terminology and the basic behavior follow those of d3.js reasonably closely. One major difference in terminology is the use of the term range in d3 to denote what in cdv is called the codomain. The word range was intentionally avoided as it has a very strong association with the concept of ranges as abstractions built over iterators in C++.

File Description
time_scale.hpp MISSING
linear_scale.hpp MISSING
ordinal_scale.hpp MISSING
log_scale.hpp MISSING
band_scale.hpp Band scale and related properties
sequential_scale.hpp MISSING

time_scale.hpp

Source: cdv/scl/time_scale.hpp

time_scale<Clock, Duration, Codomain>

template <typename Clock, typename Duration, typename Codomain>
class cdv::scl::time_scale;
Nested Typedef Type Description
codomain_t Codomain MISSING
domain_t std::chrono::time_point<Clock, Duration> MISSING

Constructor: time_scale<Clock, Duration, Codomain>

MISSING

Overload 1:

time_scale<Clock, Duration, Codomain>(const cdv::scl::time_scale::domain_t & x0, const cdv::scl::time_scale::domain_t & x1, const Codomain & y0, const Codomain & y1)

MISSING

Overload 2:

time_scale<Clock, Duration, Codomain>(const date::year_month_day & x0, const date::year_month_day & x1, const Codomain & y0, const Codomain & y1)

MISSING


ticks

MISSING

std::vector<domain_t> ticks(const size_t num_ticks_hint) const

operator()

MISSING

Codomain operator()(const cdv::scl::time_scale::domain_t & x) const

tick_formatter

MISSING

template <class num_ticks_hint:auto>
auto tick_formatter(const auto num_ticks_hint) const

snapped_to_grid

MISSING

time_scale<Clock, Duration, Codomain> snapped_to_grid(const size_t num_ticks_hint) const

domain

MISSING

auto domain() const

codomain

MISSING

auto codomain() const

linear_scale.hpp

Source: cdv/scl/linear_scale.hpp

linear_scale<DomainType, CodomainType>

template <class DomainType, typename CodomainType>
class cdv::scl::linear_scale;
Nested Typedef Type Description
codomain_t CodomainType MISSING
domain_t DomainType MISSING

ticks

MISSING

std::vector<DomainType> ticks(const size_t num_ticks_hint) const

operator()

MISSING

CodomainType operator()(const DomainType & x) const

tick_formatter

MISSING

template <class num_ticks_hint:auto>
auto tick_formatter(const auto num_ticks_hint) const

snapped_to_grid

MISSING

linear_scale<DomainType, CodomainType> snapped_to_grid(const size_t num_ticks_hint) const

Constructor: linear_scale<DomainType, CodomainType>

MISSING

Overload 1:

linear_scale<DomainType, CodomainType>(const DomainType x0, const DomainType x1, const CodomainType y0, const CodomainType y1, const linear_scale_properties<CodomainType> & properties)

MISSING

Overload 2:

template <class domain:auto, class codomain:auto>
linear_scale<DomainType, CodomainType>(const stdx::range_of<DomainType> auto & domain, const stdx::range_of<CodomainType> auto & codomain, const linear_scale_properties<CodomainType> & properties)

MISSING


domain

MISSING

auto domain() const

codomain

MISSING

auto codomain() const

linear_scale_properties

template <typename CodomainType>
struct cdv::scl::linear_scale_properties;
Field Type Description
clamp bool MISSING
interpolate linear_interpolator<CodomainType> MISSING

linear_interpolatorcdv::pixels

struct cdv::scl::linear_interpolator;

operator()

MISSING

constexpr cdv::pixels operator()(const cdv::pixels a, const cdv::pixels b, const double t) const

linear_interpolator

struct cdv::scl::linear_interpolator;

operator()

MISSING

constexpr FloatingPointType operator()(const FloatingPointType a, const FloatingPointType b, const FloatingPointType t) const

ordinal_scale.hpp

Source: cdv/scl/ordinal_scale.hpp

ordinal_scale_properties

template <typename CodomainType>
struct cdv::scl::ordinal_scale_properties;
Field Type Description
default_result std::optional<CodomainType> MISSING

ordinal_scale<DomainType, CodomainType>

template <typename DomainType, typename CodomainType>
class cdv::scl::ordinal_scale;
Nested Typedef Type Description
codomain_t CodomainType MISSING
domain_t DomainType MISSING

operator()

MISSING

Overload 1:

cdv::scl::ordinal_scale::codomain_t operator()(const DomainType & x)

MISSING

Overload 2:

cdv::scl::ordinal_scale::codomain_t operator()(const DomainType & x) const

MISSING


domain

MISSING

auto domain() const

Constructor: ordinal_scale<DomainType, CodomainType>

MISSING

template <class domain:auto, class codomain:auto>
ordinal_scale<DomainType, CodomainType>(const stdx::range_of<DomainType> auto & domain, const stdx::range_of<CodomainType> auto & codomain, const ordinal_scale_properties<CodomainType> & properties)

codomain

MISSING

auto codomain() const

make_ordinal_scale

MISSING

template <typename DomainType, typename CodomainRange>
auto make_ordinal_scale(const CodomainRange & codomain, const ordinal_scale_properties<ranges::range_value_type_t<CodomainRange>> & properties)

log_scale.hpp

Source: cdv/scl/log_scale.hpp

log_scale_properties

template <typename CodomainType>
struct cdv::scl::log_scale_properties;
Field Type Description
base double MISSING
clamp bool MISSING
interpolate linear_interpolator<CodomainType> MISSING

log_scale<DomainType, CodomainType>

template <class DomainType, typename CodomainType>
class cdv::scl::log_scale;
Nested Typedef Type Description
codomain_t CodomainType MISSING
domain_t DomainType MISSING

ticks

MISSING

std::vector<DomainType> ticks(const size_t num_ticks_hint) const

operator()

MISSING

CodomainType operator()(const DomainType & x) const

tick_formatter

MISSING

template <class num_ticks_hint:auto>
auto tick_formatter(const auto num_ticks_hint) const

base

MISSING

double base() const

snapped_to_grid

MISSING

log_scale<DomainType, CodomainType> snapped_to_grid(const size_t num_ticks_hint) const

Constructor: log_scale<DomainType, CodomainType>

MISSING

Overload 1:

log_scale<DomainType, CodomainType>(const DomainType x0, const DomainType x1, const CodomainType y0, const CodomainType y1, const log_scale_properties<CodomainType> & properties)

MISSING

Overload 2:

template <class domain:auto, class codomain:auto>
log_scale<DomainType, CodomainType>(const stdx::range_of<DomainType> auto & domain, const stdx::range_of<CodomainType> auto & codomain, const log_scale_properties<CodomainType> & properties)

MISSING


domain

MISSING

auto domain() const

codomain

MISSING

auto codomain() const

symlog

MISSING

template <class T>
T symlog(const T base, const T x)

band_scale.hpp

Source: cdv/scl/band_scale.hpp

Notes

Band scales are useful in mapping some number of discrete objects to a continuous space such that each object is assigned it's own unique slice (a band) of that continuous space. The most obvious use case for band scales is in creating the bars of a bar chart. For example, in a bar chart with vertical bars, each bar should occupy some band of space along the x-axis.

The bands are a certain distance apart and you can control the amount of spacing between bands by specify a padding value which represents a fraction of that total distance between bands. There is an inner_padding property which controls the space between bands, and there is also an outer_padding property which controls the amount of spacing before the first and after the last band. Finally, there is an alignment_factor property with which the amount of outer padding assigned to beginning or the end of the bands can be controlled. The following diagram shows how the padding controls the spacing:

band_scale_properties

struct cdv::scl::band_scale_properties;
Field Type Description
alignment_factor double determines how much of the outer padding is assigned to before the bands and how much is assigned to after the bands. A value of 0.0 will assign no outer padding to before the bands and all outer padding to after the bands. A value of 1.0 will assign all outer padding to before the bands. The default value of 0.5 distributes the padding equally to before and after the bands.
inner_padding double The fraction of the distance between the centers of two bands that should be spacing between bands (default 0.0)
outer_padding double The fraction of the distance between the centers of two bands that should be spacing before the first and after the last bands (default 0.0)

These are the properties that control spacing in band scales. Normally these properties will only be used when creating a band scale. For example,

const auto s = cdv::scl::band_scale(my_keys, frame.x0(), frame.x1(),
                   {.inner_padding = 0.1, outer_padding = 0.2});

would create a band scale where the outer padding is wider than the inner padding, but the outer padding is the same on each end because the alignment factor was not explicitly set and therefore retains its default value of 0.5.

Constructor: band_scale_properties

Compiler generated constructors

Overload 1:

band_scale_properties()

compiler generated default constructor

Overload 2:

band_scale_properties(cdv::scl::band_scale_properties &&)

compiler generated move constructor

Overload 3:

band_scale_properties(const cdv::scl::band_scale_properties &)

compiler generated copy constructor


Destructor: ~band_scale_properties

compiler generated destructor

~band_scale_properties()

band_scale<DomainType, CodomainType>

template <typename DomainType, typename CodomainType>
class cdv::scl::band_scale;
Nested Typedef Type Description
codomain_t CodomainType A floating point (or floating point like) type which can be divided into bands.
domain_t DomainType A range of the type of object that is to be mapped to the bands.

min

MISSING

cdv::scl::band_scale::codomain_t min(const DomainType & x) const

Constructor: band_scale<DomainType, CodomainType>

Band scale constructor

template <class domain:auto>
band_scale<DomainType, CodomainType>(const stdx::range_of<cdv::scl::band_scale::domain_t> auto & domain, const cdv::scl::band_scale::codomain_t & codomain_start, const cdv::scl::band_scale::codomain_t & codomain_stop, const cdv::scl::band_scale_properties & properties)

Constructs a band scale that maps a range of objects of the domain type to individual bands within a continuous codomain interval

Argument Description
domain The domain objects that are to be mapped to bands.
codomain_start The start of the codomain interval
codomain_stop The end of the codomain interval
properties The band scale properties that determine the spacing around bands

ticks

MISSING

auto ticks(const size_t) const

operator()

MISSING

cdv::scl::band_scale::codomain_t operator()(const DomainType & x) const

tick_formatter

MISSING

auto tick_formatter(const size_t) const

band_width

MISSING

cdv::scl::band_scale::codomain_t band_width() const

max

MISSING

cdv::scl::band_scale::codomain_t max(const DomainType & x) const

domain

MISSING

auto domain() const

codomain

MISSING

auto codomain() const

sequential_scale.hpp

Source: cdv/scl/sequential_scale.hpp

sequential_scale<DomainType, Interpolator>

template <class DomainType, class Interpolator>
class cdv::scl::sequential_scale;
Nested Typedef Type Description
codomain_t std::invoke_result_t<Interpolator, DomainType> MISSING
domain_t DomainType MISSING
interpolator_t Interpolator MISSING

ticks

MISSING

std::vector<domain_t> ticks(const size_t num_ticks_hint) const

operator()

MISSING

constexpr auto operator()(const cdv::scl::sequential_scale::domain_t x) const

tick_formatter

MISSING

template <class num_ticks_hint:auto>
auto tick_formatter(const auto num_ticks_hint) const

Constructor: sequential_scale<DomainType, Interpolator>

MISSING

sequential_scale<DomainType, Interpolator>(const cdv::scl::sequential_scale::domain_t start, const cdv::scl::sequential_scale::domain_t stop, const cdv::scl::sequential_scale::interpolator_t & interpolator)

domain

MISSING

constexpr auto domain() const