-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_spoiler.js
More file actions
75 lines (72 loc) · 1.86 KB
/
script_spoiler.js
File metadata and controls
75 lines (72 loc) · 1.86 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
const cal_spoiler = new CalHeatmap();
var spoiler_options = {
itemSelector: "#cal-spoiler-heatmap",
data: {
source: "./records/spoiler_track.csv",
type: "csv",
x: "date",
y: (d) => +d["spoiler"],
groupY: "max",
},
date: {
start: new Date("2024-01-01"),
locale: { weekStart: 1 }
},
range: 1,
scale: {
color: {
type: "sequential",
scheme: "Greys",
domain: [0, 1],
},
},
domain: {
type: "year",
label: { text: null },
},
subDomain: {
type: "day",
radius: 3,
gutter: 4,
height: 15,
width: 15,
label: function (timestamp, value) {
const currentDate = new Date();
const today = currentDate.toDateString();
const received_ts = new Date(timestamp);
const received_date = received_ts.toDateString();
// console.log(today);
// console.log(received_date);
let result = today.localeCompare(received_date);
if (result == 0) {
return "🟨";
} else {
return "";
}
},
},
};
var spoiler_plugs = [
[
Tooltip,
{
text: function (date, value, dayjsDate) {
return (
(value ? "oops😟" : "yay!😄") + ", " + dayjsDate.format("LL")
);
},
},
],
// [
// CalendarLabel,
// {
// key: 'spoiler_label',
// width: 40,
// textAlign: "middle",
// text: () => dayjs.weekdaysShort().map((d, i) => (i % 2 == 0 ? "" : d)),
// },
// ],
];
cal_spoiler.paint(
spoiler_options, spoiler_plugs
);