def get_ranks_graph(player=None): data = [] if player: races = player.select_races() points = [Data_point(race) for race in races] dates = [point.date for point in points] times = [point.scatter_time for point in points] relative_ranks = [point.relative_rank for point in points] markers = [point.marker for point in points] data = [go.Scatter( x=dates, y=times, text=markers, mode='markers', opacity=1, marker={ 'size': 12, 'line': {'width': 0.5, 'color': 'black'}, 'color': relative_ranks, 'showscale':False }, hoverinfo='text' )] return { 'data': data, 'layout': get_graph_layout(title='Bingo races', height=650) }
def get_PB_graph(player=None, version=None, player_update=False): graph = [] if player and version: races = player.select_races(sort='latest', type=version) if len(races) == 0: dates = [] times = [] markers = [] else: PBs = get_PB_races(races) newest = get_newest_version() dates = [PB.date for PB in PBs] times = [PB.time.total_seconds() for PB in PBs] if version == newest: dates.append(dt.date.today()) # pb still valid today times.append(times[-1]) # need last elements twice markers = get_markers(times, dates, version, newest) times = [ Utils.convert_to_human_readable_time(time)[0] for time in times ] data = [ go.Scatter(x=dates, y=times, mode='lines+markers', text=markers, marker={ 'size': 9, 'line': { 'width': 0.5, 'color': 'black' }, 'color': 'lightgreen' }, line=dict(shape='hv'), hoverinfo='text') ] graph = [ dcc.Graph( figure={ 'data': data, 'layout': get_graph_layout(title='PB progression', height=600) }) ] if player_update: graph = html.Div(graph, id='pb-graph-2') return graph
def get_race_point_graph(player=None): graph = [] if player: races = player.select_races(sort='latest') srl_races = [race for race in races if race.platform == 'srl'] rt_races = [race for race in races if race.platform == 'racetime'] if len(rt_races) > 20 or len(rt_races) > len(srl_races): races = rt_races platform = 'Racetime' else: races = srl_races platform = 'SRL' dates = [race.date for race in races] points = [race.points for race in races] markers = [ race.date.strftime('%b %d') + "<br>" + str(race.points) for race in races ] data = [ go.Scatter(x=dates, y=points, mode='lines+markers', text=markers, marker={ 'size': 7, 'line': { 'width': 0.5, 'color': 'black' }, 'color': 'lightblue' }, line=dict(shape='vh'), hoverinfo='text') ] graph = [ dcc.Graph( figure={ 'data': data, 'layout': get_graph_layout(title=f'{platform} points progression', height=600, y_label='Points', tickformat='') }) ] return graph
def get_SRL_point_graph(player=None): data = [] if player: races = player.select_races(sort='latest') dates = [race.date for race in races] points = [race.points for race in races] markers = [ race.date.strftime('%b %d') + "<br>" + str(race.points) for race in races ] data = [ go.Scatter(x=dates, y=points, mode='lines+markers', text=markers, marker={ 'size': 7, 'line': { 'width': 0.5, 'color': 'black' }, 'color': 'lightblue' }, line=dict(shape='vh'), hoverinfo='text') ] return { 'data': data, 'layout': get_graph_layout(title='SRL points progression', height=600, y_label='Points', tickformat='') }