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

Brett chart resources #254

Merged
merged 4 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ export class ChartComponent {
//calls the function that draws the chart on the canvas within the .html file of the component taking the response from the provider as an argument.
this.buildChart(res)
})

}

//this builds the chart, it takes one parameter, the parameter needs to be an array with a length of 8 numbers in order for the chart to draw correctly
buildChart(data){
this.chart = new Chart(this.canvas.nativeElement, {
type: 'polarArea',
data: { labels: ["Career", "Finance", "Personal \n Growth", "Health", "Family", "Relationships", "Social life", "Attitude"],
data: { labels: ["Career", "Finances", "Personal \n Growth", "Health", "Family", "Relationships", "Social life", "Attitude"],
datasets: [
{
backgroundColor: ["rgba(0,0,255, .6)", "rgba(255,0,0, .6)", "rgba(128,0,128, .6)", "rgba(0,128,0, .6)", "rgba(255,165,0, .6)", "rgba(0,128,128, .6)", "rgba(255,0,255, .6)", "rgba(0,255,0, .6)"],
Expand Down
2 changes: 1 addition & 1 deletion src/pages/history/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class HistoryPage {
@ViewChild('lineChart') lineChart;

historyPage: any = 'historyPage';
labels = ["Career", "Finance", "Personal \n Growth", "Health", "Family", "Relationships", "Social life", "Attitude"];
labels = ["Career", "Finances", "Personal \n Growth", "Health", "Family", "Relationships", "Social life", "Attitude"];
lineColors = ["rgba(0,0,255, .3)", "rgba(255,0,0, .3)", "rgba(128,0,128, .3)", "rgba(0,128,0, .3)", "rgba(255,165,0, .3)", "rgba(0,128,128, .3)", "rgba(255,0,255, .3)", "rgba(0,255,0, .3)"];
dataArrays = []
history:any;
Expand Down
5 changes: 5 additions & 0 deletions src/pages/resources/resources.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ <h1 id="title">
This page will provide helpful resources to aid in your transition. Based on your self assessment, here are some areas which might need more help than others.
</ion-card-content>
</ion-card>
<ion-card padding>
<ion-card-content >
<chart></chart>
</ion-card-content>
</ion-card>
<ion-card>
<ion-card-header id='title'>
Your lowest score on self assessment is: <br><br>
Expand Down
4 changes: 2 additions & 2 deletions src/providers/chart/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ChartProvider {
let allData:any = []
res.map(x=>{
//Maps the response from the API to a format that the history page will accept.
allData.push({date: moment(x.date).format('MM/DD/YYYY'), value: [x.data.Career, x.data.Finance, x.data['Personal Growth'], x.data.Health, x.data.Family, x.data.Relationships, x.data['Social Life'], x.data.Attitude]})
allData.push({date: moment(x.date).format('MM/DD/YYYY'), value: [x.data.Career, x.data.Finances, x.data.PersonalGrowth, x.data.Health, x.data.Family, x.data.Relationships, x.data.SocialLife, x.data.Attitude]})
return allData
})
return allData
Expand All @@ -39,7 +39,7 @@ export class ChartProvider {
//Returns all data, recent gets the last or most recent item from the DB
let recent = res[res.length-1].data
//destructures the response object and places it into an array so that the chart can consume it.
let mostRecentChart = [recent.Career, recent.Finance, recent['Personal Growth'], recent.Health, recent.Family, recent.Relationships, recent['Social Life'], recent.Attitude]
let mostRecentChart = [recent.Career, recent.Finances, recent.PersonalGrowth, recent.Health, recent.Family, recent.Relationships, recent.SocialLife, recent.Attitude]
return mostRecentChart
})
}
Expand Down