我在D3.js V.4.12中使用了Angular Typescript,尤其是在使用Tidy Radial Tree表示产品时。
与一起ng-cli,我安装npm install --save d3并创建了一个组件来显示信息。
可视化效果如下所示:
各个组件如下:
treediag.component.ts
import { Component, OnInit, ViewEncapsulation} from '@angular/core';
import * as d3 from 'd3';
import { ont, ont_highchair } from '../fd-ontology/ontology';
import { recursionParse, ontNode } from './model/recursion';
export class leaf {
name: string;
url: string;
color: string;
children: leaf[] = [];
}
@Component({
selector: 'app-treediag',
templateUrl: './treediag.component.html',
styleUrls: ['./treediag.component.css'],
encapsulation: ViewEncapsulation.None
})
export class TreediagComponent implements OnInit …Run Code Online (Sandbox Code Playgroud)