Sha256: c20e5f9ddbae36e3d54bef8d1be8e0177e3cea5f5343da0fdae6aeda59c74e55

Contents?: true

Size: 919 Bytes

Versions: 10

Compression:

Stored size: 919 Bytes

Contents

# frozen_string_literal: true

#
# Makes a small bar graph suitable for display at 200px or even smaller.
#
# Here's how to set up a Gruff::Mini::Bar.
#
#   g = Gruff::Mini::Bar.new
#   g.title = 'Mini Bar Graph'
#   g.data :Art, [0, 5, 8, 15]
#   g.data :Philosophy, [10, 3, 2, 8]
#   g.data :Science, [2, 15, 8, 11]
#   g.write('mini_bar.png')
#
module Gruff
  module Mini
    # A class for drawing a small bar graph.
    class Bar < Gruff::Bar
    private

      include Gruff::Mini::Legend

      def initialize_attributes
        super

        @hide_legend = true
        @hide_title = true
        @hide_line_numbers = true

        @marker_font.size = 50.0
        @legend_font.size = 60.0

        @minimum_value = 0.0
      end

      def setup_data
        expand_canvas_for_vertical_legend
        super
      end

      def draw_graph
        super
        draw_vertical_legend
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gruff-0.18.0-java lib/gruff/mini/bar.rb
gruff-0.18.0 lib/gruff/mini/bar.rb
gruff-0.17.0-java lib/gruff/mini/bar.rb
gruff-0.17.0 lib/gruff/mini/bar.rb
gruff-0.16.0 lib/gruff/mini/bar.rb
gruff-0.16.0-java lib/gruff/mini/bar.rb
gruff-0.15.0-java lib/gruff/mini/bar.rb
gruff-0.15.0 lib/gruff/mini/bar.rb
gruff-0.14.0 lib/gruff/mini/bar.rb
gruff-0.14.0-java lib/gruff/mini/bar.rb