你好,我有一個折線圖,我應(yīng)該在其中顯示動態(tài)數(shù)據(jù),如果他們不向我傳遞數(shù)據(jù),那只是一條直線。我遇到的問題是我不知道如何將道具傳遞給折線圖var data `[{ "name": "Samantha White", "id": "484567489sda", "address": "4116 Barton Creek Boulevard Austin, TX 78735 USA", "logo": "https://sssssss.s3.amazonaws.com/ssss/express.png", "occupancy": { "capacity": 150, "occupancy": 0, "percentage": 0 }, "alerts": { "conglomerations": 0, "occupancy": 0 }, "visits": 2721 "plot": [] }, { "name": "Jacqueline Wells", "id": "sdasdx45616a4dsa5", "address": "s15035 Highview Road Grand Junction, CO 81504 USA", "store_logo": "ssssss.s3.amazonaws.com/ssss/lider.png", "occupancy": { "capacity": 150, "occupancy": 0, "percentage": 0 }, "alerts": { "conglomerations": 0, "occupancy": 0 }, "visits": 2069, "plot": [9, 29, 48, 52, 88, 107, 130, 127, 122, 157, 165, 172, 211, 214, 267, 296, 331, 353, 371, 381] }]`;function App() { const [tiendas, setTiendas] = useState(JSON.parse(data)); const [showTiendas, setShowTiendas] = useState(false) useEffect(() => { setTiendas(JSON.parse(data)); }, []); return ( <div className="w-full "> <Menu showTiendas={setShowTiendas} menuData={tiendas} tiendasSet={setTiendas} /> {showTiendas && tiendas.map((tienda) => ( <Card key={Math.random()} {...tienda}></Card> ))} </div> );}export default App;圖表的數(shù)據(jù)將是plot,在卡組件中我命令調(diào)用圖表,這將是圖表的代碼,我不知道如何從圖表發(fā)送調(diào)用plot,現(xiàn)在圖表有隨機(jī)數(shù)import React, { useState } from "react";import { scaleLinear, scaleBand } from "d3-scale";import Line from "./Line";import { line, curveMonotoneX } from "d3-shape";import { extent } from "d3-array";function Chart(props) { const [data, setData] = useState( [ Math.random()*30, Math.random()*30, Math.random()*30, Math.random()*30, Math.random()*30, Math.random()*30, Math.random()*30, ] ); const parentWidth = 125; const margins = { top: 20, right: 20, bottom: 20, left: 20 };
查看完整描述