Dimension

abstract class Dimension<DOMAIN, VALUE>(accessor: Datum<DOMAIN>.() -> VALUE, parentDimension: Dimension<DOMAIN, VALUE>?)

A dimension is an object that explains how a "DOMAIN" object is converted to a "VALUE" (which use the Dimension's accessor) and how this "VALUE" should be interpreted: numeric, temporal or discrete?

For example, your DOMAIN is a data class: data class WeatherRecord(val date:Date, val weather:WeatherType, val temperature:Double)

You can encode these different properties through Dimensions:

  • val temperatureDimension = quantitative( { domain.temperature } )

  • val weatherDimension = discrete( { domain.weatherType } )

  • val timeDimension = temporal( { domain.date } )

The Dimension constructor takes mandatory information:

  • the type of your value (discrete, temporal, quantitative...)

  • how to access your value (the accessor)

Dimension also has a DSL to specify various additional elements like:

  • the name of your value

  • its formatting function

For example: val temperatureDimension = quantitative( { domain.temperature } ) { name = "Mean daily temperature (in Celsius)" // the name (used on axes, tooltip or in legend) format = { "$this °C" } // the formatting function }

Constructors

Dimension
Link copied to clipboard
common
fun <DOMAIN, VALUE> Dimension(accessor: Datum<DOMAIN>.() -> VALUE, parentDimension: Dimension<DOMAIN, VALUE>? = null)

Functions

invoke
Link copied to clipboard
common
operator fun invoke(datum: Datum<DOMAIN>): VALUE
Calling Dimension(Datum) is the same as calling its accessor.

Properties

accessor
Link copied to clipboard
common
val accessor: Datum<DOMAIN>.() -> VALUE
The "accessor" is the lambda used to transform a DOMAIN object into a VALUE.
formatter
Link copied to clipboard
common
open var formatter: VALUE.() -> String? = null
The formatter for the VALUE this Dimension can generate.
isContinuous
Link copied to clipboard
common
val isContinuous: Boolean
Is this Dimension considered "continuous"?
isDiscrete
Link copied to clipboard
common
abstract val isDiscrete: Boolean
Is this Dimension considered "discrete"?
name
Link copied to clipboard
common
var name: String? = null
The name of this Dimension, this name is used as the title of the Axis based on it.

Inheritors

ContinuousDimension
Link copied to clipboard
DiscreteDimension
Link copied to clipboard