1
我是使用D3和React的新手。我的反應應用程序由create-react-app創建。 在我的反應成分,我輸入D3使用import * as d3 from 'd3'
在'd3'中未找到導出'時間'(導入爲'd3')
我的代碼如下:
this.xScale = d3.time.scale()
.domain(d3.extent(this.props.data, function (d) {
return d[_self.props.xData];
}))
.rangeRound([0, this.w]);
this.yScale = d3.scale.linear()
.domain([0,d3.max(this.props.data,function(d){
return d[_self.props.yData]+_self.props.yMaxBuffer;
})])
.range([this.h, 0]);
this.area = d3.svg.area()
.x(function (d) {
return this.xScale(d[_self.props.xData]);
})
.y0(this.h)
.y1(function (d) {
return this.yScale(d[_self.props.yData]);
}).interpolate(this.props.interpolations);
得到了編譯錯誤:
export 'time' (imported as 'd3') was not found in 'd3'
我導入D3使用npm install d3 --save
我的工程目錄下。
任何人有想法是什麼問題?
該代碼使用D3 v3。您正在導入D3 v4。 –
是啊...謝謝! –