Allow multiple target lines
This commit is contained in:
parent
6f29bdc6da
commit
204195ac06
14
wsgi.py
14
wsgi.py
@ -82,7 +82,7 @@ def plot(
|
|||||||
current_df: pd.DataFrame | None = None,
|
current_df: pd.DataFrame | None = None,
|
||||||
data_folder: str = "data",
|
data_folder: str = "data",
|
||||||
sheet_name: str = "digital",
|
sheet_name: str = "digital",
|
||||||
total_target: int = 1500,
|
total_targets: tuple[int, ...] = (1500, ),
|
||||||
alpha: float | None = None,
|
alpha: float | None = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
curr_datetime = datetime.datetime.now()
|
curr_datetime = datetime.datetime.now()
|
||||||
@ -132,9 +132,7 @@ def plot(
|
|||||||
|
|
||||||
plt.title("Teilnahme an Digitaler Beschäftigtenbefragung")
|
plt.title("Teilnahme an Digitaler Beschäftigtenbefragung")
|
||||||
plt.ylabel("# Teilnahmen")
|
plt.ylabel("# Teilnahmen")
|
||||||
plt.ylim(0, total_target + 100)
|
plt.ylim(0, total_targets[0] + 100)
|
||||||
|
|
||||||
# plt.gcf().autofmt_xdate()
|
|
||||||
|
|
||||||
# use timezone offset to center tick labels
|
# use timezone offset to center tick labels
|
||||||
plt.gca().xaxis.set_major_locator(
|
plt.gca().xaxis.set_major_locator(
|
||||||
@ -149,16 +147,18 @@ def plot(
|
|||||||
plt.gca().tick_params("x", length=0, which="major")
|
plt.gca().tick_params("x", length=0, which="major")
|
||||||
|
|
||||||
def val_to_perc(val):
|
def val_to_perc(val):
|
||||||
return 100 * val / total_target
|
return 100 * val / total_targets[0]
|
||||||
|
|
||||||
def perc_to_val(perc):
|
def perc_to_val(perc):
|
||||||
return perc * total_target / 100
|
return perc * total_targets[0] / 100
|
||||||
|
|
||||||
sec_ax = plt.gca().secondary_yaxis("right", functions=(val_to_perc, perc_to_val))
|
sec_ax = plt.gca().secondary_yaxis("right", functions=(val_to_perc, perc_to_val))
|
||||||
sec_ax.set_ylabel("# Teilnahmen [% Erfolg]")
|
sec_ax.set_ylabel("# Teilnahmen [% Erfolg]")
|
||||||
sec_ax.yaxis.set_major_formatter(mtick.PercentFormatter())
|
sec_ax.yaxis.set_major_formatter(mtick.PercentFormatter())
|
||||||
|
|
||||||
plt.axhline(y=total_target, color="#48a9be", linestyle="--")
|
for total_target in total_targets:
|
||||||
|
plt.axhline(y=total_target, color="#48a9be", linestyle="--")
|
||||||
|
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
|
|
||||||
# Convert plot to SVG image
|
# Convert plot to SVG image
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user