-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
57 lines (43 loc) · 1.71 KB
/
main.js
File metadata and controls
57 lines (43 loc) · 1.71 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
"use strict";
document.addEventListener("DOMContentLoaded", function() {
let getRandom = (min, max) => Math.floor(Math.random() * (parseInt(max) - parseInt(min) + 1) ) + parseInt(min);
let genBtn = document.getElementById("genBtn");
genBtn.addEventListener("click", randoming);
function randoming() {
let x1 = document.getElementById("x1").value,
y1 = document.getElementById("y1").value,
x2 = document.getElementById("x2").value,
y2 = document.getElementById("y2").value,
x3 = document.getElementById("x3").value,
y3 = document.getElementById("y3").value,
x4 = document.getElementById("x4").value,
y4 = document.getElementById("y4").value;
let first = getRandom(x1, y1),
second = first + getRandom(x2, y2),
third = second + getRandom(x3, y3),
fourth = third + getRandom(x4, y4);
result.innerHTML = first + " " + second + " " + third + " " + fourth;
drawChart(first, second, third, fourth);
}
google.charts.load('current', {
'packages': ['corechart']
});
function drawChart(a, b, c, d) {
var data = google.visualization.arrayToDataTable([
['Index', 'Значение'],
['1', a],
['2', b],
['3', c],
['4', d]
]);
var options = {
title: 'Заголовок',
curveType: 'function',
legend: {
position: 'bottom'
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart'));
chart.draw(data, options);
}
})