Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thing data chart activity #2

Open
hamsterready opened this issue Dec 8, 2015 · 1 comment
Open

Add thing data chart activity #2

hamsterready opened this issue Dec 8, 2015 · 1 comment
Labels

Comments

@hamsterready
Copy link
Member

After tapping on resource name presented on thing details activity (#1) user shall see line or pie chart which represents latest data.

curl https://user:[email protected]/api/v1/thing/hYxUIwyTbE42ebT5wV7MFbqklO4=/timeseries/temp

and the output:

[ {
  "dataTimeMillis" : 1449315852706,
  "doubleValue" : 19.3840008,
  "stringValue" : null
}, {
  "dataTimeMillis" : 1449315818453,
  "doubleValue" : 15.3100004,
  "stringValue" : null
}, {
  "dataTimeMillis" : 1449315810766,
  "doubleValue" : 15.3100004,
  "stringValue" : null
}, {
  "dataTimeMillis" : 1449246281253,
  "doubleValue" : 15.3100004,
  "stringValue" : null
}, {
  "dataTimeMillis" : 1449137869912,
  "doubleValue" : 15.3100004,
  "stringValue" : null
}, {
  "dataTimeMillis" : 1449137858504,
  "doubleValue" : 15.3100004,
  "stringValue" : null
}, {
  "dataTimeMillis" : 1449137850919,
  "doubleValue" : 15.3100004,
  "stringValue" : null
} ]

Please note that the output may consists double-only values, string-only values or mix of both.

To deal with this kind of data we do the following:

  1. If length of received list is > 0 then check first element and if doubleValue is not null then show line chart, otherwise if stringValue is not null show pie chart otherwise show generic screen saying "no data received yet".
  2. For line charts - ignore all data points with doubleValue == null (or if library supports these create chart with gaps (web example: http://www.amcharts.com/demos/chart-with-gaps-in-data/)
  3. For pie charts - iterate through the list, ignore elements with stringValue == null and aggregate to map by stringValue, for instance, list ["x", "x", "y", "x", "z"] -> {"x": 3, "y": 1, "z" : 1} - show pie chart.
@hamsterready
Copy link
Member Author

CC @ktomek

ktomek added a commit that referenced this issue Dec 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant