Creating a Plot component

We'll use our knowledge of React.js and Plotly.js to create a plot component that will show the weather forecast.

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 div with an ID of plot above. This is the DOM element we’ll reference in our Plotly.newPlot call!

Now, the problem we have here is that if ...