Class: Trevl::Notebook::Display
- Inherits:
-
Object
- Object
- Trevl::Notebook::Display
- Defined in:
- lib/trevl/notebook/display.rb
Instance Method Summary collapse
Instance Method Details
#render_chart(highcharts_data, height: 400) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/trevl/notebook/display.rb', line 6 def render_chart(highcharts_data, height: 400) container_id = "trevl_#{SecureRandom.hex(6)}" html = +"" html << highcharts_script_tag unless @highcharts_loaded html << <<~HTML <div id="#{container_id}" style="width:100%;height:#{height}px;"></div> <script> Highcharts.chart('#{container_id}', #{highcharts_data.to_json}); </script> HTML @highcharts_loaded = true display_html(html) end |
#render_score(display_data) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/trevl/notebook/display.rb', line 22 def render_score(display_data) value = display_data["value"] unit = display_data["unit"] || "" header = display_data["header"] || {} title = header["title"] || "" html = <<~HTML <div style="text-align:center;padding:20px;font-family:sans-serif;"> <div style="font-size:14px;color:#6b7280;margin-bottom:8px;">#{title}</div> <div style="font-size:48px;font-weight:700;color:#1f2937;">#{value}#{unit}</div> </div> HTML display_html(html) end |