Class: Spoom::Coverage::D3::Timeline::Versions
- Defined in:
- lib/spoom/coverage/d3/timeline.rb
Instance Method Summary collapse
-
#initialize(id, snapshots) ⇒ Versions
constructor
: (String id, Array snapshots) -> void.
-
#plot ⇒ Object
: -> String.
-
#tooltip ⇒ Object
: -> String.
Methods inherited from Timeline
#commits_for_dates, #months, #ticks
Constructor Details
#initialize(id, snapshots) ⇒ Versions
: (String id, Array snapshots) -> void
230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 230 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
: -> String
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 259 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
: -> String
244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 244 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 |