Skip to content

Commit 771d524

Browse files
committed
fix: linting issues, license year
1 parent 21ef77b commit 771d524

File tree

6 files changed

+127
-134
lines changed

6 files changed

+127
-134
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2021 chartjs-plugin-zoom contributors
3+
Copyright (c) 2013-2024 chartjs-plugin-zoom contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

docs/scripts/defaults.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import {defaults} from 'chart.js';
1+
import { defaults } from 'chart.js'
22

33
defaults.set({
44
datasets: {
55
line: {
6-
tension: 0.4
7-
}
6+
tension: 0.4,
7+
},
88
},
99
interaction: {
1010
mode: 'nearest',
1111
axis: 'x',
12-
intersect: false
12+
intersect: false,
1313
},
1414
plugins: {
15-
legend: false
15+
legend: false,
1616
},
17-
});
17+
})

docs/scripts/register.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
import Chart from 'chart.js/auto';
2-
import 'chartjs-adapter-date-fns';
3-
import zoomPlugin from '../../dist/chartjs-plugin-zoom.esm.js';
1+
import Chart from 'chart.js/auto'
2+
import 'chartjs-adapter-date-fns'
3+
import zoomPlugin from '../../dist/chartjs-plugin-zoom.esm.js'
44

5-
Chart.register(zoomPlugin);
5+
Chart.register(zoomPlugin)
66

77
Chart.register({
88
id: 'version',
99
afterDraw(chart) {
10-
const ctx = chart.ctx;
11-
ctx.save();
12-
ctx.font = '9px monospace';
13-
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
14-
ctx.textAlign = 'right';
15-
ctx.textBaseline = 'top';
16-
ctx.fillText('Chart.js v' + Chart.version + ' + chartjs-plugin-zoom v' + zoomPlugin.version, chart.chartArea.right, 0);
17-
ctx.restore();
18-
}
19-
});
10+
const ctx = chart.ctx
11+
ctx.save()
12+
ctx.font = '9px monospace'
13+
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)'
14+
ctx.textAlign = 'right'
15+
ctx.textBaseline = 'top'
16+
ctx.fillText(
17+
'Chart.js v' + Chart.version + ' + chartjs-plugin-zoom v' + zoomPlugin.version,
18+
chart.chartArea.right,
19+
0
20+
)
21+
ctx.restore()
22+
},
23+
})

docs/scripts/utils.js

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
import {valueOrDefault} from 'chart.js/helpers';
2-
import {addHours, startOfWeek, endOfWeek, isWeekend, nextMonday, getHours, setHours} from 'date-fns';
3-
import addDays from 'date-fns/addDays';
1+
import { valueOrDefault } from 'chart.js/helpers'
2+
import { addHours, startOfWeek, endOfWeek, isWeekend, nextMonday, getHours, setHours } from 'date-fns'
3+
import addDays from 'date-fns/addDays'
44

55
// Adapted from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
6-
let _seed = Date.now();
6+
let _seed = Date.now()
77

88
export function srand(seed) {
9-
_seed = seed;
9+
_seed = seed
1010
}
1111

1212
export function rand(min, max) {
13-
min = valueOrDefault(min, 0);
14-
max = valueOrDefault(max, 0);
15-
_seed = (_seed * 9301 + 49297) % 233280;
16-
return min + (_seed / 233280) * (max - min);
13+
min = valueOrDefault(min, 0)
14+
max = valueOrDefault(max, 0)
15+
_seed = (_seed * 9301 + 49297) % 233280
16+
return min + (_seed / 233280) * (max - min)
1717
}
1818

1919
export function numbers(config) {
20-
const cfg = config || {};
21-
const min = valueOrDefault(cfg.min, 0);
22-
const max = valueOrDefault(cfg.max, 100);
23-
const from = valueOrDefault(cfg.from, []);
24-
const count = valueOrDefault(cfg.count, 8);
25-
const decimals = valueOrDefault(cfg.decimals, 8);
26-
const continuity = valueOrDefault(cfg.continuity, 1);
27-
const dfactor = Math.pow(10, decimals) || 0;
28-
const data = [];
29-
let i, value;
20+
const cfg = config || {}
21+
const min = valueOrDefault(cfg.min, 0)
22+
const max = valueOrDefault(cfg.max, 100)
23+
const from = valueOrDefault(cfg.from, [])
24+
const count = valueOrDefault(cfg.count, 8)
25+
const decimals = valueOrDefault(cfg.decimals, 8)
26+
const continuity = valueOrDefault(cfg.continuity, 1)
27+
const dfactor = Math.pow(10, decimals) || 0
28+
const data = []
29+
let i, value
3030

3131
for (i = 0; i < count; ++i) {
32-
value = (from[i] || 0) + this.rand(min, max);
32+
value = (from[i] || 0) + this.rand(min, max)
3333
if (this.rand() <= continuity) {
34-
data.push(Math.round(dfactor * value) / dfactor);
34+
data.push(Math.round(dfactor * value) / dfactor)
3535
} else {
36-
data.push(null);
36+
data.push(null)
3737
}
3838
}
3939

40-
return data;
40+
return data
4141
}
4242

