forked from brainstormerjr/HelloWorldOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
130 lines (118 loc) · 3.8 KB
/
sketch.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
let chartRendered = false;
function learnMoreScroll() {
document.getElementById("about1").scrollIntoView({behavior: 'smooth', block: 'start'});
}
function standardDownload() {
document.getElementById("standardDownload").click();
}
function proDownload() {
document.getElementById("proDownload").click();
}
function corporationDownload() {
document.getElementById("corporationDownload").click();
}
const chartSettings = {
type: 'bar',
data: {
labels: ['Windows 10', 'Windows 7', 'MacOS','Ubuntu', 'Chrome OS', 'Brick OS'],
datasets: [
{
data: [15.64 * 1024, 10.50 * 1024, 12.23 * 1024, 4.5 * 1024, 4 * 1024, 16/1024],
//backgroundColor: ['rgb(255, 89, 139)', 'rgb(105, 197, 255)', 'rgb(175, 255, 105)', 'rgb(250, 126, 77)', 'rgb(142, 107, 255)'],
backgroundColor: ["#db6eac", "#d160a8", "#d160c6", "#bc60d1", "#a868d4"],
borderColor: ['#36447d'],
borderWidth: 0,
borderRadius: 6
}
]
},
options: {
plugins:{
legend: {
display: false
}
},
scales: {
y: {
title: {
display: true,
text: 'Size On Disk (MB)',
color: 'rgb(0,0,0)',
font: {
size: 18,
family: 'Poppins',
style: 'sans-seriff',
weight: 600
}
},
ticks: {
color: 'rgb(0,0,0)',
font: {
size: 14,
family: 'Poppins',
weight: 600
}
},
grid: {
color: 'rgba(0, 0, 0, 0.1)',
borderColor: 'rgba(0, 0, 0, 1)',
borderWidth: 3,
drawTicks: false,
lineWidth: 3
}
},
x: {
ticks: {
color: 'rgb(0,0,0)',
font: {
size: 16,
family: 'Poppins',
weight: 600
}
},
grid: {
color: 'rgba(0, 0, 0, 0.1)',
borderColor: 'rgba(0, 0, 0, 1)',
borderWidth: 3,
drawTicks: false,
display: false
}
}
},
onAnimationComplete: function(){
this.showTooltip(this.datasets[0].bars, true);
},
animation: {
duration: 1000,
easing: "easeOutQuart"
},
responsive: false,
maintainAspectRatio: false,
}
}
window.onload=function(){
var canvas = document.getElementById("myChart");
var parent = document.getElementById("parent");
canvas.width = parent.offsetWidth - 2*80;
console.log(Chart.defaults);
if (isScrolledIntoView(document.getElementById("myChart"))) {
var ctx = document.getElementById("myChart").getContext("2d");
var myChart = new Chart(ctx, chartSettings);
chartRendered = true;
}
}
document.addEventListener('scroll', function(e) {
if (chartRendered) return;
if (isScrolledIntoView(document.getElementById("myChart"))) {
var ctx = document.getElementById("myChart").getContext("2d");
var myChart = new Chart(ctx, chartSettings);
chartRendered = true;
}
});
function isScrolledIntoView(el) {
var rect = el.getBoundingClientRect();
var elemTop = rect.top;
var elemBottom = rect.bottom;
var isVisible = elemTop < window.innerHeight / 2;
return isVisible;
}