Cómo hacer que este gráfico de trama responda en index.html: creo una aplicación de matraz y una función js para representar la trama, sin embargo, no puedo entender cómo hacer que responda. Lo que está mal con la configuración variable: parece que no funciona.
Gracias
Matraz:
@app.route('/') def index(): locations = sorted(df['location'].unique()) rooms = sorted(df['rooms'].unique()) # Visualisation import json import plotly import plotly.express as px df.rooms = df.rooms.astype(str) fig = px.scatter(df, x="m2", y="price", trendline="ols", color="rooms", symbol='rooms', marginal_x="histogram", marginal_y="rug", template='plotly_dark', hover_data=['price', 'rooms', 'm2', 'location'], title="Real Estate in Vienna") graphJSON = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder) return render_template('index.html', locations=locations, rooms=rooms, graphJSON=graphJSON)JavaScript:
<!-- Visualisation --> {%block content%} <div class="card mb-4 m-auto" style="width: 90%"> <div class="card-body"> <div id="chart"></div> </div> </div> {% endblock %} <!-- Plotly --> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <script type="text/javascript"> var graphs = {{ graphJSON | safe}}; var config = {responsive: true}; Plotly.newPlot("chart", graphs, {}, config); </script>