Skip to content

Commit

Permalink
fix xy coords on tooltips (#161)
Browse files Browse the repository at this point in the history
The svg tooltip circles weren't displaying the correct coordinates when x or y was a struct. This fixes the 'apply' function so that it descends struts.
<!-- ELLIPSIS_HIDDEN -->

----

> [!IMPORTANT]
> Fixes tooltip coordinate issue in `ScaledAesthetic.ts` by handling struct subfields and corrects type in `interaction.ts`.
> 
>   - **Behavior**:
>     - Fixes tooltip coordinate issue in `apply()` of `ScaledAesthetic` class in `ScaledAesthetic.ts` by correctly handling struct subfields.
>   - **Type Corrections**:
>     - Corrects type casting in `html_annotation()` in `interaction.ts` from `string` to `HTMLDivElement`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=nomic-ai%2Fdeepscatter&utm_source=github&utm_medium=referral)<sup> for 565e242. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
bmschmidt authored Oct 16, 2024
1 parent 9d73b5e commit 54c93b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/aesthetics/ScaledAesthetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ export abstract class ScaledAesthetic<
if (this.field === null || isConstantChannel(this.encoding)) {
return constant as Output['rangeType'];
}
const value = point[this.field] as Input['domainType'];
let value = point[this.field] as Input['domainType'];
for (const subfield of this.subfield) {
value = value[subfield] as Input['domainType'];
}
if (value === undefined || value === null) {
return constant as Output['rangeType'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export class Zoom {
}

html_annotation(points: Annotation[]) {
const div = this.svg_element_selection.node()!.parentNode
.parentNode as unknown as string;
const div = this.svg_element_selection.node().parentNode
.parentNode as HTMLDivElement;
const els = select(div)
.selectAll('div.tooltip')
.data(points)
Expand Down
1 change: 1 addition & 0 deletions src/regl_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ export class ReglRenderer extends Renderer {
variable_to_buffer_num.set(field, num);
continue;
} else {
console.log('Overflow');
// Don't use the last value, use the current value.
// Loses animation but otherwise plots nicely.
// Strategy will break if more than 14 base channels are defined,
Expand Down

0 comments on commit 54c93b7

Please sign in to comment.