4343
export function points(config) {
44-
const xs = this.numbers(config);
45-
const ys = this.numbers(config);
46-
return xs.map((x, i) => ({x, y: ys[i]}));
44+
const xs = this.numbers(config)
45+
const ys = this.numbers(config)
46+
return xs.map((x, i) => ({ x, y: ys[i] }))
4747
}
4848

49-
const rand255 = () => Math.round(Math.random() * 255);
49+
const rand255 = () => Math.round(Math.random() * 255)
5050

5151
export function randomColor(alpha) {
52-
return 'rgba(' + rand255() + ',' + rand255() + ',' + rand255() + ',' + (alpha || '.3') + ')';
52+
return 'rgba(' + rand255() + ',' + rand255() + ',' + rand255() + ',' + (alpha || '.3') + ')'
5353
}
5454

5555
const MONTHS = [
@@ -64,59 +64,59 @@ const MONTHS = [
6464
'September',
6565
'October',
6666
'November',
67-
'December'
68-
];
67+
'December',
68+
]
6969

7070
export function months(config) {
71-
const cfg = config || {};
72-
const count = cfg.count || 12;
73-
const section = cfg.section;
74-
const values = [];
75-
let i, value;
71+
const cfg = config || {}
72+
const count = cfg.count || 12
73+
const section = cfg.section
74+
const values = []
75+
let i, value
7676

7777
for (i = 0; i < count; ++i) {
78-
value = MONTHS[Math.ceil(i) % 12];
79-
values.push(value.substring(0, section));
78+
value = MONTHS[Math.ceil(i) % 12]
79+
values.push(value.substring(0, section))
8080
}
8181

82-
return values;
82+
return values
8383
}
8484

8585
export function hourlyPoints(config) {
86-
const ys = this.numbers(config);
87-
const start = new Date().valueOf();
88-
return ys.map((y, i) => ({x: addHours(start, i), y}));
86+
const ys = this.numbers(config)
87+
const start = new Date().valueOf()
88+
return ys.map((y, i) => ({ x: addHours(start, i), y }))
8989
}
9090

9191
function nextOfficeHour(time) {
9292
if (getHours(time) > 17) {
93-
time = setHours(addDays(time, 1), 8);
93+
time = setHours(addDays(time, 1), 8)
9494
}
9595
if (getHours(time) < 9) {
96-
time = setHours(time, 9);
96+
time = setHours(time, 9)
9797
} else {
98-
time = addHours(time, 1);
98+
time = addHours(time, 1)
9999
}
100100
if (isWeekend(time)) {
101-
time = setHours(nextMonday(time), 9);
101+
time = setHours(nextMonday(time), 9)
102102
}
103-
return time;
103+
return time
104104
}
105105

106106
export function officeHourPoints(config) {
107-
const ys = this.numbers(config);
108-
let time = new Date().valueOf();
109-
return ys.map(y => {
110-
time = nextOfficeHour(time);
111-
return {x: +time, y};
112-
});
107+
const ys = this.numbers(config)
108+
let time = new Date().valueOf()
109+
return ys.map((y) => {
110+
time = nextOfficeHour(time)
111+
return { x: +time, y }
112+
})
113113
}
114114

115115
export function nextWeek() {
116-
const now = new Date().valueOf();
117-
const min = startOfWeek(addHours(endOfWeek(now), 24));
116+
const now = new Date().valueOf()
117+
const min = startOfWeek(addHours(endOfWeek(now), 24))
118118
return {
119119
min: +min,
120-
max: +endOfWeek(min)
121-
};
120+
max: +endOfWeek(min),
121+
}
122122
}

0 commit comments

Comments
 (0)