mirror of
				https://github.com/StefBuwalda/dashboard_test.git
				synced 2025-10-31 03:39:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <html lang="en">
 | |
| 
 | |
| <head>
 | |
|     <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>
 | |
| 
 | |
| <body>
 | |
| 
 | |
|     <canvas id="myChart"></canvas>
 | |
| 
 | |
| </body>
 | |
| 
 | |
| <script>
 | |
| 
 | |
|     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: 'line',
 | |
|         data: data,
 | |
|         options: {
 | |
|             scales: {
 | |
|                 x: {
 | |
|                     type: 'time', // Important for datetime axis
 | |
|                     time: {
 | |
|                         unit: 'day'
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     });
 | |
| </script>
 | |
| 
 | |
| </html> |