Matteo Scandolo | 7629cc4 | 2017-03-13 14:12:15 -0700 | [diff] [blame] | 1 | import * as d3 from 'd3'; |
| 2 | |
| 3 | export interface Id3BBox { |
| 4 | x: number; |
| 5 | y: number; |
| 6 | width: number; |
| 7 | height: number; |
| 8 | } |
| 9 | |
| 10 | export interface IXosGraphHelpers { |
| 11 | parseElemClasses (classes: string): string; |
| 12 | getSiblingTextBBox(contex: any /* D3 this */): Id3BBox; |
| 13 | } |
| 14 | |
| 15 | export 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 | } |