def display_predicted_price(n_clicks, apt, ec, condo, time, radius,
                            postal_input, property_type, floor_num, floor_area,
                            lease):

    if n_clicks:

        ##### Current Global Listing Object #####
        global curr_listing
        curr_listing = Listing(postal_input, property_type, int(floor_num),
                               float(floor_area), int(lease))

        global price_output, price_psm_output
        price_output, price_psm_output = curr_listing.pred_price(
            "modelling/", cols, postal_code_area, area_df, sch, train,
            police_centre, avg_cases)

        # For testing
        #curr_listing = Listing('597592', 'Condominium', 6, 99, 70)
        #curr_listing = Listing('689527', 'Condominium', 6, 99, 70)

        ##### Parameters of Sample Object #####
        time_param = [0, 0]
        if (time == 'Past 5 Years'):
            time_param[0] = 1
        elif (time == 'Past 10 Years'):
            time_param[1] = 1

        radius_param = [0, 0]
        if (radius == 'Within 1km'):
            radius_param[0] = 1
        elif (radius == 'Within 2km'):
            radius_param[1] = 1

        ec_param, condo_param, apt_param = 0, 0, 0

        # Setting default property_filter to property_type of listing
        if ((not apt) and (not condo) and (not ec)):
            if (property_type == 'Condominium'):
                condo_param = 1
            elif (property_type == 'Apartment'):
                apt_param = 1
            elif (property_type == 'Executive Condominium'):
                ec_param = 1
        else:

            if ec:
                ec_param = 1
            if condo:
                condo_param = 1
            if apt:
                apt_param = 1

        ##### Current Global Sample Object #####
        global curr_sample
        params = {
            'radius': radius_param,
            'property': [ec_param, condo_param, apt_param],
            'time': time_param
        }
        curr_sample = Sample(params, prelim_ds)
        curr_sample.get_filtered_df(prelim_ds,
                                    curr_listing.get_lon(postal_code_area),
                                    curr_listing.get_lat(postal_code_area))
        curr_sample.get_map(curr_listing.get_lon(postal_code_area),
                            curr_listing.get_lat(postal_code_area),
                            price_psm_output, curr_listing.get_building(),
                            curr_listing.get_road_name(), 100)
        map_component = html.Iframe(srcDoc=open('sample_map.html', 'r').read(),
                                    height='600')

        transaction_table = curr_sample.get_transaction_table()

        psm_timeseries_plot = html.Div([
            html.Div([
                'Aggregated resale market conditions for ',
                html.B(
                    curr_listing.get_planning_area(postal_code_area,
                                                   area_df).title()),
                " planning area together with its 2 closest neighbours in the past "
                + str(curr_sample.get_time()) + ' years'
            ],
                     style={'font-size': 'medium'}),
            html.Div(
                'Only resale transactions of ' + ", ".join([
                    property + "s" for property in curr_sample.get_property()
                ]) +
                "  within each planning area are included within the computation",
                style={'font-size': 'medium'}),
            curr_sample.plot_psm(
                prelim_ds, area_df,
                curr_listing.get_planning_area(postal_code_area, area_df), 2),
        ])

        return [
            overview_section(curr_listing, price_output, price_psm_output),
            curr_listing.get_planning_area(postal_code_area, area_df).title(),
            transaction_features(curr_sample), map_component,
            transaction_table, psm_timeseries_plot,
            [
                'All resale transactions of ' + ", ".join([
                    property + "s" for property in curr_sample.get_property()
                ]) + "  in the past ",
                html.B(str(curr_sample.get_time()) + " years"),
                " that are within a radius of ",
                html.B(str(curr_sample.get_radius()) + "km"),
                " from your property"
            ]
        ]

    #### Default output

    # Map
    map_component = html.Iframe(srcDoc=open('assets/default_map.html',
                                            'r').read(),
                                height='600')

    # Timeseries

    filtered_df = prelim_ds.copy()
    filtered_df['Sale Month'] = filtered_df['Sale Date'].apply(
        lambda x: x.strftime('%Y-%m'))  # to plot based on Year and Month
    filtered_df['Sale Year'] = filtered_df['Sale Date'].apply(
        lambda x: x.year)  # to plot based on Year
    grp_df = filtered_df.groupby(['Sale Month',
                                  'Planning Area']).mean().reset_index()

    fig = px.line(
        grp_df,
        x="Sale Month",
        y="PPI",
        #color='Planning Area',
        labels={
            "Sale Month": "Year",
            "PPI": "Property Price Index"
        })

    fig.update_layout(plot_bgcolor='#f8f4f0')

    # To control white space surrounding the plot
    fig.update_layout(margin={'t': 15, 'b': 20, 'l': 20, 'r': 30})

    fig.update_layout(height=450)

    ts_plot = dcc.Graph(figure=fig)

    # Transaction Table
    df = prelim_ds[[
        'Sale Date', 'Address', 'Floor Number', 'Area (SQFT)',
        'Remaining Lease', 'Unit Price ($ PSF)'
    ]].copy()
    df = df.rename(columns={
        'Area (SQFT)': 'Floor Area',
        'BUILDING': 'Building Name'
    })
    df = df.sort_values(by=['Sale Date'], ascending=False).head(100)
    df['Sale Date'] = df['Sale Date'].apply(lambda x: x.date())

    table = dash_table.DataTable(
        data=df.to_dict('records'),
        columns=[{
            'id': c,
            'name': c
        } for c in df.columns],

        # Remove Pagination
        page_action='none',

        #For sorting by columns
        sort_action="native",

        # For filtering rows by column values
        filter_action="native",

        #style_as_list_view=True,
        style_table={
            'max-height': '400px',
            'font-size': '13px'
        },
        style_cell={
            'textAlign': 'center',
            'font-family': 'sans-serif',
            'width': '{}%'.format(len(df.columns))
            #'minWidth': '20px', 'width': '20px', 'maxWidth': '200px'
        },

        #Controilling width of columns
        style_cell_conditional=[
            {
                'if': {
                    'column_id': 'Sale Date'
                },
                'width': '5%'
            },
            {
                'if': {
                    'column_id': 'Address'
                },
                'width': '5.5%'
            },
        ],
        style_data={'padding-left': 7},

        #striped rows
        style_data_conditional=[{
            'if': {
                'row_index': 'even'
            },
            'backgroundColor': '#f2f2ed'
            #'lightgrey'
        }],

        #Fixed row for when scrolling vertically
        fixed_rows={'headers': True},
        style_header={
            'backgroundColor': 'rgb(255, 255, 255)',
            'fontWeight': 'bold',
            'padding-left': 7
        },
    )

    transaction_table = html.Div([
        html.Div('Past 100 Recent Transactions',
                 style={
                     'padding-bottom': 2,
                     'font-size': 'xx-large'
                 }), table
    ])

    return [
        "", 'Island Wide',
        transaction_features(full_sample), map_component, transaction_table,
        ts_plot,
        "Showing all resale transactions of Apartments, Condominiums, Executive Condominiums within the past 10 years"
    ]