Skip to content

Data Model: Chart

awstin17 edited this page Oct 23, 2018 · 7 revisions

Data Model: Chart

What the model will look like:

The model for the chart data will be an array of objects that looks like this:

[
  {
    "Date": "mm/dd/yyyy",
    "Data": "[8, 2, 5, 10, 3, 5, 6, 8]"
  },
  {
    "Date": "mm/dd/yyyy",
    "Data": "[8, 3, 6, 10, 2, 5, 7, 8]"
  }
]

This way it will be suuuuuper easy to display the data historically because you can just cycle through the array with loops and ngFors and the like!

Data Relation

This data model will have a relation to the user model. The relation will be created via loopback and it will be a hasOne relation. This means that each user model instance will "own" exactly ONE chart model instance that looks like the example above.

Data Flow

So this is how the data is gonna flow through the app:

  1. User logs in and an HTTP Get request gathers the user's ONE array like the example above, and it is copied locally in a chart provider file.
  2. The chart component will get its data from the most recent entry in the array in chart Provider. That way the data will persist no matter what page you put the chart component on. Tricky stuff 😮
  3. The assessment page is where the user will update their life wheel. The range sliders will be ngmodeled to their own separate data array. When the user presses submit, that's when we will make the HTTP request to append this most recent data array to their array of data arrays, like the example above.

Clone this wiki locally