def update_terms_figure(date, terms_df):  
    """
    Generate a figure frame using the date.
    Args:
        date: The date until to generate the frame.
        terms_df: Dataframe to use.
    """
    filtered_df = terms_df[terms_df['day'] <= date]
    days = [day for day in filtered_df['day'].unique()]
    terms = [term for term in filtered_df['term'].unique()]   
    traces = []
    
    for term in terms:
        counts = list(filtered_df[filtered_df['term'] == term]['count'])
        data_dict = {
            'x': days,
            'y': counts,
            'mode': 'lines',
            'text': [term],
            'name': term,
            'line': {
                'width': 1.5,
                'shape': 'spline'
            }
        }
        traces.append(data_dict)
            
    return {
        'data': traces,
        'layout': dict(
            xaxis = {
                'range': [terms_df['day'].min(), terms_df['day'].max()],
                'title': 'Publication Date',
                'showgrid': True
            },
            yaxis = {
                'range': [0, 3500],
                'title': '# Mentions',
                'showgrid': True
            },
            hovermode = 'x',
            legend_title_text='Trending Terms',
            ##title = 'Bi-grams in the news',
            paper_bgcolor = '#FFFFFF',
            plot_bgcolor = '#FFFFFF',
            font = dict(color = '#333333', family='SimplonRegular')
        )
    }