我试图使用d3.js库和TypeScript绘制饼图.我有以下代码:
"use strict";
module Chart {
export class chart {
private chart: d3.Selection<string>;
private width: number;
private height: number;
private radius: number;
private donutWidth: number;
private dataset: { label: string, count: number }[];
private color: d3.scale.Ordinal<string, string>;
constructor(container: any) {
this.width = 360;
this.height = 360;
this.radius = Math.min(this.width, this.height) / 2;
this.donutWidth = 75;
this.dataset = [
{ label: 'Road', count: 5500 },
{ label: 'Bridge', count: 8800 },
{ label: 'Tunnel', count: 225 },
];
this.color = d3.scale.category10(); …Run Code Online (Sandbox Code Playgroud)