Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
month labels for x-axis
Browse files
app.py
CHANGED
|
@@ -773,6 +773,18 @@ def create_plot(username, year):
|
|
| 773 |
z[day][week] = activity_count[date]
|
| 774 |
hover_texts[day][week] = f"{date}: {activity_count[date]} activities"
|
| 775 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 776 |
# heatmap
|
| 777 |
fig = go.Figure(data=go.Heatmap(
|
| 778 |
z=z,
|
|
@@ -807,6 +819,9 @@ def create_plot(username, year):
|
|
| 807 |
scaleratio=1
|
| 808 |
),
|
| 809 |
xaxis=dict(
|
|
|
|
|
|
|
|
|
|
| 810 |
scaleanchor="y",
|
| 811 |
scaleratio=1,
|
| 812 |
fixedrange=True, # disable zoom and pan
|
|
|
|
| 773 |
z[day][week] = activity_count[date]
|
| 774 |
hover_texts[day][week] = f"{date}: {activity_count[date]} activities"
|
| 775 |
|
| 776 |
+
# month labels
|
| 777 |
+
month_labels = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]
|
| 778 |
+
month_positions = [0] # JAN
|
| 779 |
+
|
| 780 |
+
for month in range(2, 13):
|
| 781 |
+
|
| 782 |
+
first_day_of_month = datetime(year, month, 1).date()
|
| 783 |
+
|
| 784 |
+
month_position = (first_day_of_month - datetime(year, 1, 1).date()).days // 7
|
| 785 |
+
|
| 786 |
+
month_positions.append(month_position)
|
| 787 |
+
|
| 788 |
# heatmap
|
| 789 |
fig = go.Figure(data=go.Heatmap(
|
| 790 |
z=z,
|
|
|
|
| 819 |
scaleratio=1
|
| 820 |
),
|
| 821 |
xaxis=dict(
|
| 822 |
+
tickmode='array',
|
| 823 |
+
tickvals=month_positions,
|
| 824 |
+
ticktext=month_labels,
|
| 825 |
scaleanchor="y",
|
| 826 |
scaleratio=1,
|
| 827 |
fixedrange=True, # disable zoom and pan
|