Class: PostRunner::ChartView
- Inherits:
-
Object
- Object
- PostRunner::ChartView
- Defined in:
- lib/postrunner/ChartView.rb
Instance Method Summary collapse
-
#initialize(activity, unit_system) ⇒ ChartView
constructor
A new instance of ChartView.
- #to_html(doc) ⇒ Object
Constructor Details
#initialize(activity, unit_system) ⇒ ChartView
Returns a new instance of ChartView.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/postrunner/ChartView.rb', line 19 def initialize(activity, unit_system) @activity = activity @sport = activity.sport @unit_system = unit_system @empty_charts = {} @hrv_analyzer = HRV_Analyzer.new(activity) @charts = [ { :id => 'pace', :label => 'Pace', :unit => select_unit('min/km'), :graph => :line_graph, :colors => '#0A7BEE', :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'speed', :label => 'Speed', :unit => select_unit('km/h'), :graph => :line_graph, :colors => '#0A7BEE', :show => @sport != 'running' }, { :id => 'Power_18FB2CF01A4B430DAD66988C847421F4', :label => 'Power', :unit => select_unit('Watts'), :graph => :line_graph, :colors => '#FFAC2E', :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'altitude', :label => 'Altitude', :unit => select_unit('m'), :graph => :line_graph, :colors => '#5AAA44', :show => @activity.sub_sport != 'treadmill' }, { :id => 'heart_rate', :label => 'Heart Rate', :unit => 'bpm', :graph => :line_graph, :colors => '#900000', :show => true }, { :id => 'hrv', :label => 'Heart Rate Variability', :short_label => 'HRV', :unit => 'ms', :graph => :line_graph, :colors => '#900000', :show => @hrv_analyzer.has_hrv_data? }, { :id => 'hrv_score', :label => 'rMSSD (30s Window)', :short_label => 'rMSSD', :graph => :line_graph, :colors => '#900000', :show => false }, { :id => 'respiration_rate', :label => 'Respiration Rate', :unit => 'brpm', :graph => :line_graph, :colors => '#9cd6ef', :show => true }, { :id => 'performance_condition', :label => 'Performance Condition', :graph => :line_graph, :colors => '#7CB7E7', :show => true }, { :id => 'run_cadence', :label => 'Run Cadence', :unit => 'spm', :graph => :point_graph, :colors => [ [ '#EE3F2D', 151 ], [ '#F79666', 163 ], [ '#A0D488', 174 ], [ '#96D7DE', 185 ], [ '#A88BBB', nil ] ], :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'stride_length', :label => 'Stride Length', :unit => select_unit('m'), :graph => :point_graph, :colors => [ ['#506DE1', nil ] ], :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'vertical_oscillation', :label => 'Vertical Oscillation', :short_label => 'Vert. Osc.', :unit => select_unit('cm'), :graph => :point_graph, :colors => [ [ '#A88BBB', 67 ], [ '#96D7DE', 84 ], [ '#A0D488', 101 ], [ '#F79666', 118 ], [ '#EE3F2D', nil ] ], :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'vertical_ratio', :label => 'Vertical Ratio', :unit => '%', :graph => :point_graph, :colors => [ [ '#CF45BD', 6.1 ], [ '#4FBEED', 7.4 ], [ '#6AB03A', 8.6 ], [ '#EDA14F', 10.1 ], [ '#FF5558', nil ] ], :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'Form_Power_18FB2CF01A4B430DAD66988C847421F4', :label => 'Form Power', :unit => select_unit('Watts'), :graph => :line_graph, :colors => '#CBBB58', :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'Leg_Spring_Stiffness_18FB2CF01A4B430DAD66988C847421F4', :label => 'Leg Spring Stiffness', :unit => select_unit('kN/m'), :graph => :line_graph, :colors => '#358C88', :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'stance_time', :label => 'Ground Contact Time', :short_label => 'GCT', :unit => 'ms', :graph => :point_graph, :colors => [ [ '#A88BBB', 208 ], [ '#96D7DE', 241 ], [ '#A0D488', 273 ], [ '#F79666', 305 ], [ '#EE3F2D', nil ] ], :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'gct_balance', :label => 'Ground Contact Time Balance', :short_label => 'GCT Balance', :unit => '%', :graph => :point_graph, :colors => [ [ '#FF5558', 47.8 ], [ '#EDA14F', 49.2 ], [ '#6AB03A', 50.7 ], [ '#EDA14F', 52.2 ], [ '#FF5558', nil ] ], :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'cadence', :label => 'Cadence', :unit => 'rpm', :graph => :line_graph, :colors => '#A88BBB', :show => @sport == 'cycling' }, { :id => "Air_Power_18FB2CF01A4B430DAD66988C847421F4", :label => 'Air Power', :unit => select_unit('Watts'), :graph => :line_graph, :colors => '#919498', :show => @sport == 'running' || @sport == 'multisport' }, { :id => 'temperature', :label => 'Temperature', :short_label => 'Temp.', :unit => 'C', :graph => :line_graph, :colors => '#444444', :show => true } ] end |
Instance Method Details
#to_html(doc) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/postrunner/ChartView.rb', line 204 def to_html(doc) doc.unique(:chartview_style) { doc.head { doc.style(style) } } doc.script(java_script) @charts.each do |chart| label = chart[:label] + (chart[:unit] ? " (#{chart[:unit]})" : '') chart_div(doc, chart[:id], label) if chart[:show] end end |