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.
16 17 18 19 20 21 |
# File 'lib/postrunner/ChartView.rb', line 16 def initialize(activity, unit_system) @activity = activity @sport = activity.fit_activity.sessions[0].sport @unit_system = unit_system @empty_charts = {} end |
Instance Method Details
#to_html(doc) ⇒ Object
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 |
# File 'lib/postrunner/ChartView.rb', line 23 def to_html(doc) doc.unique(:chartview_style) { doc.head { [ 'jquery/jquery-2.1.1.min.js', 'flot/jquery.flot.js', 'flot/jquery.flot.time.js' ].each do |js| doc.script({ 'language' => 'javascript', 'type' => 'text/javascript', 'src' => js }) end doc.style(style) } } doc.script(java_script) if @sport == 'running' chart_div(doc, 'pace', "Pace (#{select_unit('min/km')})") else chart_div(doc, 'speed', "Speed (#{select_unit('km/h')})") end chart_div(doc, 'altitude', "Elevation (#{select_unit('m')})") chart_div(doc, 'heart_rate', 'Heart Rate (bpm)') chart_div(doc, 'run_cadence', 'Run Cadence (spm)') chart_div(doc, 'vertical_oscillation', "Vertical Oscillation (#{select_unit('cm')})") chart_div(doc, 'stance_time', 'Ground Contact Time (ms)') end |