Hi, I think this is a CSS question, but here goes.
I am trying to make an interactive bar chart where the user can drag two range slider handles to change the bar heights:
The purpose is to guess the breakdown of a budget by category.
I am tryin to figure out how I can change the CSS such that the range slider has three different colors:
Values 0 to left handle = blue
values left handle to right handle = red
Values right handle to 100 = green.
Below is my code. Any help would be much appreciated as I am not an expert in CSS or JS.
import plotly.express as px
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
# dummy global var for total $$
TOTAL = 45034567
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = JupyterDash(__name__,external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.P('Total Spending: '+str(TOTAL)),
dcc.RangeSlider(id='range-slider',
min=0,
max=100,
step=0.5,
value=[33.3,66.6],
),
html.Div(id='range-slider-drag-output'),
dcc.Graph(id='guess-spending')
])
@app.callback(Output('guess-spending','figure'),
Output('range-slider-drag-output','children'),
Input('range-slider','value'))
def make_guess(value):
# percents
a = value[0]
b = value[1]-value[0]
c = 100-value[1]
# dollar amounts
A = a/100*TOTAL
B = b/100*TOTAL
C = c/100*TOTAL
guess_dict = {'Category':['A','B','C'],
'Dollar Amount':[A,B,C]
}
guessFig = px.bar(guess_dict,
x='Category',
y='Dollar Amount',
color='Category',
title='Spending by Category, Your Estimate')
return guessFig, 'Your estimate: A: {}%, B: {}%, C: {}%'.format(round(a),round(b),round(c))
app.run_server(mode='external',port=8051) ```