0
我想實現的D3 V4線圖,按照Mike Bostock's article就可以了,但是當行我在角2D3-形狀誤差創造角2
這樣我已經安裝了D3 v4和所需分型。從我package.json
摘錄:
"@types/d3": "^4.9.0",
"@types/d3-array": "^1.2.0",
"@types/d3-axis": "^1.0.8",
"@types/d3-scale": "^1.0.6",
"@types/d3-shape": "^1.2.0",
"@types/d3-time-format": "^2.0.5",
...
"d3": "4.9.0",
"d3-array": "^1.2.0",
"d3-axis": "^1.0.8",
"d3-scale": "^1.0.6",
"d3-shape": "^1.2.0",
"d3-time-format": "^2.0.5",
但是,試圖創建line
變量時,我收到一個錯誤,因爲它是期待一個[number, number]
但按照指導我需要在這裏傳遞數據的項目,因此可以拿起日期和價值。我的代碼是:
var line = d3Shape.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.value); });
兩個錯誤這會產生如下:
Property 'date' does not exist on type '[number, number]'.
Property 'value' does not exist on type '[number, number]'.
有沒有其他人遇到這個錯誤,並知道如何解決?