Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -708,8 +708,6 @@ def get_data2():
|
|
| 708 |
|
| 709 |
|
| 710 |
#-------------------------------------------------------------------------------------------------------------------------------
|
| 711 |
-
colors = ['white', 'lightgreen', 'green', 'darkgreen']
|
| 712 |
-
|
| 713 |
# year->get all dates
|
| 714 |
def get_dates_in_year(year):
|
| 715 |
start_date = datetime(year, 1, 1)
|
|
@@ -764,7 +762,7 @@ def create_plot(username, year):
|
|
| 764 |
# data->Plotly
|
| 765 |
num_weeks = len(dates_in_year) // 7 + (1 if len(dates_in_year) % 7 != 0 else 0)
|
| 766 |
|
| 767 |
-
z = [[None for _ in range(num_weeks)] for _ in range(7)]
|
| 768 |
hover_texts = [["" for _ in range(num_weeks)] for _ in range(7)]
|
| 769 |
|
| 770 |
for idx, date in enumerate(dates_in_year):
|
|
@@ -778,11 +776,8 @@ def create_plot(username, year):
|
|
| 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
|
|
@@ -819,13 +814,13 @@ def create_plot(username, year):
|
|
| 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
|
| 828 |
-
showticklabels=False # hide the x-axis labels
|
| 829 |
),
|
| 830 |
autosize=False,
|
| 831 |
width=num_weeks * cell_size,
|
|
@@ -841,7 +836,7 @@ def create_plot(username, year):
|
|
| 841 |
|
| 842 |
fig.update_layout(
|
| 843 |
xaxis=dict(fixedrange=True), # disable zoom and pan
|
| 844 |
-
yaxis=dict(fixedrange=True)
|
| 845 |
)
|
| 846 |
|
| 847 |
return fig
|
|
|
|
| 708 |
|
| 709 |
|
| 710 |
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
| 711 |
# year->get all dates
|
| 712 |
def get_dates_in_year(year):
|
| 713 |
start_date = datetime(year, 1, 1)
|
|
|
|
| 762 |
# data->Plotly
|
| 763 |
num_weeks = len(dates_in_year) // 7 + (1 if len(dates_in_year) % 7 != 0 else 0)
|
| 764 |
|
| 765 |
+
z = [[None for _ in range(num_weeks)] for _ in range(7)]
|
| 766 |
hover_texts = [["" for _ in range(num_weeks)] for _ in range(7)]
|
| 767 |
|
| 768 |
for idx, date in enumerate(dates_in_year):
|
|
|
|
| 776 |
month_positions = [0] # JAN
|
| 777 |
|
| 778 |
for month in range(2, 13):
|
|
|
|
| 779 |
first_day_of_month = datetime(year, month, 1).date()
|
|
|
|
| 780 |
month_position = (first_day_of_month - datetime(year, 1, 1).date()).days // 7
|
|
|
|
| 781 |
month_positions.append(month_position)
|
| 782 |
|
| 783 |
# heatmap
|
|
|
|
| 814 |
scaleratio=1
|
| 815 |
),
|
| 816 |
xaxis=dict(
|
| 817 |
+
|
| 818 |
tickmode='array',
|
| 819 |
tickvals=month_positions,
|
| 820 |
+
ticktext=month_labels,
|
| 821 |
scaleanchor="y",
|
| 822 |
scaleratio=1,
|
| 823 |
fixedrange=True, # disable zoom and pan
|
|
|
|
| 824 |
),
|
| 825 |
autosize=False,
|
| 826 |
width=num_weeks * cell_size,
|
|
|
|
| 836 |
|
| 837 |
fig.update_layout(
|
| 838 |
xaxis=dict(fixedrange=True), # disable zoom and pan
|
| 839 |
+
yaxis=dict(fixedrange=True)
|
| 840 |
)
|
| 841 |
|
| 842 |
return fig
|