“”我已经使用import *作为“ d3”中的d3,但显示错误尝试导入错误:'select'不是从'd3'中导出(导入为'd3')。我很困惑为什么它显示了此信息错误。有人可以帮我解决这个问题吗?谢谢“
import React, {Component} from 'react';
import * as d3 from "d3";
class BarChart extends Component{
componentDidMount() {
this.drawChart();
}
drawChart(){
const data = [12,5,6,5,9,10];
const svg = d3.select("body").append("svg").attr("width",
700).attr("height", 300);
svg.selectAll("rect").data(data).enter().append("rect")
.attr("x", (d, i) => i*70)
.attr("y", 0)
.attr("width", 25)
.attr("height", (d, i) => d * 10)
.attr("fill", "green");
}
render() {
return (
<div id={"#" + this.props.id}></div>
);
}
}
export default BarChart;