Thermometer Examples and Reference


Default Thermometer

An example of a default Thermometer without any extra properties.

library(dash)
library(dashDaq)
library(dashHtmlComponents)
library(dashCoreComponents)

app <- Dash$new()

app$layout(htmlDiv(list(
  daqThermometer(
    id = 'my-thermometer-1',
    value = 5,
    min = 0,
    max = 10,
    style = list('margin-bottom' = '5%')
  ),
  dccSlider(
    id = 'thermometer-slider-1',
    value = 5,
    min = 0,
    max = 10
  )
)))

app$callback(
  output(id = "my-thermometer-1", property = "value"),
  params = list(input(id = "thermometer-slider-1", property = "value")),

  update_output <- function(value) {
    return(value)
  }
)

app$run_server()

Current value with units

Display the value of the thermometer along with
optional units with showCurrentValue and units.

library(dashDaq)

daqThermometer(
    min = 95,
    max = 105,
    value = 100,
    showCurrentValue = TRUE,
    units = "C"
)

Height and width

Control the size of the thermometer by setting height and width.

library(dashDaq)

daqThermometer(
    id = "my-daq-tsize",
    height = 150,
    width = 5,
    value = 5)

Label

Display a label alongside the thermometer in
the specified position by setting label and labelPosition.

library(dashDaq)

daqThermometer(
    id = "my-daq-tlabel",
    value = 5,
    label = "Current temperature",
    labelPosition = "top"
)

Custom scales

Control the intervals at which labels are displayed,
as well as the labels themselves with the scale property.

library(dashDaq)

daqThermometer(
  id = "my-daq-tscales",
  value = 5,
  scale = list(
    "start" = 2,
    "interval" = 3,
    "labelInterval" = 2,
    "custom" = list("2" = "ideal temperature",
                    "5" = "projected temperature")
  )
)

Thermometer Properties

Our recommended IDE for writing Dash apps is Dash Enterprise’s
Data Science Workspaces,
which has typeahead support for Dash Component Properties.
Find out if your company is using
Dash Enterprise
.

id (character; optional):
The ID used to identify this compnent in Dash callbacks.

value (numeric; optional):
The value of thermometer. If logarthmic, the value displayed will be
the logarithm of the inputted value.

height (numeric; default 192):
The height of the thermometer in pixels.

width (numeric; default 20):
The width of the thermometer in pixels.

color (character; optional):
The color of the thermometer fill/current value text.

min (numeric; default 0):
The minimum value of the thermometer. If logarithmic, represents the
minimum exponent.

max (numeric; default 10):
The maximum value of the thermometer. If logarithmic, represents the
maximum exponent.

base (numeric; default 10):
Base to be used in logarithmic scale.

logarithmic (logical; optional):
If set to TRUE, a logarithmic scale will be used.

showCurrentValue (logical; optional):
If TRUE, the current value of the thermometer will be displayed.

units (character; optional):
Label for the current value.

theme (named list; default light):
Theme configuration to be set by a ThemeProvider.

label (named list; optional):
Description to be displayed alongside the control. To control styling,
pass an object with label and style properties.

label is a character | named list with keys:

  • label (character; optional)

  • style (named list; optional)

labelPosition (a value equal to: ‘top’ or ‘bottom’; default 'top'):
Where the component label is positioned.

scale (named list; optional):
Configuration for the component scale.

scale is a named list with keys:

  • custom (named list; optional):
    Custom scale marks. The key determines the position and the value
    determines what will show. If you want to set the style of a
    specific mark point, the value should be an object which contains
    style and label properties.

    custom is a numeric | named list with keys:

    • label (character; optional)

    • style (character; optional)

  • interval (numeric; optional):
    Interval by which the scale goes up. Attempts to dynamically
    divide min-max range by default.

  • labelInterval (numeric; optional):
    Interval by which labels are added to scale marks. Defaults to 2
    (every other mark has a label).

  • start (numeric; optional):
    Value to start the scale from. Defaults to min.

className (character; optional):
Class to apply to the root component element.

style (named list; optional):
Style to apply to the root component element.