我正在尝试将D3 v4代码块转换为v3。这是给我麻烦的代码块。
//var spiral = d3.radialLine()
var spiral = d3.svg.line.radial()
//.curve(d3.curveCardinal)
.curve(d3.line.curve())
//.curve(d3.curve.linear)
.angle(theta)
.radius(radius);
我注释掉的第一行引用了我能够解决的radialLine
,但是,当尝试将d3.curveCardinal
转换为d3.line.curve()
时,出现以下错误:
未捕获的TypeError:无法读取未定义的属性“曲线”
我尝试了d3.line.curve()
的一些派生方式,但无济于事。有人知道我可以成功翻译此方法吗?
答案 0 :(得分:1)
引用changelog:
line .interpolate和 area .interpolate方法已被line.curve和area.curve取代。使用curve interface实现曲线,而不是将其作为返回SVG路径数据字符串的函数
对于您的反向移植,这意味着要替换
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/cdk": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/platform-server": "^5.2.0",
"@angular/router": "^5.2.0",
"@aspnet/signalr": "^1.1.2",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^3.4.1",
"core-js": "^2.6.5",
"rxjs": "^5.5.12",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "^2.8.16",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^6.14.3",
"codelyzer": "^4.5.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.5",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
使用
.curve(d3.curveCardinal)
因此整个语句变为:
.interpolate("cardinal")
v3 API文档包含有关d3.svg.line.radial()
及其interpolation modes的正确用法的所有详细信息。