| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>Spiral Visualization with Flask</title> |
| <script src="https://cdn.jsdelivr.net/npm/vega@5"></script> |
| <script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script> |
| <script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script> |
| <style> |
| body { |
| font-family: Arial, sans-serif; |
| margin: 20px; |
| background-color: #f5f5f5; |
| } |
| .container { |
| max-width: 1200px; |
| margin: 0 auto; |
| background-color: white; |
| padding: 20px; |
| border-radius: 8px; |
| box-shadow: 0 2px 10px rgba(0,0,0,0.1); |
| } |
| h1 { |
| color: #333; |
| text-align: center; |
| } |
| .controls { |
| margin: 20px 0; |
| padding: 20px; |
| background-color: #f8f9fa; |
| border-radius: 5px; |
| } |
| .slider-container { |
| margin: 15px 0; |
| } |
| label { |
| display: block; |
| margin-bottom: 5px; |
| font-weight: bold; |
| } |
| input[type="range"] { |
| width: 100%; |
| } |
| .value-display { |
| display: inline-block; |
| width: 50px; |
| text-align: right; |
| } |
| #vis { |
| width: 700px; |
| height: 700px; |
| margin: 20px auto; |
| } |
| button { |
| background-color: #007bff; |
| color: white; |
| border: none; |
| padding: 10px 20px; |
| border-radius: 5px; |
| cursor: pointer; |
| font-size: 16px; |
| } |
| button:hover { |
| background-color: #0056b3; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="container"> |
| <h1>Welcome to Flask Spiral Visualization!</h1> |
| |
| <div class="controls"> |
| <div class="slider-container"> |
| <label for="points">Number of points in spiral: <span id="points-value" class="value-display">1100</span></label> |
| <input type="range" id="points" name="points" min="1" max="10000" value="1100"> |
| </div> |
| |
| <div class="slider-container"> |
| <label for="turns">Number of turns in spiral: <span id="turns-value" class="value-display">31</span></label> |
| <input type="range" id="turns" name="turns" min="1" max="300" value="31"> |
| </div> |
| |
| <button onclick="updateChart()">Update Chart</button> |
| </div> |
| |
| <div id="vis"></div> |
| </div> |
|
|
| <script> |
| |
| document.getElementById('points').addEventListener('input', function() { |
| document.getElementById('points-value').textContent = this.value; |
| }); |
| |
| document.getElementById('turns').addEventListener('input', function() { |
| document.getElementById('turns-value').textContent = this.value; |
| }); |
| |
| |
| function updateChart() { |
| const numPoints = document.getElementById('points').value; |
| const numTurns = document.getElementById('turns').value; |
| |
| fetch('/generate_chart', { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json', |
| }, |
| body: JSON.stringify({ |
| num_points: parseInt(numPoints), |
| num_turns: parseInt(numTurns) |
| }) |
| }) |
| .then(response => response.json()) |
| .then(data => { |
| vegaEmbed('#vis', JSON.parse(data.chart)); |
| }) |
| .catch(error => { |
| console.error('Error:', error); |
| }); |
| } |
| |
| |
| document.addEventListener('DOMContentLoaded', function() { |
| updateChart(); |
| }); |
| </script> |
| </body> |
| </html> |