Skip to content

Commit d1f7abb

Browse files
committed
add width and stroke demo to focus-cursor
1 parent 3eb7da9 commit d1f7abb

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

demos/focus-cursor.html

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,58 @@
133133
</script>
134134

135135
<script>
136-
let u = new uPlot({
136+
function getStroke(color) {
137+
return (u, seriesIdx) => u.series[seriesIdx]._focus ? 'magenta' : color;
138+
}
139+
140+
let u3 = new uPlot({
141+
title: 'Width and stroke color change on focus',
142+
width: 1920,
143+
height: 600,
144+
focus: {
145+
alpha: 1,
146+
},
147+
cursor: {
148+
focus: {
149+
prox: 1e6,
150+
}
151+
},
152+
scales: {
153+
y: {
154+
range: [0, 30]
155+
}
156+
},
157+
series: [
158+
{},
159+
{
160+
label: 'A',
161+
stroke: getStroke('blue'),
162+
},
163+
{
164+
label: 'B',
165+
stroke: getStroke('green'),
166+
}
167+
],
168+
hooks: {
169+
setSeries: [
170+
(u, seriesIdx, opts) => {
171+
if (opts.focus != null) {
172+
u.series.forEach((s, i) => {
173+
s.width = i == seriesIdx ? 2 : 1;
174+
});
175+
u.redraw(false);
176+
}
177+
}
178+
]
179+
},
180+
}, [
181+
[0,1,2,3,4,5,6,7,8,9],
182+
...Array.from({length: 2}, (v, i) => Array(10).fill((i+1)*10)),
183+
],
184+
document.body);
185+
186+
let u4 = new uPlot({
187+
title: 'Performance test (300 series)',
137188
width: 1920,
138189
height: 600,
139190
focus: {

0 commit comments

Comments
 (0)