Last active
April 22, 2017 11:41
-
-
Save ygaller/91c644843ebd04076f0380cd3b056f8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class FlareJsonService implements HierarchicalData { | |
private d3: D3; | |
constructor(private http: Http, d3Service: D3Service, private url: string) { | |
this.d3 = d3Service.getD3(); | |
} | |
getRoot(): Observable<HierarchyNode<any>> { | |
return this.http.get('./assets/' + this.url).map(res => { | |
const rawData = res['_body'] || ''; | |
let parsedJson = JSON.parse(rawData); | |
return this.d3.hierarchy(parsedJson) | |
.sum((d: HierarchyPointNode<any>) => (<any>d).size) | |
.sort((a, b) => (<any>b).value - (<any>a).value); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment