I have a sqlite file that automatically updates each day with stats for each hour of that date. My function get_date_range() gets that data so that all hours (xaxis) (from 0 to 23 repeating) are in tdata[0] and the stat (yaxis) is in tdata[1]
I’m trying to create a graph in Dash that uses DatePickerRange to select a range of days and displays the hourly range in a graph, with the hour as a string on the x axis. The string itself is just the hour of the day (0, 1, etc).
The problem I’m having is that Dash won’t show any hours after 23 on the x axis. It should go 22, 23, 0, 1, 2, etc.
I’ve tried setting the xaxis type to category under both the data and layout sections (as suggested in the use-a-list-of-number-string-as-xaxis topic). I’ve tried setting the hour as both a string and an int within the list. Nothing seems to work unfortunately.
Would love if someone could tell me what I’m doing wrong here. My code for the callback is:
def update_tab3(start_date, end_date):
if end_date is not None and start_date is not None:
tdata = get_date_range(start_date, end_date)
figure = {
'data': [
{'x': tdata[0], 'y': tdata[1], 'type': 'line', 'name': 'Total L1',
'legendgroup': 'Level 1', 'marker': {'color': 'rgb(0, 0, 255)'}}
],
'layout': {
'title': 'Ticket Stats',
'plot_bgcolor': colors['background'],
'xaxis': {'title': 'Hour Of The Day', 'tickmode': 'linear', 'dtick': 1,
'type': 'category'},
'yaxis': {'title': 'Ticket Count', 'tickmode': 'linear', 'dtick': 10},
'legend': {'orientation': 'h', 'x': 0, 'y': -0.2, 'yanchor': 'top'},
'barmode': 'overlay'
}
}
return figure