blob: 4bf4cb8f2136921e4893d150f937d747472a8e07 [file] [log] [blame]
Matteo Scandolo7629cc42017-03-13 14:12:15 -07001import * as d3 from 'd3';
2
3export interface Id3BBox {
4 x: number;
5 y: number;
6 width: number;
7 height: number;
8}
9
10export interface IXosGraphHelpers {
11 parseElemClasses (classes: string): string;
12 getSiblingTextBBox(contex: any /* D3 this */): Id3BBox;
13}
14
15export class XosGraphHelpers implements IXosGraphHelpers {
16 public parseElemClasses (classes: string): string {
17 return classes ? classes.split(' ')
18 .map(c => `ext-${c}`)
19 .join(' ') : '';
20 }
21
22 public getSiblingTextBBox(contex: any): Id3BBox {
23 return d3.select(contex.parentNode).select('text').node().getBBox();
24 }
25}