Skip to content

Data Model: Chart

awstin17 edited this page Oct 24, 2018 · 7 revisions

What the model will look like:

The model for the chart data will be an object that looks like this:

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

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 hasMany relation. This means that each user model instance will "own" lots of chart model instances that look like the example above. I'm pretty sure that a get request for all instances of the model will return an array of them, which will be really nice for displaying in the view via ngFors and loops, etc.

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 array of charts, 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 post this data array to the backend.

Clone this wiki locally