Dreamweaver updating library items
We’d like our labels to be exactly aligned with the start of a day (midnight).
So we are going to figure out what time it is on the first element of the time series, compute when exactly is the next day, and then create an array of 5 values corresponding to the time we just computed, then the time 24 hours after (start of the next day), the time 24 hours after that, etc. The styling is a bit different (these charts are, well, smaller).
And that final object has an extra property: city-name, the name of the city for which weather is being queried, if it exists.
When this object is created, we send it to the state. What it does is send whatever it’s passed to the state.
By using this as opposed to XYPlot with a fixed width, we can make our app layout responsive (try resizing the window! The first interesting thing is the on Mouse Leave property of Flexible XYPlot.
If the mouse leaves the chart, we’ll use our highlight X callback function to pass “null” to the state of App.
Else, we pass to each component a part of our data object, and a different title.
If the data can’t load, error will have a value, and we’ll pass it to the state. Map turns an array into another array of the same shape. To simplify, one of these objects could look like this: query Results to create a time series of objects with three properties: in x, a date in timestamp format (number of milliseconds since 1970). and in i, the index of that object in the time series. KEYS, I have an array of such time series, or more exactly: an array of objects with a name property (which comes from CONSTANTS.Well, it’s good practice to never store your API keys in your code. If they change it, I can just edit the constants file. You can replace it by whatever you want (it’s not too difficult to find the city_id for any given city at the OWM web site).Finally, I have a json object called KEYS where I store what I’m interested in getting from the API.Else, we’re going to process the result of the query (query Results) according to the structure that we want (CONSTANTS. Reduce turns an array into something else, such as an object as here. KEYS) and a values property (the array of objects described above).
query Results is an object which has a list property. Finally, I’m reducing it to an object using reduce.
In other words, when the mouse is not on a chart, the value of highlighted is null.