Dimension
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 }