[Pharo] Personal fitness tracker web app.
Graphs.
Changed files
src/MyFitnessTracker/MFTRepsDistributionGraph.class.st
@@ -0,0 +1,51 @@
1
Added:
Class {
2
Added:
#name : #MFTRepsDistributionGraph,
3
Added:
#superclass : #MFTGraph,
4
Added:
#category : #'MyFitnessTracker-Components'
5
Added:
}
6
Added:
7
Added:
{ #category : #'as yet unclassified' }
8
Added:
MFTRepsDistributionGraph >> crunchTheNumbers [
9
Added:
10
Added:
| exercises repTally |
11
Added:
exercises := self session user workouts flatCollect: #exercises.
12
Added:
repTally := Dictionary new.
13
Added:
exercises do: [ :exercise |
14
Added:
repTally at: exercise englishName ifAbsentPut: [ 0 ].
15
Added:
repTally
16
Added:
at: exercise englishName
17
Added:
put: (repTally at: exercise englishName) + exercise repsBySet sum ].
18
Added:
19
Added:
labels := repTally keys.
20
Added:
data := repTally values
21
Added:
]
22
Added:
23
Added:
{ #category : #initialization }
24
Added:
MFTRepsDistributionGraph >> initialize [
25
Added:
26
Added:
super initialize.
27
Added:
self crunchTheNumbers
28
Added:
]
29
Added:
30
Added:
{ #category : #rendering }
31
Added:
MFTRepsDistributionGraph >> renderContentOn: html [
32
Added:
33
Added:
html canvas id: 'repsVsTimeChart'.
34
Added:
html script:
35
Added:
'var ctx = document.getElementById("repsVsTimeChart").getContext("2d");
36
Added:
var workoutChart = new Chart(ctx, {
37
Added:
type: "doughnut",
38
Added:
data: {
39
Added:
labels: ' , labels asJavascript , ',
40
Added:
datasets: [{
41
Added:
data: ' , data asJavascript , '
42
Added:
}]
43
Added:
},
44
Added:
options: {
45
Added:
title: {
46
Added:
display: true,
47
Added:
text: "Reps by exercise"
48
Added:
}
49
Added:
}
50
Added:
});'
51
Added:
]
src/MyFitnessTracker/MFTRepsVsTimeGraph.class.st
@@ -1,51 +0,0 @@
1
Removed:
Class {
2
Removed:
#name : #MFTRepsVsTimeGraph,
3
Removed:
#superclass : #MFTGraph,
4
Removed:
#category : #'MyFitnessTracker-Components'
5
Removed:
}
6
Removed:
7
Removed:
{ #category : #'as yet unclassified' }
8
Removed:
MFTRepsVsTimeGraph >> crunchTheNumbers [
9
Removed:
10
Removed:
| exercises repTally |
11
Removed:
exercises := self session user workouts flatCollect: #exercises.
12
Removed:
repTally := Dictionary new.
13
Removed:
exercises do: [ :exercise |
14
Removed:
repTally at: exercise englishName ifAbsentPut: [ 0 ].
15
Removed:
repTally
16
Removed:
at: exercise englishName
17
Removed:
put: (repTally at: exercise englishName) + exercise repsBySet sum ].
18
Removed:
19
Removed:
labels := repTally keys.
20
Removed:
data := repTally values
21
Removed:
]
22
Removed:
23
Removed:
{ #category : #initialization }
24
Removed:
MFTRepsVsTimeGraph >> initialize [
25
Removed:
26
Removed:
super initialize.
27
Removed:
self crunchTheNumbers
28
Removed:
]
29
Removed:
30
Removed:
{ #category : #rendering }
31
Removed:
MFTRepsVsTimeGraph >> renderContentOn: html [
32
Removed:
33
Removed:
html canvas id: 'workoutChart'.
34
Removed:
html script:
35
Removed:
'var ctx = document.getElementById("workoutChart").getContext("2d");
36
Removed:
var workoutChart = new Chart(ctx, {
37
Removed:
type: "doughnut",
38
Removed:
data: {
39
Removed:
labels: ' , labels asJavascript , ',
40
Removed:
datasets: [{
41
Removed:
data: ' , data asJavascript , '
42
Removed:
}]
43
Removed:
},
44
Removed:
options: {
45
Removed:
title: {
46
Removed:
display: true,
47
Removed:
text: "Reps by exercise"
48
Removed:
}
49
Removed:
}
50
Removed:
});'
51
Removed:
]
src/MyFitnessTracker/MFTWeightVsTimeGraph.class.st
@@ -11,12 +11,9 @@
11
11
weight date yyyymmdd ].
12
12
data := self session user weights collect: #value.
13
13
14
Removed:
html canvas
15
Removed:
id: 'weightChart';
16
Removed:
height: 1;
17
Removed:
width: 1.
14
Added:
html canvas id: 'weightVsTimeChart'.
18
15
html script:
19
Removed:
'var ctx = document.getElementById("weightChart").getContext("2d");
16
Added:
'var ctx = document.getElementById("weightVsTimeChart").getContext("2d");
20
17
var weightChart = new Chart(ctx, {
21
18
type: "line",
22
19
data: {
src/MyFitnessTracker/MFTWorkoutVolumePerWeekGraph.class.st
@@ -0,0 +1,35 @@
1
Added:
Class {
2
Added:
#name : #MFTWorkoutVolumePerWeekGraph,
3
Added:
#superclass : #MFTGraph,
4
Added:
#category : #'MyFitnessTracker-Components'
5
Added:
}
6
Added:
7
Added:
{ #category : #initialization }
8
Added:
MFTWorkoutVolumePerWeekGraph >> initialize [
9
Added:
10
Added:
super initialize
11
Added:
]
12
Added:
13
Added:
{ #category : #rendering }
14
Added:
MFTWorkoutVolumePerWeekGraph >> renderContentOn: html [
15
Added:
16
Added:
| datasets datasetsAsJs |
17
Added:
labels := Date dayNames.
18
Added:
data := self session user workouts collect: #volume.
19
Added:
datasets := {
20
Added:
{ 1. 2. 0. 0. 3. 5. 3 }.
21
Added:
{ 3. 4. 3. 0. 0. 0. 6 } }.
22
Added:
datasetsAsJs := datasets collectWithIndex: [ :dataset :i |
23
Added:
'{ label: ' , i asJavascript , ', data: '
24
Added:
, dataset asJavascript , '},' ].
25
Added:
html canvas id: 'workoutVolumePerWeekChart'.
26
Added:
html script:
27
Added:
'var ctx = document.getElementById("workoutVolumePerWeekChart").getContext("2d");
28
Added:
var weightChart = new Chart(ctx, {
29
Added:
type: "line",
30
Added:
data: {
31
Added:
labels: ' , labels asJavascript , ',
32
Added:
datasets: [ ' , (datasetsAsJs joinUsing: Character space) , ' ]
33
Added:
},
34
Added:
});'
35
Added:
]
src/MyFitnessTracker/MFTWorkoutVolumeVsTimeGraph.class.st
@@ -0,0 +1,33 @@
1
Added:
Class {
2
Added:
#name : #MFTWorkoutVolumeVsTimeGraph,
3
Added:
#superclass : #MFTGraph,
4
Added:
#category : #'MyFitnessTracker-Components'
5
Added:
}
6
Added:
7
Added:
{ #category : #initialization }
8
Added:
MFTWorkoutVolumeVsTimeGraph >> initialize [
9
Added:
10
Added:
super initialize
11
Added:
]
12
Added:
13
Added:
{ #category : #rendering }
14
Added:
MFTWorkoutVolumeVsTimeGraph >> renderContentOn: html [
15
Added:
16
Added:
labels := self session user workouts collect: [ :workout |
17
Added:
workout date yyyymmdd ].
18
Added:
data := self session user workouts collect: #volume.
19
Added:
20
Added:
html canvas id: 'workoutVolumeVsTimeChart'.
21
Added:
html script:
22
Added:
'var ctx = document.getElementById("workoutVolumeVsTimeChart").getContext("2d");
23
Added:
var weightChart = new Chart(ctx, {
24
Added:
type: "line",
25
Added:
data: {
26
Added:
labels: ' , labels asJavascript , ',
27
Added:
datasets: [{
28
Added:
label: "total workout volume",
29
Added:
data: ' , data asJavascript , ',
30
Added:
}]
31
Added:
},
32
Added:
});'
33
Added:
]