Spaces:
Sleeping
Sleeping
Update src/reporter/docx_fill.py
Browse files- src/reporter/docx_fill.py +106 -1
src/reporter/docx_fill.py
CHANGED
|
@@ -77,8 +77,113 @@ def extract_competence_blocks(columns: Iterable[str]) -> List[dict]:
|
|
| 77 |
def wrap_label(s: str, width: int = 14) -> str:
|
| 78 |
return "\n".join(textwrap.wrap(str(s), width=width, break_long_words=False))
|
| 79 |
|
| 80 |
-
|
| 81 |
def radar_chart(names: List[str], auto_vals: List[float], valut_vals: List[float], out_png: Path) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
"""Radar con 2 sole serie (AUTO vs VALUT).
|
| 83 |
|
| 84 |
Nota estetica: niente aree piene (o riempimento quasi trasparente) per evitare l'effetto
|
|
|
|
| 77 |
def wrap_label(s: str, width: int = 14) -> str:
|
| 78 |
return "\n".join(textwrap.wrap(str(s), width=width, break_long_words=False))
|
| 79 |
|
|
|
|
| 80 |
def radar_chart(names: List[str], auto_vals: List[float], valut_vals: List[float], out_png: Path) -> None:
|
| 81 |
+
""" Radar con 2 sole serie (AUTO vs VALUT) """
|
| 82 |
+
labels = [wrap_label(n, 18) for n in names]
|
| 83 |
+
n = len(labels)
|
| 84 |
+
angles = np.linspace(0, 2 * np.pi, n, endpoint=False).tolist()
|
| 85 |
+
angles += angles[:1]
|
| 86 |
+
|
| 87 |
+
a = list(auto_vals) + [auto_vals[0]]
|
| 88 |
+
v = list(valut_vals) + [valut_vals[0]]
|
| 89 |
+
|
| 90 |
+
fig = plt.figure(figsize=(14.6, 8.6), dpi=220)
|
| 91 |
+
fig.patch.set_facecolor("white")
|
| 92 |
+
ax = plt.subplot(111, polar=True)
|
| 93 |
+
ax.set_facecolor("white")
|
| 94 |
+
|
| 95 |
+
ax.set_theta_offset(np.pi / 2)
|
| 96 |
+
ax.set_theta_direction(-1)
|
| 97 |
+
ax.set_ylim(0, 6)
|
| 98 |
+
|
| 99 |
+
ax.set_xticks(angles[:-1])
|
| 100 |
+
ax.set_xticklabels(labels, fontsize=10.3)
|
| 101 |
+
ax.tick_params(axis="x", pad=30)
|
| 102 |
+
|
| 103 |
+
ax.set_rlabel_position(18)
|
| 104 |
+
ax.set_yticks([1, 2, 3, 4, 5, 6])
|
| 105 |
+
ax.set_yticklabels(["1", "2", "3", "4", "5", "6"], fontsize=9.2, alpha=0.52)
|
| 106 |
+
|
| 107 |
+
ax.spines["polar"].set_linewidth(1.0)
|
| 108 |
+
ax.spines["polar"].set_alpha(0.16)
|
| 109 |
+
ax.yaxis.grid(True, alpha=0.14, linewidth=0.9)
|
| 110 |
+
ax.xaxis.grid(True, alpha=0.08, linewidth=0.8)
|
| 111 |
+
|
| 112 |
+
line1, = ax.plot(
|
| 113 |
+
angles, v,
|
| 114 |
+
linewidth=2.9,
|
| 115 |
+
solid_capstyle="round",
|
| 116 |
+
solid_joinstyle="round",
|
| 117 |
+
marker="o",
|
| 118 |
+
markersize=8.5,
|
| 119 |
+
markeredgewidth=1.2,
|
| 120 |
+
label="Valutazione",
|
| 121 |
+
zorder=4
|
| 122 |
+
)
|
| 123 |
+
line2, = ax.plot(
|
| 124 |
+
angles, a,
|
| 125 |
+
linewidth=2.9,
|
| 126 |
+
solid_capstyle="round",
|
| 127 |
+
solid_joinstyle="round",
|
| 128 |
+
marker="o",
|
| 129 |
+
markersize=8.5,
|
| 130 |
+
markeredgewidth=1.2,
|
| 131 |
+
label="Autovalutazione",
|
| 132 |
+
zorder=4
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
c1 = line1.get_color()
|
| 136 |
+
c2 = line2.get_color()
|
| 137 |
+
|
| 138 |
+
line1.set_markerfacecolor(c1)
|
| 139 |
+
line1.set_markeredgecolor("white")
|
| 140 |
+
line2.set_markerfacecolor(c2)
|
| 141 |
+
line2.set_markeredgecolor("white")
|
| 142 |
+
|
| 143 |
+
ax.fill(angles, v, color=c1, alpha=0.055, zorder=2)
|
| 144 |
+
ax.fill(angles, a, color=c2, alpha=0.055, zorder=2)
|
| 145 |
+
|
| 146 |
+
# halo bianco sotto ai marker
|
| 147 |
+
ax.scatter(angles[:-1], v[:-1], s=520, color="white", edgecolors="none", zorder=5)
|
| 148 |
+
ax.scatter(angles[:-1], a[:-1], s=520, color="white", edgecolors="none", zorder=5)
|
| 149 |
+
|
| 150 |
+
# marker grandi
|
| 151 |
+
ax.scatter(
|
| 152 |
+
angles[:-1], v[:-1],
|
| 153 |
+
s=310, color=c1,
|
| 154 |
+
edgecolors="white", linewidth=1.9, zorder=6
|
| 155 |
+
)
|
| 156 |
+
ax.scatter(
|
| 157 |
+
angles[:-1], a[:-1],
|
| 158 |
+
s=310, color=c2,
|
| 159 |
+
edgecolors="white", linewidth=1.9, zorder=6
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
fig.subplots_adjust(left=0.05, right=0.72, top=0.96, bottom=0.08)
|
| 163 |
+
|
| 164 |
+
legend = ax.legend(
|
| 165 |
+
loc="center left",
|
| 166 |
+
bbox_to_anchor=(1.20, 0.56),
|
| 167 |
+
frameon=True,
|
| 168 |
+
fancybox=True,
|
| 169 |
+
framealpha=1.0,
|
| 170 |
+
borderpad=1.05,
|
| 171 |
+
labelspacing=1.0,
|
| 172 |
+
handlelength=2.5,
|
| 173 |
+
handletextpad=0.85,
|
| 174 |
+
fontsize=11.2,
|
| 175 |
+
numpoints=1,
|
| 176 |
+
)
|
| 177 |
+
frame = legend.get_frame()
|
| 178 |
+
frame.set_facecolor("white")
|
| 179 |
+
frame.set_edgecolor("#E2E8F0")
|
| 180 |
+
frame.set_linewidth(0.9)
|
| 181 |
+
|
| 182 |
+
fig.savefig(out_png, transparent=True, bbox_inches="tight", pad_inches=0.24)
|
| 183 |
+
plt.close(fig)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
def radar_chart_old(names: List[str], auto_vals: List[float], valut_vals: List[float], out_png: Path) -> None:
|
| 187 |
"""Radar con 2 sole serie (AUTO vs VALUT).
|
| 188 |
|
| 189 |
Nota estetica: niente aree piene (o riempimento quasi trasparente) per evitare l'effetto
|