Formatting time in Chart

I simply want to create a chart with numbers on the y-axis and times on the x-axis.

I'm using these blocks to insert entries into the chart ...

... so the x-values are numbers of millis (that's the simplest way for me to compute the values I want) and the y-values are numbers from a html get request since over wifi.

Everything looks good, except I'd like the x-axis time values to be formatted at HH:MM instead of HH:MM:SS.

... but I'd prefer the time was just HH:MM

I tried this ...

...but if flags "invalid chart entries".

Proviidng a list of two-element lists does not work, because the x-labels are not spaced correctly (i.e. 10:15 and 10:30 are closer together than 10:45 and 11:00).

Use the chart Labels property to hold your list of HH:MM time stamps, and add your x,y values starting with x=0 and adding 1 to x for each minute.

I assume your data is spaced one minute apart?

For sample code, upload sample data.

That looks like it will work, thanks. Just have to work out how to generate the labels. Data is 15 minutes apart.

This needed a working sample, so I worked one up for you, based on List Pickers and sticking to measurement intervals that fit evenly into hours.


chart_by_HHMM.aia (6.8 KB)

image

The Time range List Pickers at the top are wired to keep the From Hours less than the To Hours.

The interval minutes choice is used to populate minute Elements in the List Pickers and in generating an Elements list for the data entry HH:MM List Picker.

That Elements List has all the HH:MM Labels for the graph, and is the foundation for determining the x value of any graph points, counting from 0.

Having the graph Labels pre-populated allows for gaps in the incoming data.

(added to FAQ)

Ok thanks, that's interesting. I haven't learned to use ListPicker as yet.

This is how I did it ...

The points I want to graph arrive as a response to a html get request sent over wifi. I break the response into response_words, which have the data points, as well as explicitly stating the number of data points num_pts and the time the last data point was collected end_time.

A typical example mgiht look like ...

outdoor_tmp ( 8 qtr-hrs at 23:00 ): 22.0 21.6 21.2 21.1 20.6 20.1 19.9 19.8 ( 19.8 20.8 22.0 )

At screen initialization I populate the list chart_times as ...

... and use this in the while block to generate the chart labels in the list tablist .

1 Like