Spaces:
Sleeping
Sleeping
| import plotly.graph_objects as go | |
| from typing import List, Dict, Any | |
| def create_map_visualization(locations: List[Dict[str, Any]]) -> go.Figure: | |
| fig = go.Figure() | |
| # Add markers for each location | |
| fig.add_trace(go.Scattergeo( | |
| lon=[loc["longitude"] for loc in locations], | |
| lat=[loc["latitude"] for loc in locations], | |
| text=[loc["place_name"] for loc in locations], | |
| mode="markers+text", | |
| marker=dict(size=10, color="red"), | |
| textposition="top center" | |
| )) | |
| # Update layout | |
| fig.update_layout( | |
| geo=dict( | |
| scope="world", | |
| showland=True, | |
| showcountries=True, | |
| landcolor="rgb(243, 243, 243)", | |
| countrycolor="rgb(204, 204, 204)" | |
| ), | |
| title="Historical Art Locations", | |
| height=600 | |
| ) | |
| return fig | |
| def create_timeline_visualization(timeline_data: Dict[str, Any]) -> go.Figure: | |
| fig = go.Figure() | |
| # Add period span | |
| fig.add_trace(go.Scatter( | |
| x=[timeline_data["start_year"], timeline_data["end_year"]], | |
| y=[1, 1], | |
| mode="lines+markers", | |
| name=timeline_data["period_name"], | |
| line=dict(width=20, color="rgb(100, 100, 200)") | |
| )) | |
| # Add historical events | |
| event_years = list(range( | |
| timeline_data["start_year"], | |
| timeline_data["end_year"], | |
| (timeline_data["end_year"] - timeline_data["start_year"]) // len(timeline_data["events"]) | |
| )) | |
| fig.add_trace(go.Scatter( | |
| x=event_years[:len(timeline_data["events"])], | |
| y=[1.2] * len(timeline_data["events"]), | |
| mode="markers+text", | |
| text=timeline_data["events"], | |
| textposition="top center", | |
| marker=dict(size=8, color="red") | |
| )) | |
| # Update layout | |
| fig.update_layout( | |
| title="Historical Timeline", | |
| showlegend=False, | |
| height=400, | |
| yaxis=dict(visible=False), | |
| xaxis=dict(title="Year") | |
| ) | |
| return fig |