Creating a Plot component
Explore building a reusable Plot component in React using Plotly.js. Learn how to efficiently render graphs by leveraging component lifecycle methods and passing data through props to display dynamic forecast charts.
We'll cover the following...
We'll cover the following...
Plot component
To show our plot on the webpage, we will create a component which we’ll call Plot (what a surprise!) so lets start by rendering just a div:
class Plot extends React.Component {
render() {
return (
<div id="plot"></div>
);
}
}
As you can see, I’ve added a
divwith an ID ofplotabove. This is the DOM element we’ll reference in ourPlotly.newPlotcall!
Now, the problem we have here is that if we ...