Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "deepscatter",
"type": "module",
"version": "3.0.0-next.50",
"version": "3.0.0-next.47",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package version in this PR is being downgraded from 3.0.0-next.50 to 3.0.0-next.47. This appears to be unintentional, as adding new features (like custom label fonts) should typically be accompanied by a version increment rather than a decrement. Please ensure the version number is properly incremented according to the project's versioning policy.

Suggested change
"version": "3.0.0-next.47",
+ "version": "3.0.0-next.51",

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

"description": "Fast, animated zoomable scatterplots scaling to billions of points",
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion src/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class Zoom {
if (event.sourceEvent) {
(event.sourceEvent as Event).stopPropagation();
}
});
})

canvas.call(zoomer);

Expand Down
18 changes: 14 additions & 4 deletions src/label_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class LabelMaker extends Renderer {
public label_key?: string;
public labelgroup: SVGGElement;
private hovered: undefined | string;
private font: string = 'verdana';
public options: DS.LabelOptions = {};
/**
*
Expand All @@ -46,6 +47,11 @@ export class LabelMaker extends Renderer {
) {
super(scatterplot.div!.node() as HTMLDivElement, scatterplot);
this.options = options;
if (options.font) {
this.font = options.font;
// else verdana
}

this.canvas = scatterplot
.elements![2].selectAll('canvas')
.node() as HTMLCanvasElement;
Expand Down Expand Up @@ -74,6 +80,7 @@ export class LabelMaker extends Renderer {
0.5,
[0.5, 1e6],
options.margin === undefined ? 30 : options.margin,
this.font
);

/* this.tree.accessor = (x, y) => {
Expand Down Expand Up @@ -264,7 +271,7 @@ export class LabelMaker extends Renderer {
if (this.hovered === '' + d.minZ + d.minX) {
emphasize += 2;
}
context.font = `${datum.height * size_adjust + emphasize}pt verdana`;
context.font = `${datum.height * size_adjust + emphasize}pt ${this.font}`;

context.shadowBlur = 12 + emphasize * 3;
context.lineWidth = 3 + emphasize;
Expand Down Expand Up @@ -380,13 +387,13 @@ function getContext(): CanvasRenderingContext2D {
return context;
}

function measure_text(d: RawPoint, pixel_ratio: number, margin: number) {
function measure_text(d: RawPoint, pixel_ratio: number, margin: number, font: string) {
// Uses a global context that it calls into existence for measuring;
// using the deepscatter
// canvas gets too confused with state information.
const context = getContext();
// Called for the side-effect of setting `d.aspect_ratio` on the passed item.
context.font = `${d.height}pt verdana`;
context.font = `${d.height}pt ${font}`;
if (d.text === '') {
return null;
}
Expand Down Expand Up @@ -427,6 +434,7 @@ class DepthTree extends RBush3D {
public pixel_ratio: number;
public rectangle_buffer: number;
public margin: number;
public font: string;
// public insertion_log = [];
private _accessor: (p: Point) => [number, number] = (p) => [p.x, p.y];

Expand All @@ -440,12 +448,14 @@ class DepthTree extends RBush3D {
scale_factor = 0.5,
zoom = [0.1, 1000],
margin = 10, // in screen pixels
font = 'verdana',
) {
// scale factor used to determine how quickly points scale.
// Not implemented.
// size = exp(log(k) * scale_factor);

super();
this.font = font;
this.scale_factor = scale_factor;
this.mindepth = zoom[0];
this.maxdepth = zoom[1];
Expand Down Expand Up @@ -520,7 +530,7 @@ class DepthTree extends RBush3D {
if (point['pixel_width'] === undefined) {
measured = {
...point,
...measure_text(point, this.pixel_ratio, this.margin),
...measure_text(point, this.pixel_ratio, this.margin, this.font),
};
} else {
measured = point as Point;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {
Timestamp,
Utf8,
Vector,
TypeMap,
} from 'apache-arrow';
import type { Renderer } from './rendering';
import type { Deeptable } from './Deeptable';
Expand Down Expand Up @@ -520,6 +519,7 @@ export type LabelOptions = {
useColorScale?: boolean; // Whether the colors of text should inherit from the active color scale.
margin?: number; // The number of pixels around each box. Default 30.
draggable_labels?: boolean; // Should labels be draggable in place?
font?: string; // Font. Default verdana.
};

export type Labelset = {
Expand Down
2 changes: 1 addition & 1 deletion src/wrap_arrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { Deeptable } from './Deeptable';
import { add_or_delete_column } from './Deeptable';
import type * as DS from './types';
import { extent, extent, range } from 'd3-array';
import { extent, range } from 'd3-array';
import { Rectangle } from './tile';
import { tixToZxy } from './tixrixqid';

Expand Down