cairo-graph 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/examples/basic.rb +2 -0
- data/lib/cairo/graph.rb +12 -7
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d65aced2df6209d22f60d5ad3382b6f66475141a
         | 
| 4 | 
            +
              data.tar.gz: 44be113372e08a635722699bfd6468070f7df16e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 48663b86a1a724bab0d82b948abd4134ba1513036a83c260329ae66d9d58d981dd9c43fe758e6c10093884d4326a7bbf7620be6bdec5ff7b90255287ea55699c
         | 
| 7 | 
            +
              data.tar.gz: daa47bd2e9fe58d5aa4a2ff2b95a7b488771432b66a9bc2be7c10d8217e2fdd79b39c94c4bf8431c3ab537f196ff5194e3e08487bb1fca84f040096b1033faa2
         | 
    
        data/README.md
    CHANGED
    
    
    
        data/examples/basic.rb
    CHANGED
    
    
    
        data/lib/cairo/graph.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ module Cairo | |
| 8 8 | 
             
              end
         | 
| 9 9 |  | 
| 10 10 | 
             
              class Graph
         | 
| 11 | 
            -
                VERSION = "0.0. | 
| 11 | 
            +
                VERSION = "0.0.2"
         | 
| 12 12 |  | 
| 13 13 | 
             
                LINE_COLORS = [
         | 
| 14 14 | 
             
                  Cairo::Color.parse("#CCCCE6"),
         | 
| @@ -17,10 +17,6 @@ module Cairo | |
| 17 17 | 
             
                  Cairo::Color.parse("#F9B351"),
         | 
| 18 18 | 
             
                  Cairo::Color.parse("#83BE41"),
         | 
| 19 19 | 
             
                  Cairo::Color.parse("#E2629C"),
         | 
| 20 | 
            -
                  Cairo::Color::RGB.new(rand, rand, rand),
         | 
| 21 | 
            -
                  Cairo::Color::RGB.new(rand, rand, rand),
         | 
| 22 | 
            -
                  Cairo::Color::RGB.new(rand, rand, rand),
         | 
| 23 | 
            -
                  Cairo::Color::RGB.new(rand, rand, rand),
         | 
| 24 20 | 
             
                ]
         | 
| 25 21 |  | 
| 26 22 | 
             
                attr_reader :width
         | 
| @@ -45,6 +41,8 @@ module Cairo | |
| 45 41 | 
             
                attr_accessor :grid_max
         | 
| 46 42 | 
             
                attr_accessor :grid_step
         | 
| 47 43 |  | 
| 44 | 
            +
                attr_accessor :font
         | 
| 45 | 
            +
             | 
| 48 46 | 
             
                def initialize(options={})
         | 
| 49 47 | 
             
                  # TODO: validate options
         | 
| 50 48 |  | 
| @@ -82,6 +80,7 @@ module Cairo | |
| 82 80 | 
             
                end
         | 
| 83 81 |  | 
| 84 82 | 
             
                def draw(context)
         | 
| 83 | 
            +
                  context.select_font_face(@font) if @font
         | 
| 85 84 | 
             
                  draw_background(context)
         | 
| 86 85 | 
             
                  draw_title(context)
         | 
| 87 86 | 
             
                  draw_grid(context)
         | 
| @@ -145,7 +144,7 @@ module Cairo | |
| 145 144 | 
             
                  x1 = @width - (@margin_right * 0.85)
         | 
| 146 145 | 
             
                  x2 = @width - (@margin_right * 0.1)
         | 
| 147 146 | 
             
                  @names.each_with_index do |name, i|
         | 
| 148 | 
            -
                    context.set_source_color( | 
| 147 | 
            +
                    context.set_source_color(line_color(i))
         | 
| 149 148 | 
             
                    text = (@names[i] || (i + 1)).to_s
         | 
| 150 149 | 
             
                    y = (@margin_top * 0.7) + (font_size * i * 1.8)
         | 
| 151 150 | 
             
                    context.stroke do
         | 
| @@ -194,7 +193,7 @@ module Cairo | |
| 194 193 |  | 
| 195 194 | 
             
                def draw_row(context, index)
         | 
| 196 195 | 
             
                  row = @rows[index]
         | 
| 197 | 
            -
                  context.set_source_color( | 
| 196 | 
            +
                  context.set_source_color(line_color(index))
         | 
| 198 197 | 
             
                  points = []
         | 
| 199 198 | 
             
                  row.each_with_index do |value, i|
         | 
| 200 199 | 
             
                    x = interval_x * i + @margin_left
         | 
| @@ -283,5 +282,11 @@ module Cairo | |
| 283 282 | 
             
                  pattern.add_color_stop(1.0, @background_bottom_color)
         | 
| 284 283 | 
             
                  pattern
         | 
| 285 284 | 
             
                end
         | 
| 285 | 
            +
             | 
| 286 | 
            +
                def line_color(index)
         | 
| 287 | 
            +
                  @colors[index] ||
         | 
| 288 | 
            +
                    LINE_COLORS[index] ||
         | 
| 289 | 
            +
                    Cairo::Color::RGB.new(rand, rand, rand)
         | 
| 290 | 
            +
                end
         | 
| 286 291 | 
             
              end
         | 
| 287 292 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cairo-graph
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Masafumi Yokoyama
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-03- | 
| 11 | 
            +
            date: 2015-03-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: cairo
         |