File size: 1,382 Bytes
4560f00
 
 
d240213
4560f00
595fa2d
4560f00
d240213
 
4560f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pandas as pd
import plotly.express as px
import gradio as gr
import os
from huggingface_hub import login
from datasets import load_dataset

token = os.getenv("HF_TOKEN")  # Legge il token da una variabile d'ambiente
login(token=token)

df_multi = pd.DataFrame(load_dataset("SelmaNajih001/MapsData")["train"])

# Funzione per aggiornare la mappa
def update_map(metric):
    fig = px.scatter_mapbox(
        df,
        lat="Latitude",
        lon="Longitude",
        size=metric,
        color=metric,
        hover_name="Name",
        hover_data=[
            "busy_aprile",
            "busy_maggio",
            "Variazione",
            "StarsAprile_numeric",
            "StarsMaggio_numeric",
            "VariazioneStelle",
            "VariazionePercentuale"
        ],
        zoom=10,
        height=600
    )
    fig.update_layout(mapbox_style="open-street-map")
    fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
    return fig

# Dropdown delle metriche
dropdown = gr.Dropdown(
    choices=[
        "busy_aprile",
        "Variazione",
        "VariazionePercentuale",
        "StarsAprile_numeric",
        "StarsMaggio_numeric",
        "VariazioneStelle"
    ],
    value="busy_aprile",
    label="Seleziona metrica"
)

# Interfaccia Gradio
interface = gr.Interface(
    fn=update_map,
    inputs=dropdown,
    outputs=gr.Plot()
)

interface.launch()