@@ -32,6 +32,7 @@ export class LabelMaker extends Renderer {
3232 public label_key ?: string ;
3333 public labelgroup : SVGGElement ;
3434 private hovered : undefined | string ;
35+ private font : string = 'verdana' ;
3536 public options : DS . LabelOptions = { } ;
3637 /**
3738 *
@@ -46,6 +47,11 @@ export class LabelMaker extends Renderer {
4647 ) {
4748 super ( scatterplot . div ! . node ( ) as HTMLDivElement , scatterplot ) ;
4849 this . options = options ;
50+ if ( options . font ) {
51+ this . font = options . font ;
52+ // else verdana
53+ }
54+
4955 this . canvas = scatterplot
5056 . elements ! [ 2 ] . selectAll ( 'canvas' )
5157 . node ( ) as HTMLCanvasElement ;
@@ -74,6 +80,7 @@ export class LabelMaker extends Renderer {
7480 0.5 ,
7581 [ 0.5 , 1e6 ] ,
7682 options . margin === undefined ? 30 : options . margin ,
83+ this . font
7784 ) ;
7885
7986 /* this.tree.accessor = (x, y) => {
@@ -264,7 +271,7 @@ export class LabelMaker extends Renderer {
264271 if ( this . hovered === '' + d . minZ + d . minX ) {
265272 emphasize += 2 ;
266273 }
267- context . font = `${ datum . height * size_adjust + emphasize } pt verdana ` ;
274+ context . font = `${ datum . height * size_adjust + emphasize } pt ${ this . font } ` ;
268275
269276 context . shadowBlur = 12 + emphasize * 3 ;
270277 context . lineWidth = 3 + emphasize ;
@@ -380,13 +387,13 @@ function getContext(): CanvasRenderingContext2D {
380387 return context ;
381388}
382389
383- function measure_text ( d : RawPoint , pixel_ratio : number , margin : number ) {
390+ function measure_text ( d : RawPoint , pixel_ratio : number , margin : number , font : string ) {
384391 // Uses a global context that it calls into existence for measuring;
385392 // using the deepscatter
386393 // canvas gets too confused with state information.
387394 const context = getContext ( ) ;
388395 // Called for the side-effect of setting `d.aspect_ratio` on the passed item.
389- context . font = `${ d . height } pt verdana ` ;
396+ context . font = `${ d . height } pt ${ font } ` ;
390397 if ( d . text === '' ) {
391398 return null ;
392399 }
@@ -427,6 +434,7 @@ class DepthTree extends RBush3D {
427434 public pixel_ratio : number ;
428435 public rectangle_buffer : number ;
429436 public margin : number ;
437+ public font : string ;
430438 // public insertion_log = [];
431439 private _accessor : ( p : Point ) => [ number , number ] = ( p ) => [ p . x , p . y ] ;
432440
@@ -440,12 +448,14 @@ class DepthTree extends RBush3D {
440448 scale_factor = 0.5 ,
441449 zoom = [ 0.1 , 1000 ] ,
442450 margin = 10 , // in screen pixels
451+ font = 'verdana' ,
443452 ) {
444453 // scale factor used to determine how quickly points scale.
445454 // Not implemented.
446455 // size = exp(log(k) * scale_factor);
447456
448457 super ( ) ;
458+ this . font = font ;
449459 this . scale_factor = scale_factor ;
450460 this . mindepth = zoom [ 0 ] ;
451461 this . maxdepth = zoom [ 1 ] ;
@@ -520,7 +530,7 @@ class DepthTree extends RBush3D {
520530 if ( point [ 'pixel_width' ] === undefined ) {
521531 measured = {
522532 ...point ,
523- ...measure_text ( point , this . pixel_ratio , this . margin ) ,
533+ ...measure_text ( point , this . pixel_ratio , this . margin , this . font ) ,
524534 } ;
525535 } else {
526536 measured = point as Point ;
0 commit comments