-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
83 lines (72 loc) · 1.61 KB
/
Copy pathutil.js
File metadata and controls
83 lines (72 loc) · 1.61 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
function hexToRGBA(hex, alpha) {
let r = parseInt(hex.slice(1, 3), 16),
g = parseInt(hex.slice(3, 5), 16),
b = parseInt(hex.slice(5, 7), 16);
return "rgba(" + r + ", " + g + ", " + b + ", .3)";
}
function randomBrightColor() {
let colorStr = `hsla(${Math.floor(Math.random()*360)}, 100%, 70%, `;
return [
colorStr + '1)',
colorStr + '.3)'
];
}
function getDate(quantity = 1, dir = 1, includeCurrent = false) {
if (includeCurrent)
quantity++;
let today = new Date();
let out = [];
for (let i = 0; i < quantity; i++)
{
if (!(includeCurrent && i == 0))
today = new Date(today.setDate(today.getDate() + dir));
out[i] = today.toLocaleDateString("pt-BR");
}
if (dir < 0)
out.reverse();
return out;
}
function getData() {
return {
type: "line",
data: { },
options: {
elements: {
line: {
fill: false,
tension: 0.2,
borderWidth: 3,
pointRadius: 1.5,
pointHitRadius: 10
},
},
legend: {
labels: {
fontColor: "#FFFFFF"
}
},
animation: {
duration: 0
},
hover: {
animationDuration: 0
},
responsiveAnimationDuration: 0
}
}
}
let currentChart;
function create(fill)
{
if (!this.data) return;
if (!fill)
fill = this.fill || false;
data.options.elements.line.fill = fill;
var ctx = document.getElementById("chart").getContext("2d");
if (currentChart)
currentChart.destroy();
currentChart = new Chart(ctx, data);
return true;
}
var totalDays = document.location.search.match(/[?&]d=(\d+)/);
totalDays = totalDays ? totalDays[1] - 1 : 29;