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。 –
是啊...谢谢! –