Skip to content

Commit e99da3d

Browse files
committed
changes
1 parent ccb610d commit e99da3d

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

trackio/frontend/src/components/LinePlot.svelte

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
type: "line",
113113
clip: true,
114114
strokeWidth: 2,
115-
point: { size: 20, ...(extra.point || {}) },
116115
...extra,
117116
});
118117
@@ -123,26 +122,54 @@
123122
{ field: y, type: "quantitative", title: yTitle },
124123
];
125124
125+
const hoverParams = [{
126+
name: "hover",
127+
select: { type: "point", on: "pointerover", nearest: true, clear: "pointerout" },
128+
}];
129+
130+
const hoverPointLayer = (dataSpec, layerName) => ({
131+
...dataSpec,
132+
mark: { type: "circle", clip: true, size: 60, opacity: 0 },
133+
encoding: {
134+
x: xEnc,
135+
y: yEnc,
136+
...colorEnc,
137+
tooltip: tooltipEnc,
138+
opacity: {
139+
condition: { param: "hover", empty: false, value: 1 },
140+
value: 0,
141+
},
142+
},
143+
params: hoverParams,
144+
name: layerName,
145+
});
146+
126147
if (hasSmoothed) {
127148
layers.push({
128149
data: { name: "data_original", values: originalData },
129-
mark: lineMark({ strokeWidth: 1, opacity: 0.3, point: { size: 20, opacity: 0.3 } }),
130-
encoding: { x: xEnc, y: yEnc, ...colorEnc, tooltip: tooltipEnc },
150+
mark: lineMark({ strokeWidth: 1, opacity: 0.3 }),
151+
encoding: { x: xEnc, y: yEnc, ...colorEnc },
131152
name: "original",
132153
});
133154
layers.push({
134155
data: { name: "data_smoothed", values: smoothedData },
135156
mark: lineMark(),
136-
encoding: { x: xEnc, y: yEnc, ...colorEnc, tooltip: tooltipEnc },
157+
encoding: { x: xEnc, y: yEnc, ...colorEnc },
137158
name: "plot",
138159
});
160+
layers.push(
161+
hoverPointLayer({ data: { name: "data_smoothed", values: smoothedData } }, "hover_points"),
162+
);
139163
} else {
140164
layers.push({
141165
data: { name: "data_plot", values: data },
142166
mark: lineMark(),
143-
encoding: { x: xEnc, y: yEnc, ...colorEnc, tooltip: tooltipEnc },
167+
encoding: { x: xEnc, y: yEnc, ...colorEnc },
144168
name: "plot",
145169
});
170+
layers.push(
171+
hoverPointLayer({ data: { name: "data_plot", values: data } }, "hover_points"),
172+
);
146173
}
147174
148175
return {

0 commit comments

Comments
 (0)