Skip to content

Instantly share code, notes, and snippets.

@ygaller
Last active April 22, 2017 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ygaller/91c644843ebd04076f0380cd3b056f8c to your computer and use it in GitHub Desktop.
Save ygaller/91c644843ebd04076f0380cd3b056f8c to your computer and use it in GitHub Desktop.
@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