LED Display format as scientific notation

Is there a way to format the LEDDisplay() as scientific notation? My device returns small numbers like 8e-6. But the LEDDisplay() only displays this as 0.0000008. I would prefer to display as 8.00e-6.

I don’t see a property to format it, is there something I am missing or is this just the incorrect component to use?

Hi TollisH,

Unfortunately it doesn’t seem LEDDisplay supports that format, but you can get similar results filling a html.Div component with numbers formatted using Python’s string formatting. Going from the daq.LEDDisplay component example, you could do something like:

import dash
import dash_daq as daq
import dash_core_components as dcc
import dash_html_components as html

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

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

app.layout = html.Div([
    html.Div(
        id='my-LED-display',
        children=0
    ),
    dcc.Slider(
        id='my-LED-display-slider',
        min=0,
        max=1000000,
        step=1,
        value=0
    ),
])


@app.callback(
    dash.dependencies.Output('my-LED-display', 'children'),
    [dash.dependencies.Input('my-LED-display-slider', 'value')]
)
def update_output(value):
    return '%6e' % (value/1e6)

if __name__ == '__main__':
    app.run_server(debug=True)

Then it would just be a matter of styling the html.Div with an LED-like font. There seem to be a few on the internet, but with various licenses so I wasn’t sure about posting them here.

1 Like

Thanks so much for your detailed response nickest! :smiley: