Gauge Examples and Reference


Default Gauge

An example of a default Gauge without any extra properties.

using Dash
using DashDaq

external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"]

app = dash(external_stylesheets=external_stylesheets)

app.layout = html_div([
  daq_gauge(
      id="my-gauge",
      label="Default",
      value=6
  ),
  dcc_slider(
      id="my-gauge-slider",
      min=0,
      max=10,
      step=1,
      value=5
  ),
])

callback!(app,
    Output("my-gauge", "value"),
    [Input("my-gauge-slider", "value")]
) do value
    return value
end

run_server(app, "0.0.0.0", debug=true)

Minimum and Maximum

Specify the minimum and maximum values of the gauge, using the min and max properties.
If the scale is logarithmic the minimum and maximum will represent an exponent.

using Dash
using DashDaq

app = dash()

app.layout = daq_gauge(
  value=5,
  label="Default",
  max=20,
  min=0,
)  

run_server(app, "0.0.0.0", debug=true)

Current Value and Units

Show the current value of the gauge and the units with showCurrentValue=true
and units=<units>.

using Dash
using DashDaq

app = dash()

app.layout = daq_gauge(
  showCurrentValue=true,
  units="MPH",
  value=5,
  label="Default",
  max=10,
  min=0,
)  

run_server(app, "0.0.0.0", debug=true)

Logarithmic Gauge

To set the scale of the gauge to logarithmic use the property logarithmic=true.

using Dash
using DashDaq

app = dash()

app.layout = daq_gauge(
  logarithmic=true,
  value=5,
  label="Default",
  max=10,
  min=0,
)  


run_server(app, "0.0.0.0", debug=true)

Color

Set the color of the gauge by using the property color=<hex_color>.

using Dash
using DashDaq

app = dash()

app.layout = daq_gauge(
  color="#9B51E0",
  value=2,
  label="Default",
  max=5,
  min=0,
)  

run_server(app, "0.0.0.0", debug=true)

Color Gradient

Apply a color gradient to the gauge with the property:

color=Dict(
    "gradient" => true,
    "ranges" => Dict(
        "<color>" => [<value>, <value>],
        "<color>" => [<value>, <value>],
        "<color>" => [<value>, <value>]
    )
)
using Dash
using DashDaq

app = dash()

app.layout = daq_gauge(
  color=Dict("gradient" => true,"ranges" => Dict("green" => [0,6],"yellow" => [6,8],"red" => [8,10])),
  value=2,
  label="Default",
  max=10,
  min=0,
)  

run_server(app, "0.0.0.0", debug=true)

Size

Adjust the size of the gauge in pixels size=200.

using Dash
using DashDaq

app = dash()

app.layout = daq_gauge(
  size=200,
  value=2,
  label="Default",

) 

run_server(app, "0.0.0.0", debug=true)

Scale

Modify where the scale starts, the label interval, and actual interval
with the scale property.

using Dash
using DashDaq

app = dash()

app.layout = daq_gauge(
  label="Scale",
  scale=Dict("start" => 0, "interval" => 3, "labelInterval" => 2),
  value=3,
  min=0,
  max=24,
)  

run_server(app, "0.0.0.0", debug=true)

Gauge 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 (String; optional):
The ID used to identify this compnent in Dash callbacks.

value (Real; optional):
The value of gauge. If logarithmic, the displayed value will be the
logarithm of the inputted value.

size (Real; default 208):
The size (diameter) of the gauge in pixels.

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

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

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

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

showCurrentValue (Bool; optional):
If true, the current value of the gauge will be displayed.

digits (Real; default 1):
Number of digits for current value.

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

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

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

label is a String | Dict with keys:

  • label (String; optional)

  • style (Dict; optional)

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

scale (Dict; optional):
Configuration for the component scale.

scale is a Dict with keys:

  • custom (Dict; 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 Real | Dict with keys:

    • label (String; optional)

    • style (String; optional)

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

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

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

color (Dict; optional):
Color configuration for the gauge’s track.

color is a String | Dict with keys:

  • default (String; optional):
    Color used for current value text and other minor accents.

  • gradient (Bool; optional):
    Display ranges as a gradient between given colors.

  • ranges (Dict; optional):
    Define multiple color ranges on the gauge’s track. The key
    determines the color of the range and the value is the start,end
    of the range itself. Ranges must be contiguous along the entirety
    of the gauge’s range of values.

    ranges is a Dict with keys:

    • color (Array of Reals | Array of Realss; optional)

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

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

exceedMessage (String; optional):
Warning message when value exceed max.

lagingMessage (String; optional):
Warning message when value is laging from min.

textColor (String; optional):
text color for theme.