-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathmain.js
137 lines (134 loc) · 3.55 KB
/
main.js
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
131
132
133
134
135
136
137
$('#ddd').on('click', function() {
var gape = {
"from": $("#from").val(),
"to": $("#to").val(),
};
console.log("adsfadsfdff");
// console.log(gape);
// console.log(gape.from);
var csrftoken = getCookie('csrftoken');
$.ajaxSetup({
beforeSend: function(xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
});
$.ajax({
type: 'POST',
url: '/show_data/',
data: gape,
success: function(x){
console.log(x);
fun(x);
},
});
});
const fun = function(da){
console.log('asdgf',da);
console.log("ooooooooooooooooooooooooooooooo");
let load = da;
console.log(load.Load);
// let datee = (parseInt(tarikh[8]+tarikh[9]) + i).toString() + '-' + tarikh[5]+tarikh[6] +'-'+tarikh[0]+tarikh[1]+tarikh[2]+tarikh[3];
var chart = c3.generate({
bindto: '#d',
data: {
x: 'x',
xFormat:'%H:%M',
columns: load.Load,
},
axis: {
y: {
label:{
text:'POWER IN MW',
position: 'outer-middle',
},
},
x: {
label:{
text: 'Time',
position:'outer-right',
},
type: 'timeseries',
tick:{
format:'%H:%M'
}
}
},
point: {
show: false
},
// zoom: {
// enabled:true,
// rescale:true,
// extent: [1, 100],
// },
grid: {
x: {
show: true,
},
y: {
show: true,
},
},
});
};
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
// $(document).ready(function(){
// $('#kp').on('click', function(){
// console.log("ooooooooooooooooooooooooooooooo");
// let load = data;
// // let datee = (parseInt(tarikh[8]+tarikh[9]) + i).toString() + '-' + tarikh[5]+tarikh[6] +'-'+tarikh[0]+tarikh[1]+tarikh[2]+tarikh[3];
// var chart = c3.generate({
// bindto: '#d',
// data: {
// x: 'x',
// xFormat:'%H:%M',
// columns: load.Load,
// },
// axis: {
// y: {
// label:{
// text:'POWER IN MW',
// position: 'outer-middle',
// },
// },
// x: {
// label:{
// text: 'Time',
// position:'outer-center',
// },
// type: 'timeseries',
// tick:{
// format:'%H:%M'
// }
// }
// },
// zoom: {
// enabled:true,
// rescale:true,
// extent: [1, 100],
// },
// grid: {
// x: {
// show: true,
// },
// y: {
// show: true,
// },
// },
// });
// });
// });