feat: change API router structure
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from datetime import datetime
|
||||
import numpy as np
|
||||
import io
|
||||
import base64
|
||||
from fastapi import APIRouter
|
||||
@@ -81,19 +80,17 @@ class Params(BaseModel):
|
||||
font_size: int | None = Field(default=10, alias="fontSize")
|
||||
arrow_size: int | None = Field(default=20, alias="arrowSize")
|
||||
edge_width: float | None = Field(default=1, alias="edgeWidth")
|
||||
distance: float | None = 0.2
|
||||
|
||||
|
||||
def sociogram_image(params: Params):
|
||||
print(params)
|
||||
plt.figure(figsize=(16, 10), facecolor="none")
|
||||
ax = plt.gca()
|
||||
ax.set_facecolor("none") # Set the axis face color to none (transparent)
|
||||
ax.axis("off") # Turn off axis ticks and frames
|
||||
|
||||
G = sociogram_data()
|
||||
pos = nx.spring_layout(
|
||||
G, scale=2, k=1 / np.sqrt(G.number_of_edges()), iterations=50, seed=42
|
||||
)
|
||||
pos = nx.spring_layout(G, scale=2, k=params.distance, iterations=50, seed=None)
|
||||
nx.draw_networkx_nodes(
|
||||
G,
|
||||
pos,
|
||||
|
||||
Reference in New Issue
Block a user