mirror of
				https://github.com/StefBuwalda/dashboard_test.git
				synced 2025-10-31 03:39:58 +00:00 
			
		
		
		
	More chart experimentation. Managed to make a chart of ping history display
This commit is contained in:
		| @@ -1,45 +1,48 @@ | ||||
| <!DOCTYPE html> | ||||
| <html lang="en" data-bs-theme="dark"> | ||||
| <html lang="en"> | ||||
|  | ||||
| <head> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1" charset=" UTF-8"> | ||||
|     <title>Chart</title> | ||||
|     <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" | ||||
|         integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous"> | ||||
|     <link rel="icon" type="image/svg+xml" href="/static/favicon.svg"> | ||||
|     <meta charset="UTF-8"> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||
|     <title>Simple Line Chart</title> | ||||
|     <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||||
|     <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns"></script> | ||||
|     <script src="https://www.chartjs.org/docs/latest/samples/utils.js"></script> | ||||
| </head> | ||||
|  | ||||
| <div class="container-fluid" style="width:900px;"> | ||||
|     <canvas id="myChart"></canvas> | ||||
| </div> | ||||
| <body> | ||||
|  | ||||
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||||
|     <canvas id="myChart"></canvas> | ||||
|  | ||||
| </body> | ||||
|  | ||||
| <script> | ||||
|     const ctx = document.getElementById('myChart'); | ||||
|  | ||||
|     const chartDates = {{ dates| tojson | safe }}.map(dt => new Date(dt)); | ||||
|  | ||||
|     const data = { | ||||
|         labels: chartDates, | ||||
|         datasets: [{ | ||||
|             label: 'Example Data', | ||||
|             data: {{ values }}, | ||||
|         }] | ||||
|     }; | ||||
|  | ||||
|     const ctx = document.getElementById('myChart').getContext('2d'); | ||||
|     new Chart(ctx, { | ||||
|         type: 'bar', | ||||
|         data: { | ||||
|             labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'], | ||||
|             datasets: [{ | ||||
|                 label: '# of Votes', | ||||
|                 data: [12, 19, 3, 5, 2, 3], | ||||
|                 borderWidth: 1 | ||||
|             }] | ||||
|         }, | ||||
|         type: 'line', | ||||
|         data: data, | ||||
|         options: { | ||||
|             scales: { | ||||
|                 y: { | ||||
|                     beginAtZero: true | ||||
|                 x: { | ||||
|                     type: 'time', // Important for datetime axis | ||||
|                     time: { | ||||
|                         unit: 'day' | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| </script> | ||||
|  | ||||
| <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" | ||||
|     integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" | ||||
|     crossorigin="anonymous"></script> | ||||
|  | ||||
| </html> | ||||
		Reference in New Issue
	
	Block a user