Class: Spoom::Coverage::D3::Timeline::Runtimes
- Inherits:
-
Spoom::Coverage::D3::Timeline
- Object
- Base
- Spoom::Coverage::D3::Timeline
- Spoom::Coverage::D3::Timeline::Runtimes
- Defined in:
- lib/spoom/coverage/d3/timeline.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(id, snapshots) ⇒ Runtimes
constructor
: (String id, Array snapshots) -> void.
-
#plot ⇒ Object
: -> String.
-
#tooltip ⇒ Object
: -> String.
Methods inherited from Spoom::Coverage::D3::Timeline
#area, header_script, header_style, #line, #points, #script, #x_scale, #x_ticks, #y_scale, #y_ticks
Methods inherited from Base
header_script, header_style, #html, #script
Constructor Details
#initialize(id, snapshots) ⇒ Runtimes
: (String id, Array snapshots) -> void
280 281 282 283 284 285 286 287 288 289 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 280 def initialize(id, snapshots) data = snapshots.map do |snapshot| { timestamp: snapshot., commit: snapshot.commit_sha, runtime: snapshot.duration.to_f / 1000.0 / 1000.0, } end super(id, data, []) end |
Instance Method Details
#plot ⇒ Object
: -> String
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 307 def plot " \#{x_scale}\n \#{y_scale(\n min: \"0\",\n max: \"d3.max(data_\#{id}, (d) => d.runtime)\",\n ticks: \"ticks(10)\",\n )}\n \#{area(y: \"d.runtime\")}\n \#{line(y: \"d.runtime\")}\n \#{points(y: \"d.runtime\")}\n \#{x_ticks}\n \#{y_ticks(ticks: \"ticks(5)\", format: 'd.toFixed(2) + \"s\"', padding: 40)}\n .call(g => g.selectAll(\".tick:first-of-type text\").remove())\n JS\nend\n" |
#tooltip ⇒ Object
: -> String
293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 293 def tooltip " function tooltip_\#{id}(d) {\n moveTooltip(d)\n .html(\"commit <b>\" + d.commit + \"</b><br>\"\n + d3.timeFormat(\"%y/%m/%d\")(parseDate(d.timestamp)) + \"<br><br>\"\n + \"<b>\" + d.runtime + \"</b>s<br><br>\"\n + \"(sorbet user + system time)\")\n }\n JS\nend\n" |