I’m trying to create a line chart which will display a metric on Y axis and time on X axis. When displaying data for last 7 days on X axis data is sorted in numerical ascending order rather than on logical order which should be 23 feb , 24 feb , 25 feb , 26 … 1 Mar, 2 Mar. Any pointers on how to custom sort X axis will be helpful.
Code, pasting only the graph part … results is a Pandas Data Frame loaded from sql db.
import plotly.graph_objs as go
dates = results[‘row_type’] # x axis last 7 days data
points = results[‘metric1’] # Y axis metric
figure = go.Figure(
data=[go.Scatter(x=dates, y=points, mode=‘lines+markers’,name=‘lines’)],