Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Extract text from marks using RangeSlider

$
0
0

Is there a way to show and extract the text used in Marks.

I am looking for a way that tooltip = { ‘always_visible’: True } shows the text, for example: ‘3 °F’ when 3 is selected. And I want to use that value in the rest of my code, but I am only able to get the value 3 out of there with a callback.

import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output

app = dash.Dash()

app.layout = html.Div([
    dcc.RangeSlider(id='range_slider',
        min=0,
        max=10,
        step=None,
        marks={
            0: '0 °F',
            3: '3 °F',
            5: '5 °F',
            7.65: '7.65 °F',
            10: '10 °F'
        },
        value=[3, 7.65],
        tooltip = { 'always_visible': True }
    ),
    html.Div(id='output_slider')
])

@app.callback(
    Output(component_id='output_slider', component_property='children'),
    Input(component_id='range_slider', component_property='value')
)
def update_output(value):
    return 'The begin date is "{}" with value{}'.format(type(value), value)

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

Thanks in advanced

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images