-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.html
More file actions
130 lines (111 loc) · 4.25 KB
/
Copy pathdata.html
File metadata and controls
130 lines (111 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap" rel="stylesheet">
<link rel = "stylesheet" type = "text/css" href = "data.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(function(){
$("#header-template").load("header.html");
$("#footer-template").load("footer.html");
});
</script>
</head>
<body>
<div id="header-template">Header</div>
<div class="data">
<p>Palani Ranch</p>
<div class="dropdown">
<label for="data">Select data:</label>
<select name="data" id="data">
<option value="Rainfall">Rainfall</option>
<option value="saab">NDVI</option>
<option value="mercedes">Evapotranspiration</option>
</select>
</div>
<div id="plot" style=" width: 800px; height: 600px; margin: auto;"></div>
<script>
const CSV = "../et_df.csv"
function plotFromCSV() {
Plotly.d3.csv(CSV, function(err, rows) {
console.log(rows);
processData(rows);
});
}
function processData(allRows) {
let x = [];
let y1 = [];
let row;
let i = 0;
while (i < allRows.length) {
row = allRows[i];
x.push(row["datetime"]);
y1.push(row["ET"]);
i += 1;
}
console.log("X", x);
console.log("Y1", y1);
makePlotly(x, y1,);
}
var selectorOptions = {
buttons: [{
step: 'month',
stepmode: 'backward',
count: 1,
label: '1m'
}, {
step: 'month',
stepmode: 'backward',
count: 6,
label: '6m'
}, {
step: 'year',
stepmode: 'todate',
count: 1,
label: 'YTD'
}, {
step: 'year',
stepmode: 'backward',
count: 1,
label: '1y'
}, {
step: 'all',
}],
};
function makePlotly(x, y1) {
let traces = [
{
x: x,
y: y1,
name: "Evapotranspiration",
hovertemplate: 'Evapotranspiration: %{y}<extra></extra>',
line: {
color: "#387fba",
width: 3
}
}
];
let layout = {
title: "Evapotranspiration",
yaxis: {
range: [-10, 80]
},
xaxis: {
rangeselector: selectorOptions,
rangeslider: {}
},
};
let config = {
responsive: true,
displayModeBar: true,
};
Plotly.newPlot("plot", traces, layout, config);
}
plotFromCSV();
</script>
</div>
<div id="footer-template">Footer</div>
</body>
</html>