Sarat Chandra commited on
Commit
5fd2dbd
·
1 Parent(s): 0110486

"Changed X axis from Numbers to Dates"

Browse files
Files changed (1) hide show
  1. templates/index.html +16 -2
templates/index.html CHANGED
@@ -26,10 +26,24 @@
26
  var predictions = {{predictions}};
27
  var last_60_days_data = {{last_60_days_data}};
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  // Create the Plotly chart
31
  var trace1 = {
32
- x: Array.from({ length: 60 }, (_, i) => i + 1),
33
  y: last_60_days_data,
34
  type: 'scatter',
35
  mode: 'lines',
@@ -37,7 +51,7 @@
37
  line: { color: 'rgba(54, 162, 235, 1)' }
38
  };
39
  var trace2 = {
40
- x: Array.from({ length: 10 }, (_, i) => i + 61),
41
  y: predictions,
42
  type: 'scatter',
43
  mode: 'lines',
 
26
  var predictions = {{predictions}};
27
  var last_60_days_data = {{last_60_days_data}};
28
 
29
+ const today = new Date();
30
+ const next10DaysDates = Array.from({ length: 10 }, (_, i) => {
31
+ const nextDay = new Date(today);
32
+ nextDay.setDate(today.getDate() + i);
33
+ return nextDay.toISOString().split('T')[0]; // Extract the date in YYYY-MM-DD format
34
+ });
35
+
36
+ today.setDate(today.getDate() - 1); // Set to yesterday
37
+
38
+ const past60DaysDates = Array.from({ length: 60 }, (_, i) => {
39
+ const pastDay = new Date(today);
40
+ pastDay.setDate(today.getDate() - i);
41
+ return pastDay.toISOString().split('T')[0]; // Extract the date in YYYY-MM-DD format
42
+ });
43
 
44
  // Create the Plotly chart
45
  var trace1 = {
46
+ x: past60DaysDates,
47
  y: last_60_days_data,
48
  type: 'scatter',
49
  mode: 'lines',
 
51
  line: { color: 'rgba(54, 162, 235, 1)' }
52
  };
53
  var trace2 = {
54
+ x: next10DaysDates,
55
  y: predictions,
56
  type: 'scatter',
57
  mode: 'lines',