Quiero tener un gráfico donde, cuando hago clic en el gráfico, aparece un modal. Sin embargo, estoy luchando para que el gráfico reconozca al oyente onclick.
¿Alguna forma de hacer que esto funcione?
en mi vista gráfica:
class GraphView extends React.Component { render() { return ( <ResponsiveContainer width="100%" height={180} onClick={this.props.onClick}> <LineChart data={mydata} width={600} height={400} margin={{ top: 5, bottom: 5, left:-30, right: 0}}> <XAxis dataKey='time'/> <YAxis> {/* <Label angle={-90} value='stuff' position='insideLeft'style={{textAnchor: 'middle'}} dy={0} dx={0}/> */} </YAxis> <Legend /> <Line type="monotone" dataKey="visitors" stroke="#4285f4" activeDot={{r: 5}}/> <Line type="monotone" dataKey="visitors2" stroke="#001529" activeDot={{r: 5}}/> <Tooltip/> </LineChart> </ResponsiveContainer> ); } }en mi componente de función:
function showModal () { console.log("aaaaaaaaaa"); } function alarmLog() { const modal = <div> <GraphView onClick={() => showModal()}/>