Class: Flightdeck::Metrics::BarChart
- Defined in:
- app/models/flightdeck/metrics/bar_chart.rb
Overview
Succeeded stacked under failed, per bucket.
Constant Summary collapse
- BAR_GAP =
2- CORNER =
1.5
Constants inherited from Chart
Chart::GRID_INTERVALS, Chart::HEIGHT, Chart::PAD_BOTTOM, Chart::PAD_LEFT, Chart::PAD_RIGHT, Chart::PAD_TOP, Chart::WIDTH
Instance Attribute Summary
Attributes inherited from Chart
Instance Method Summary collapse
Methods inherited from Chart
#axis_max, #empty?, #format_time, #full_time, #gridlines, #height, #initialize, #plot_bottom, #plot_height, #plot_left, #plot_right, #plot_top, #plot_width, #width, #x_ticks
Constructor Details
This class inherits a constructor from Flightdeck::Metrics::Chart
Instance Method Details
#bars ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/flightdeck/metrics/bar_chart.rb', line 10 def points.each_with_index.map do |point, index| x = plot_left + (slot_width * index) = [ slot_width - BAR_GAP, 1 ].max failed_height = height_for(point.failed) succeeded_height = height_for(point.succeeded) failed_y = plot_bottom - failed_height - succeeded_height { x: round(x + (BAR_GAP / 2.0)), width: round(), corner: CORNER, succeeded: { y: round(plot_bottom - succeeded_height), height: round(succeeded_height) }, failed: { y: round(failed_y), height: round(failed_height) }, empty: point.total.zero?, title: (point) } end end |