def render_add_job_content(style): global active_house if style == {"display": "block"}: return html.Div(id="add_job", children=[ html.Div(id="add_job_content"), dcc.Dropdown(id="jobs_device_dropdown", placeholder="Choose device", options=[{ "label": device.name, "value": device.id } for user in active_house.users for device in user.devices]), html.H4("Earliest Start time"), dcc.DatePickerSingle( id="est_date_picker", initial_visible_month=datetime.datetime.now()), html.Br(), dcc.Input(id="est_time_picker", type="time", placeholder="HH:MM"), html.H4("Latest start time"), dcc.DatePickerSingle( id="lst_date_picker", initial_visible_month=datetime.datetime.now()), html.Br(), dcc.Input(id="lst_time_picker", type="time", placeholder="HH:MM") ]),
def header_dropdown(): port_dropdown=dcc.Dropdown(id='ports-dropdown', options=[{'label': row["bunkering_port"].title(),'value': row["code"]} \ for index,row in df.drop_duplicates(subset=["bunkering_port"]).iterrows()], placeholder="Port/s (max 5)",multi=True) type_dropdown=dcc.Dropdown(id='types-dropdown', options=[{'label': row.title(),'value': row} \ for row in df.dropna(subset=["ConType"]).ConType.unique()], placeholder="Vessel type(s)",multi=True) date_start=dcc.DatePickerSingle( id='date-picker-start', min_date_allowed=dt(2014, 1, 1), max_date_allowed=dt(2019, 6, 1), initial_visible_month=dt(2014, 1, 1), display_format='DD-MM-YYYY', placeholder="01-01-2014") date_end=dcc.DatePickerSingle( id='date-picker-end', min_date_allowed=dt(2014, 1, 1), max_date_allowed=dt(2019, 6, 1), initial_visible_month=dt(2019, 6, 1), display_format='DD-MM-YYYY', placeholder="01-06-2019") return [html.H1("BUNKER ANALYTICS"),html.Div([date_start,date_end, port_dropdown,type_dropdown],className="box"), html.Div([html.Button("Refresh",id="update-button"), html.A(html.Button("Home",id="home-button"), href="http://gabrielfuentes.org")])]
def build_menu(start_date, options): return html.Div( id="header_viz", children=[ #html.H3("Visualization Module"), html.Span(children=[" "]), html.Div(id="site_dropdown", children=[ html.H5("Select the site you want to display"), html.Span(children=[" "]), dcc.Dropdown( id='site-id', style={'width': '380px'} ) ], className = "two column" ), html.Div(id="variable_dropdown", children=[ html.H5("Select the variable you want to display"), html.Span(children=[" "]), dcc.Dropdown( id='var-id', options=options, style={'width': '380px'} ) ], className = "two column" ), html.Div(id="date_picker", children=[ html.H5("Select the timeframe you want to display"), html.Span(children=[" "]), dcc.DatePickerSingle( id='starting-date', min_date_allowed=start_date, max_date_allowed=dt.today(), initial_visible_month=start_date, date=str(start_date) ), html.Span(children=[" "]), dcc.DatePickerSingle( id='ending-date', min_date_allowed=start_date, max_date_allowed=dt.today(), initial_visible_month=dt.today(), date=str(dt.today()) ), html.Span(children=[" "]), html.Button( id="submit-visu-button", n_clicks=0, children="Submit" ), ], className = "two column" ), ], className="row", )
def test_dtps010_local_and_session_persistence(dash_dcc): app = dash.Dash(__name__) app.layout = html.Div( [ dcc.DatePickerSingle(id="dps-local", persistence=True, day_size=47), dcc.DatePickerSingle( id="dps-session", persistence=True, persistence_type="session", day_size=47, ), ] ) dash_dcc.start_server(app) assert not dash_dcc.find_element("#dps-local input").get_attribute( "value" ) and not dash_dcc.find_element("#dps-session input").get_attribute( "value" ), "component should contain no initial date" for idx in range(3): local = dash_dcc.select_date_single("dps-local", index=idx) session = dash_dcc.select_date_single("dps-session", index=idx) dash_dcc.wait_for_page() assert ( dash_dcc.find_element("#dps-local input").get_attribute("value") == local and dash_dcc.find_element("#dps-session input").get_attribute( "value" ) == session ), "the date value should be consistent after refresh"
def cb(clicks): if clicks is None: return dash.no_update if clicks % 2 == 1: return [ dcc.DatePickerSingle( id="dps-memory", min_date_allowed=datetime(2010, 1, 1), max_date_allowed=datetime(2099, 12, 31), initial_visible_month=datetime.today().date() - timedelta(days=1), persistence=True, persistence_type="memory", day_size=47, ), dcc.DatePickerSingle( id="dps-none", min_date_allowed=datetime(2010, 1, 1), max_date_allowed=datetime(2099, 12, 31), initial_visible_month=datetime.today().date() - timedelta(days=1), day_size=47, ), ] else: return "switched"
def currency_stability_page(): layout = html.Div([ navbar(), dbc.Row([ dbc.Col([html.H6('Crypto-Currencies:'), dcc.Dropdown( id='currency-stability-currencies', options=[{'label': i, 'value': i} for i in data.CURRENCIES], value=['BTC', 'DASH'], multi=True ), html.H6('Country:'), dcc.Dropdown( id='currency-stability-countries', options=[{'label': i, 'value': i} for i in data.COUNTRIES], value='US', ), html.Div([ html.Div([ html.H6('Start Date:'), dcc.DatePickerSingle( id='currency-stability-start', min_date_allowed=data.MIN_DATE, max_date_allowed=data.MAX_DATE, date=data.DEFAULT_DATE )], style={'display': 'inline-block'}), html.Div([ html.H6('End Date:'), dcc.DatePickerSingle( id='currency-stability-end', min_date_allowed=data.MIN_DATE, max_date_allowed=data.MAX_DATE, date=data.MAX_DATE )], style={'display': 'inline-block'})])], md=4), dbc.Col([ dcc.Graph(id='currency-stability-graph'), ]) ]), dbc.Row([ html.Div([ html.P( """\ This page demonstrates the distinction between various methods of calculating the standard deviation of a cryptocurrency, as well as the ability of said methods to demonstrate the volatility of said cryptocurrency.\n Historically, stock traders have used the standard deviation of a stock's price in a preceding timeframe as a means of determining its "volatility", which is best defined as its range of probable price shifts in an upcoming market segment. Cryptocurrencies, like stocks, are also investments, and are often referred to as some of the most volatile investments traders can place their money in. Of course, as with any investment, high risks can yield high rewards, but awareness of these risks is critical to making an informed decision. \n The graph shown above is able to make use of one of two running averages to demonstrate the standard deviation's ability to predict price shifts. In "All time" mode, a running average of all data within the specified range is used to determine the standard deviation at a given point. This prevents significant changes in predictions from occurring due to price spikes, but can become wildly inaccurate over long intervals. "Last 12 hours" mode, on the other hand, utilizes a running average of the 12 hours of data preceding a given data point to determine the standard deviation. This allows the standard deviation to "forget" past trends to enable more accurate short-term predictions. However, this can result in gross overestimations of future value during moments of extreme volatility. \n Regardless of which mode is chosen, the graph displays six lines over the selected time interval. The most jagged and erratic of these is the actual price graph of the currency, similarly to that shown on this website's homepage. Surrounding it are five lines, four of which appear to nearly mirror about a centerline. The "centerline" is the running average for the selected mode at a given data points. Above and below this average are the first standard deviations from the mean. Due to the mathematical properties of standard deviation calculations and limitations of reliance on historical data, it can be assumed that there is a 68.1% chance for the following price point to fall within this range. \n The two lines surrounding the first standard deviations are the second standard deviations. It can be assumed that there is a 95.3% chance for the following price point to fall within this range. \n Key concepts covered for this query included the use of the Oracle SQL "OVER" clause to generate running averages, the use of the SQL "STDDEV" command to determine the standard deviation of a given data set, and combination of these results to generate appropriate statistical ranges for the data.""" ) ], style = {'margin-left' : '30px', 'margin-right' : '30px'}) ]) ]) return layout
def add_job_modal(): return html.Div( html.Div( [ html.Div( [ # header html.Div( [ html.Span( "Add Job", style={ "color": "#506784", "fontWeight": "bold", "fontSize": "20", }, ), html.Span( "×", id="job_modal_close", n_clicks=0, style={ "float": "right", "cursor": "pointer", "marginTop": "0", "marginBottom": "17", }, ), ], className="popup", style={"borderBottom": "1px solid #C8D4E3"}, ), # form html.Div( id="add_jobs_content", children=[ dcc.Dropdown(id="jobs_device_dropdown"), dcc.DatePickerSingle(id="est_date_picker"), dcc.Input(id="est_time_picker"), dcc.DatePickerSingle(id="lst_date_picker"), dcc.Input(id="lst_time_picker") ]), html.Button("Save", id="save_job", n_clicks_timestamp="0", className="button button--primary add"), html.Button("Delete") ], className="modal_content", style={"textAlign": "center"}, ) ], className="modal", ), id="job_modal", style={"display": "none"}, )
def DatePickerSingles(): return [[html.Label('Default'), dcc.DatePickerSingle(date=dt.now())], [ html.Label('Max and Min Date Allowed'), dcc.DatePickerSingle( date=dt(2017, 2, 15), min_date_allowed=dt(2017, 2, 10), max_date_allowed=dt(2017, 2, 20), ) ], [ html.Label('Vertical'), dcc.DatePickerSingle(date=dt(2017, 2, 15), calendar_orientation='vertical') ], [ html.Label('Clearable'), dcc.DatePickerSingle(date=dt(2017, 2, 15), min_date_allowed=dt(2017, 2, 10), max_date_allowed=dt(2017, 2, 20), calendar_orientation='vertical') ], [ html.Label('Number of Months Shown'), dcc.DatePickerSingle(date=dt(2017, 2, 15), number_of_months_shown=3) ], [ html.Label('Placeholder'), dcc.DatePickerSingle(placeholder='Select a date...') ], [ html.Label('Show Outside Days'), dcc.DatePickerSingle(date=dt.now(), show_outside_days=True) ], [ html.Label('Full Screen Portal'), dcc.DatePickerSingle(date=dt.now(), with_full_screen_portal=True) ], [ html.Label('Portal'), dcc.DatePickerSingle(date=dt.now(), with_portal=True) ], [ html.Label('Day Size'), dcc.DatePickerSingle(date=dt.now(), day_size=50) ]]
def thirdpage(df, df1uk, SpecialDates): col1 = dbc.Col( html.Div( [html.H6('Time series prediction'), dcc.DatePickerSingle( id='single-date-picker-range', min_date_allowed=df1uk.date.min(), max_date_allowed=df1uk.date.max(), initial_visible_month=df1uk.date.max(), date=df1uk.date.max(), style={'background-color': 'red', 'color': 'red'} ), html.Button('Predict', id='predict', n_clicks=0), dcc.Graph(figure=predict_series(df1uk, str(dt.datetime.now()), SpecialDates, n=df1uk.shape[0]), id="time_series_graph"), ], # className='mini_container' ), className='box1' , width=6) col2 = dbc.Col( html.Div( [html.H6('Similar countries'), dcc.Dropdown( id='column-dropdown', options=column_dropdown_options(), value='total_cases_per_million'), html.Button('Show', id='show', n_clicks=0), dcc.Graph(figure=world_map_plot('total_cases_per_million', df), id="world_map_graph")], # className='mini_container' ) ,width=6 ) content = dbc.Row([col1, col2]) return content
def first_row(self): col = html.Div([html.Div([create_paragraph(PROFILE_TEXTS['first_layer']['heading'], PROFILE_TEXTS['first_layer']['detail'])]), html.Div([ html.Div([ html.H6('Select PV penetration (in %)'), dcc.Slider(id='pv', min=0, max=100, value=0, marks={i: '{}%'.format(i) for i in range(0, 100, 10)},className='h2'),\ dcc.Graph(id="load-duration-curve", className='mt-5')], className="DropDown"), html.Div([ html.H6('Select a day to show load profile:'), dcc.DatePickerSingle( id='date-picker-single', date=str(dt(self.settings['year'], 1, 1)), className='h2'), dcc.Graph(id="load-curve",className='mt-3')], className="DropDown"), ]), html.Div([ html.Div([html.H6("Important statistics related to load profiles"), dash_table.DataTable( id='table', style_cell={'textAlign': 'left', 'backgroundColor': '#1e2130','color': 'white'}, style_as_list_view=True)], className='DropDown')]) ]) return col
def display_date_selector(product_value): if product_value == 'climate-for-day': return dcc.DatePickerSingle( id='date', display_format='MM-DD', date=today )
def _assemble_datepickersingle_html( self, minimum: Any = None, maximum: Any = None, wrapper_class_name: str = None, label_class_name: str = None, filter_class_name: str = None, ): return html.Div( className=wrapper_class_name, children=[ html.Div( className=label_class_name, children=self.label_string, ), dcc.DatePickerSingle( id=self.component_id, className=filter_class_name, min_date_allowed=minimum, max_date_allowed=maximum, initial_visible_month=maximum, date=self.default_value, persistence=self.persistence, persistence_type=self.persistence_type, ), ], )
def create_layout(app): return html.Div([ html.Div(id="ff"), # represents the URL bar, doesn't render anything html.H1(children='Gerar Laminas', style={ 'textAlign': 'center', }), html.Div(id='dlinl1'), dcc.Dropdown(id='demo-dropdown', options=[ { 'label': 'ZEUS', 'value': '34691362000198' }, { 'label': 'FENIX', 'value': '26631527000108' }, ], placeholder='selecione o fundo'), html.Div(id='datepickerr'), dcc.DatePickerSingle( id='datepicker', date=day, display_format='MMM Do, YY', ), html.Div(id='dlinl1link'), dcc.Link('SUBMIT', href='/gerarlamina'), html.Div(id='lala') ])
def test_cdpr001_date_clearable_true_works(dash_dcc): app = dash.Dash(__name__) app.layout = html.Div( [ dcc.DatePickerRange(id="dpr", clearable=True), dcc.DatePickerSingle(id="dps", clearable=True), ] ) dash_dcc.start_server(app) # DPR start_date, end_date = dash_dcc.select_date_range("dpr", (1, 28)) close_btn = dash_dcc.wait_for_element('button[aria-label="Clear Dates"]') assert ( "1" in start_date and "28" in end_date ), "both start date and end date should match the selected day" close_btn.click() start_date, end_date = dash_dcc.get_date_range("dpr") assert ( not start_date and not end_date ), "both start and end dates should be cleared" # DPS selected = dash_dcc.select_date_single("dps", day="1") assert selected, "single date should get a value" close_btn = dash_dcc.wait_for_element("#dps button") close_btn.click() single_date, = dash_dcc.get_date_range("dps") assert not single_date, "date should be cleared"
def side_bar(call_with_db): date_range = call_with_db(data.get_date_range) markdown_text=''' Cada día se procesa el [Boletín Oficial del Estado](https://boe.es/) para que puedas verlo de forma resumida aquí. Cada diario del BOE tiene entradas organizadas en secciones y éstas a su vez en departamentos. A veces las entradas van asociadas con un gasto económico (en licitaciones por ejemplo), y verlo supone tener que abrir cada boletín. Esta página se creó para facilitar dicha información. **Selecciona el día en el campo que hay debajo para cambiar el día mostrado en el espacio de la derecha.** #### **Día** ''' content = html.Div(className='col border-end mt-4 text-muted', children=[ dcc.Markdown(children=markdown_text), dcc.DatePickerSingle( id='date-picker', min_date_allowed=date_range[0], max_date_allowed=date_range[1], date=date_range[1] ) ]) return content
def test_dtps001_simple_click(dash_dcc): app = dash.Dash(__name__) app.layout = html.Div( [ html.Label("Operating Date"), dcc.DatePickerSingle( id="dps", min_date_allowed=datetime(2010, 1, 1), max_date_allowed=datetime(2099, 12, 31), initial_visible_month=datetime.today().date() - timedelta(days=1), day_size=47, ), ], style={ "width": "10%", "display": "inline-block", "marginLeft": 10, "marginRight": 10, "marginBottom": 10, }, ) dash_dcc.start_server(app) date = dash_dcc.find_element("#dps input") assert not date.get_attribute("value") assert dash_dcc.select_date_single( "dps", index=3 ), "Component should be clickable to choose a valid date"
def interaction_tool(): """ Returns the iteraction tool as a dash `html.Div`. The view is a 8:3 division between visualization and controls. """ return html.Div( children=[ html.Div(children=[dcc.Graph(id='interaction-figure')], className='nine columns'), html.Div( children=[ # datePicker tool html.Div([ html.H5("Choose a date to explore contemporary news"), dcc.DatePickerSingle( id='my-date-picker-single', min_date_allowed=dt(1900, 1, 1), max_date_allowed=dt(2018, 12, 31), initial_visible_month=dt(2008, 6, 15), date=str(dt(2008, 6, 15, 23, 59, 59))), html.Div(id='output-container-date-picker-single'), html.Br(), html.H6("Possible dates: 01/01/1900 - 12/31/2018") ]), ], className='three columns', style={ 'marginLeft': 5, 'marginTop': '10%' }), ], className='row eleven columns')
def to_html_inputs(cls): """ construct ui input from the class constructor arguments spec """ spec = inspect.getfullargspec(cls) args = [arg for arg in spec.args if arg != 'self'] annotations = spec.annotations defaults = [ cls.marshal_data_for_ui(default) for default in spec.defaults ] divs = [] states = [] for i, arg in enumerate(args): left = html.Label(arg, style={ 'display': 'inline-block', 'width': '100px' }) annotation = annotations.get(arg) default = defaults[i] if annotation is bool: right = daq.BooleanSwitch(id=arg, on=default) state = State(arg, 'value') elif 'level' == arg: right = dcc.Dropdown(id=arg, options=[{ 'label': item.value, 'value': item.value } for item in IntervalLevel], value=default) state = State(arg, 'value') elif 'timestamp' in arg: right = dcc.DatePickerSingle(id=arg, date=default) state = State(arg, 'date') else: if 'filters' == arg and default: default = json.dumps(default, cls=CustomJsonDecoder) if 'columns' == arg and default: columns = [column.name for column in default] default = ','.join(columns) if isinstance(default, list) or isinstance(default, dict): default = json.dumps(default) right = dcc.Input(id=arg, type='text', value=default) state = State(arg, 'value') right.style = {'display': 'inline-block'} divs.append(html.Div([left, right], style={'margin-left': '120px'})) states.append(state) return divs, states
def date_input(): min_date = datetime.now() - timedelta(days=1) max_date = min_date + timedelta(days=90) date_input_field = dcc.DatePickerSingle(id='date', min_date_allowed=min_date, max_date_allowed=max_date, initial_visible_month=min_date) return date_input_field
def make_layout(): """ Make the Dash Layout. This is in a function so it gets the live data when the layout is initially created. Subsequent updates are handled with the callbacks below. """ channels = get_channels_dict() def_name = 92 fig = make_plot(def_name, start=datetime.now() - timedelta(days=1)) fig.update_layout(title="Last 24 Hours") _lv = get_live_values(92) default_live_value = _lv if _lv is not None else 0 layout = html.Div( children=[ html.H1('Walnuts Temperature', style={ 'textAlign': 'center', 'color': '#7FDBFF' }), html.H1(round(default_live_value, 2), id="live_val1"), html.Div( children=[ dcc.Interval( id='interval-component', interval=5 * 60 * 1000, # in milliseconds n_intervals=0), dcc.Checklist(id='chan_chk', options=[{ 'label': v, 'value': k } for k, v in channels.items()], labelStyle={'display': 'inline-block'}, value=[def_name], style={'flex': 1}), dcc.DatePickerSingle(id='start-date-picker', min_date_allowed=date(2022, 1, 1), max_date_allowed=date.today(), initial_visible_month=date.today(), date=date.today() - timedelta(days=1), style={'flex': 1}) ], style={ 'padding': 10, 'display': 'flex', 'flex-direction': 'row' }, ), dcc.Graph(id='line-graph', figure=fig) ], id="dash-container", style={ 'padding': 10, 'flex-direction': 'row' }, ) return layout
def date_picker(self, caption=None, id=None, prefix_id='', initial_date=datetime.date.today(), offset=None, width=155): if isinstance(id, str): id = [id] date_picker_list = [html.P(caption)] if prefix_id != '': prefix_id = prefix_id + '-' for i in range(0, len(id)): id_ = id[i] offset_ = 0 if offset is not None: offset_ = offset[i] # date_picker_list.append(dcc.Input( # id=prefix_id + id_, # type='date', # value=datetime.date.today() - datetime.timedelta(days=60) # )) date_picker_list.append( html.Div( children=dcc.DatePickerSingle( id=prefix_id + id_, min_date_allowed=datetime.date.today() - datetime.timedelta(days=365 * 3), max_date_allowed=datetime.date.today(), date=initial_date + datetime.timedelta(days=offset_), display_format='DD/MM/YY'), style={ 'padding': 5, 'height': 5, 'font-size': '24px !important' }, )) #if i < len(id) - 1: # date_picker_list.append(' to ') return html.Div(date_picker_list, style={ 'width': str(width) + 'px', 'display': 'inline-block', 'marginBottom': 0, 'marginTop': 0, 'marginLeft': 5, 'marginRight': 5 })
def date_selector(section): df = pd.read_csv('energy_data/' + str(section)) df['Date'] = df['Datetime'].apply(lambda x: x.split(' ')[0]) return dcc.DatePickerSingle(id='my-date-picker', display_format='D/M/Y', min_date_allowed=df['Date'].iloc[0], max_date_allowed=df['Date'].iloc[-1], date=df['Date'].iloc[0])
def update_output(value): return dcc.DatePickerSingle( id="dps", min_date_allowed=datetime(2020, 1, 1), max_date_allowed=datetime(2020, 1, 7), date=datetime(2020, 1, 3, 1, 1, 1, value), persistence=True, persistence_type="session", )
def get_app_layout(): date_select = dcc.DatePickerSingle(id='date-selector', min_date_allowed=dt(2020, 8, 1), max_date_allowed=date.today(), initial_visible_month=dt(2020, 8, 1)) country_select = dcc.Dropdown(id='selector', value=['Colombia'], multi=True) tab1_content = dbc.Card( dbc.CardBody([ dcc.Loading(id="loading-1", type="default", children=html.Div(id="container-heatmap")) ]), className="mt-3", ) tab2_content = dbc.Card( dbc.CardBody([ html.Div([ dbc.Row(dbc.Col(country_select, width={ "size": 6, "offset": 3 })), dbc.Row( dbc.Col(dcc.Graph(id='graph-container'), width={ "size": 6, "offset": 3 })) ], style={"padding-top": "20px"}) ]), className="mt-3", ) return dbc.Container([ dcc.Store(id='memory-output'), html.H1("Popular Songs!"), html.Hr(), html.Div([date_select]), dcc.Loading(id="loading-2", type="default", children=html.Div(id="loading-data-div")), dbc.Tabs([ dbc.Tab(label='Audio Features Heatmap', tab_id='heatmap', children=tab1_content), dbc.Tab(label='Compare countries', tab_id='scatter_polar', children=tab2_content) ], id='tabs', active_tab='heatmap'), html.Div(id='tab-content', className='p-4') ])
def render_iv_card(): ivs = interventions_to_rows() iv_table = dash_table.DataTable( id='interventions-table', data=ivs, columns=[ {'name': _('Date'), 'id': 'date'}, {'name': _('Event'), 'id': 'label'}, {'name': _('Value'), 'id': 'value', 'editable': True}, {'name': '', 'id': 'unit'}, ], style_cell={'textAlign': 'left'}, style_cell_conditional=[ { 'if': {'column_id': 'value'}, 'textAlign': 'right' } ], row_deletable=True, style_as_list_view=True, ) iv_card = dbc.CardBody([ html.Div([ dbc.Form([ html.Span(_('Add a new event: ')), dcc.DatePickerSingle( id='new-intervention-date', display_format='YYYY-MM-DD', first_day_of_week=1, className="mx-3", ), dcc.Dropdown( id='new-intervention-id', options=[{'label': i.label, 'value': i.type} for i in INTERVENTIONS], style=dict(width="450px"), ), dbc.Input( id='new-intervention-value', type='number', size='6', style=dict(width="100px"), className="mx-3", placeholder=_('value'), ), dbc.Button( _("Add"), id='new-intervention-add', color='primary' ), ], inline=True), ], className="mb-3"), iv_table, html.Div(dbc.Button( _('Restore default events'), id='interventions-reset-defaults', color='secondary', size='sm', className='mt-3' ), className='text-right'), ], className="px-5"), return iv_card
def renderDatePicker(sd): print('renderDatePicker now {}'.format(dt.now().strftime("%Y-%m-%d"))) dp = dcc.DatePickerSingle( id='TASKS_date', placeholder='Enter a start date...', display_format='YYYY-MM-DD', min_date_allowed=sd, #max_date_allowed=dt.now().strftime("%Y-%m-%d"), initial_visible_month=sd, date=str(sd)) return dp
def serve_layout(): return html.Main( [ dcc.Dropdown( id='deviceid', options=[ {'label': 'ST1', 'value': ''}, {'label': 'ST2', 'value': ''}, {'label': 'ST3', 'value': ''}, {'label': 'ST4', 'value': ''}, {'label': 'ST5', 'value': ''}, {'label': 'ST6', 'value': ''}, {'label': 'ST7', 'value': ''}, {'label': 'ST8', 'value': ''}, {'label': 'ST9', 'value': ''}, {'label': 'ST10', 'value': ''}, {'label': 'STDemo', 'value': ''} ], value='36a8d4b0-618c-11e8-ab9e-8f4bf9a263e5' ), dcc.Dropdown( id='key', options=[ {'label': 'RSRP', 'value': 'rsrp'}, {'label': 'RSRQ', 'value': 'rsrq'}, {'label': 'SNR', 'value': 'snr'} ], value='rsrp' ), dcc.DatePickerSingle( id='datepicker', # layout settings first_day_of_week=1, display_format='YYYY-MM-DD', placeholder='Select Date', # date defaults date=datetime.now(), # date limits min_date_allowed=datetime(2018, 1, 1), # today max_date_allowed=datetime.now(), initial_visible_month=datetime( datetime.now().year, datetime.now().month, 1 ) ), html.Button( 'Select Date', id='button' ), dcc.Graph(id='plot', figure=fig_init) ], )
def _get_component_for(self, key, val): field_type = self.table._get_type(key) value = self._get_value_for(key, val) if field_type == self.table.ID: component = html.Div(id=self._get_field_entry_id('id'), children=value) elif field_type == self.table.SET: attr = self.table.get_attribute(key) attr_type = attr.py_type options = [{'label': entry.label(), 'value': repr(entry)} for entry in attr_type.select().fetch()] component = dcc.Dropdown(id=self._get_field_entry_id(key), options=options, value=value, multi=True) elif field_type == self.table.REFERENCE: attr = self.table.get_attribute(key) attr_type = attr.py_type options = [{'label': entry.label(), 'value': repr(entry)} for entry in attr_type.select().fetch()] component = dcc.Dropdown(id=self._get_field_entry_id(key), options=options, value=value) elif field_type == self.table.DATE: date_picker_kwargs = dict( id=self._get_field_entry_id(key), display_format='D MMM YYYY', clearable=True, with_portal=True, ) if val: date_picker_kwargs['date'] = value component = dcc.DatePickerSingle(**date_picker_kwargs) elif field_type == self.table.STR: component = dcc.Input(id=self._get_field_entry_id(key), placeholder=value, value=value, style=self.FULL_WIDTH) elif field_type == self.table.BOOL: component = dcc.Checklist(id=self._get_field_entry_id(key), options=[{'label': key, 'value': key}], values=value) elif field_type == self.table.DECIMAL: component = dcc.Input(id=self._get_field_entry_id(key), placeholder=value, value=value, style=self.FULL_WIDTH) return component
def datepicker(date_range): content = html.Div( className= 'mt-5 border-top border-bottom border-primary d-flex p-4 align-items-center', children=[ html.Span(className='fw-bold text-primary me-3', children='Cambia la fecha del boletín'), dcc.DatePickerSingle(id=output_id, min_date_allowed=date_range[0], max_date_allowed=date_range[1], date=date_range[1]) ]) return content
def build_tab_1(): return [ # day wise statistics html.Div( id='daywiseplot', className='daywiseplot', children=[ html.Div( className="row", children=[ # Column for user controls html.Div( className="four columns div-user-controls", children=[ html.H2("SINGLE DAY SUMMARY"), html. P("""Select a particular day using the date picker for viewing specific summary and statistics.""" ), html.Div( className="div-for-dropdown", children=[ dcc.DatePickerSingle( id="date-picker", min_date_allowed=dt(2020, 3, 21), max_date_allowed=dt(2020, 7, 12), initial_visible_month=dt( 2020, 3, 21), date=dt(2020, 3, 21).date(), display_format="MMMM D, YYYY", style={ "border": "0px solid black" }) ]) ]), # Column for app graphs and plots html.Div( className="eight columns div-for-charts bg-grey", children=[ dcc.Graph(id='piechart', responsive=True), html.Div(id='daystats', className='daystats') ]) ]), html.Div(className='totplot', children=[generate_totplot()]), html.Div(className='daywiseplot', children=[generate_daywiseplot()]), html.Div(className='scoreplot', children=[generate_scoreplot()]) ]) ]