Class: Spoom::Coverage::D3::Timeline::Versions
- Inherits:
-
Spoom::Coverage::D3::Timeline
- Object
- Base
- Spoom::Coverage::D3::Timeline
- Spoom::Coverage::D3::Timeline::Versions
- Extended by:
- T::Sig
- Defined in:
- lib/spoom/coverage/d3/timeline.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(id, snapshots) ⇒ Versions
constructor
A new instance of Versions.
- #plot ⇒ Object
- #tooltip ⇒ Object
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) ⇒ Versions
Returns a new instance of Versions.
236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 236 def initialize(id, snapshots) data = snapshots.map do |snapshot| { timestamp: snapshot., commit: snapshot.commit_sha, static: snapshot.version_static, runtime: snapshot.version_runtime, } end super(id, data, []) end |
Instance Method Details
#plot ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 263 def plot <<~JS #{x_scale} #{y_scale( min: "d3.min([d3.min(data_#{id}, (d) => parseVersion(d.static)), d3.min(data_#{id}, (d) => parseVersion(d.runtime))]) - 0.01", max: "d3.max([d3.max(data_#{id}, (d) => parseVersion(d.static)), d3.max(data_#{id}, (d) => parseVersion(d.runtime))]) + 0.01", ticks: "ticks(8)", )} #{line(y: "parseVersion(d.runtime)", color: "#e83e8c", curve: "curveStepAfter")} #{line(y: "parseVersion(d.static)", color: "#007bff", curve: "curveStepAfter")} #{points(y: "parseVersion(d.static)")} #{x_ticks} #{y_ticks(ticks: "ticks(4)", format: "'v0.' + d.toFixed(2)", padding: 50)} JS end |
#tooltip ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 249 def tooltip <<~JS function tooltip_#{id}(d) { moveTooltip(d) .html("commit <b>" + d.commit + "</b><br>" + d3.timeFormat("%y/%m/%d")(parseDate(d.timestamp)) + "<br><br>" + "static: v<b>" + d.static + "</b><br>" + "runtime: v<b>" + d.runtime + "</b><br><br>" + "versions from<br>Gemfile.lock") } JS end |