我是新手,使用D3和React.我的反应应用程序是由create-react-app创建的.在我的react组件中,我使用导入d3import * as d3 from '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);
Run Code Online (Sandbox Code Playgroud)
得到了编译错误:
'd3'中未找到导出'时间'(导入为'd3')
我npm install d3 --save
在我的项目目录下导入d3 .
任何人都有想法是什么问题?