Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Radio button does not work in dash

I am trying to display data on chart using radio buttons. Please see code below and solve the issue.

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import pandas as pd
import yfinance
from dash.exceptions import PreventUpdate

df = yfinance.download("MSFT", "2020-01-01", "2020-06-26")
df.reset_index(inplace=True)

def update_graph(radio_items):
   fig = go.Figure()
   fig.add_trace(go.Scatter(x=df['Date'],
                        y=df['Close'],

                        name='Price',

                        marker=dict(color='red'),
                        hoverinfo='text',
                        hovertext=
                        '<b>Date</b>: ' + df['Date'].astype(str) + '<br>' +
                        '<b>Close Value</b>: ' + [f'{x:,.2f}' for x in df['Close']] + '<br>'
                        ))

   if radio_items == 'movav7':
    df['CMA7'] = df["Close"].rolling(window=10, min_periods=1).mean()
    fig.add_trace(go.Scatter(x=df['Date'],
                            y=df['CMA7'],

                            name='Price',

                            marker=dict(color='blue'),
                            hoverinfo='text',
                            hovertext=
                            '<b>Date</b>: ' + df['Date'].astype(str) + '<br>' +
                            '<b>Close Value</b>: ' + [f'{x:,.2f}' for x in df['CMA7']] + '<br>'

                            ))

   elif radio_items == 'movav14':
        df['CMA14'] = df["Close"].rolling(window=10, min_periods=1).mean()
        fig.add_trace(go.Scatter(x=df['Date'],
                                 y=df['CMA14'],

                                 name='Price',

                                 marker=dict(color='blue'),
                                 hoverinfo='text',
                                 hovertext=
                                 '<b>Date</b>: ' + df['Date'].astype(str) + '<br>' +
                                 '<b>Close Value</b>: ' + [f'{x:,.2f}' for x in df['CMA14']] + '<br>'

                                 ))




   fig.update_layout(title={
        "text":"MSFT Close Price",
        "y":0.9,
        "x":0.5,
    })

   return fig




app = dash.Dash(__name__, external_stylesheets=["https://fonts.googleapis.com/css2?family=Notable&display=swap"])
app.layout = html.Div([

html.Div([
    html.Br(), html.Br(),
    html.H1('Sample Sales Data Dashboard')], className='title'),


html.Div([
    dcc.RadioItems(id='radio_items',
                   options=[
                       {'label': 'Moving Average 7', 'value': 'movav7'},
                       {'label': 'Moving Average 14', 'value': 'movav14'}], className='radio'

                   )
    ], className='radio'),

html.Div([
    dcc.Graph(id='bar_line_1',
              config={'displayModeBar': 'hover'}, className='graph-01'),

 ], className='graph'),

  ])

@app.callback(Output('bar_line_1', 'figure'),
              [Input('radio_items', 'value')])

def get_radio(radio_items):
    if radio_items == None:
        raise PreventUpdate
    return [update_graph(radio_items)]



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