0

请找到以下代码:

class Timedown extends Component {
  state = {
    data: d3.csv("./data/d3plus.csv", function(error, dataset) {
      if (error) return console.error(error);
    })
};

在此处输入图像描述

4

1 回答 1

0

试试这个,我想你在阅读 csv 文件后不会返回数据。

    d3.csv('./data/d3plus.csv', (err, data) => {
        if (err) {
            console.log(err)
            return;
        }
        ReactDOM.render(
            <App width={960} height={640} data={data} />,
            document.getElementById('root'),
        )
    });

function App({width, height, data}) {
    const config = { data, x: "year", y: "value", text: "name" }; 
    return (
       // you can manipulate the data here using data
      // your html goes here
       <LinePlot config={{ config }} />

    )
}
于 2017-10-11T13:41:08.630 回答