google_otg 1.0.11 → 1.0.12
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.
- data/VERSION +1 -1
- data/google_otg.gemspec +2 -2
- data/lib/google_otg.rb +53 -33
- metadata +2 -2
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.0. | 
| 1 | 
            +
            1.0.12
         | 
    
        data/google_otg.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{google_otg}
         | 
| 8 | 
            -
              s.version = "1.0. | 
| 8 | 
            +
              s.version = "1.0.12"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["esilverberg"]
         | 
| 12 | 
            -
              s.date = %q{2009-10- | 
| 12 | 
            +
              s.date = %q{2009-10-05}
         | 
| 13 13 | 
             
              s.description = %q{Include Google's Over Time Graph in your app}
         | 
| 14 14 | 
             
              s.email = %q{eric@ericsilverberg.com}
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
    
        data/lib/google_otg.rb
    CHANGED
    
    | @@ -22,7 +22,7 @@ module GoogleOtg | |
| 22 22 | 
             
                    data = []
         | 
| 23 23 |  | 
| 24 24 | 
             
                    if hits[0].is_a?(Array)
         | 
| 25 | 
            -
                        shape_markers = [['o','0000ff',0,'-1.0', | 
| 25 | 
            +
                        shape_markers = [['D','6699CC',0,'-1.0',4],['D','FF9933',1,'-1.0',2],['o','0000ff',0,'-1.0',8],['o','FF6600',1,'-1.0',8]]
         | 
| 26 26 | 
             
                        line_colors = ['6699CC','FF9933']
         | 
| 27 27 |  | 
| 28 28 | 
             
                        hits.map{|h|
         | 
| @@ -33,8 +33,8 @@ module GoogleOtg | |
| 33 33 | 
             
                        }
         | 
| 34 34 |  | 
| 35 35 | 
             
                    else
         | 
| 36 | 
            -
                        shape_markers = ['o','0000ff',0,'-1.0', | 
| 37 | 
            -
                        line_colors = '6699CC' | 
| 36 | 
            +
                        shape_markers = [['D','6699CC',0,'-1.0',4],['o','0000ff',0,'-1.0',8]]
         | 
| 37 | 
            +
                        line_colors = ['6699CC']
         | 
| 38 38 |  | 
| 39 39 | 
             
                        converted = hits_to_gchart_range(hits, args)            
         | 
| 40 40 | 
             
                        data.push(converted[:points])
         | 
| @@ -65,7 +65,11 @@ module GoogleOtg | |
| 65 65 | 
             
                    height = args.has_key?(:height) ? args[:height] : 125
         | 
| 66 66 | 
             
                    src = args.has_key?(:src) ? args[:src] : "http://www.google.com/analytics/static/flash/OverTimeGraph.swf"
         | 
| 67 67 |  | 
| 68 | 
            -
                     | 
| 68 | 
            +
                    if hits.is_a?(Array) and hits[0].is_a?(Array)
         | 
| 69 | 
            +
                        range = hits.map{|h| hits_to_otg_range(h, args) }
         | 
| 70 | 
            +
                    else
         | 
| 71 | 
            +
                        range = [hits_to_otg_range(hits, args)]
         | 
| 72 | 
            +
                    end
         | 
| 69 73 | 
             
                    vars = range_to_flashvars(range)
         | 
| 70 74 |  | 
| 71 75 | 
             
                    html = <<-eos
         | 
| @@ -286,17 +290,50 @@ eos | |
| 286 290 | 
             
                end
         | 
| 287 291 | 
             
                protected :hits_to_range
         | 
| 288 292 |  | 
| 289 | 
            -
                 | 
| 290 | 
            -
             | 
| 291 | 
            -
             | 
| 292 | 
            -
             | 
| 293 | 
            -
             | 
| 293 | 
            +
                
         | 
| 294 | 
            +
                PRIMARY_STYLE = {
         | 
| 295 | 
            +
                                    :PointShape => "CIRCLE",
         | 
| 296 | 
            +
                                    :PointRadius => 9,
         | 
| 297 | 
            +
                                    :FillColor => 30668,
         | 
| 298 | 
            +
                                    :FillAlpha => 10,
         | 
| 299 | 
            +
                                    :LineThickness => 4,
         | 
| 300 | 
            +
                                    :ActiveColor => 30668,
         | 
| 301 | 
            +
                                    :InactiveColor => 11654895
         | 
| 302 | 
            +
                                }
         | 
| 303 | 
            +
                                
         | 
| 304 | 
            +
                COMPARE_STYLE = {
         | 
| 305 | 
            +
                                    :PointShape => "CIRCLE",
         | 
| 306 | 
            +
                                    :PointRadius => 6,
         | 
| 307 | 
            +
                                    :FillAlpha => 10,
         | 
| 308 | 
            +
                                    :LineThickness => 2,
         | 
| 309 | 
            +
                                    :ActiveColor => 16750848,
         | 
| 310 | 
            +
                                    :InactiveColor => 16750848
         | 
| 311 | 
            +
                                }
         | 
| 312 | 
            +
                                
         | 
| 313 | 
            +
                def setup_series(args, style)
         | 
| 314 | 
            +
                    raise ArgumentError unless args[:label]
         | 
| 315 | 
            +
                    raise ArgumentError unless args[:points]
         | 
| 316 | 
            +
                    raise ArgumentError unless args[:y_labels]
         | 
| 294 317 |  | 
| 318 | 
            +
                        return {
         | 
| 319 | 
            +
                                :SelectionStartIndex => 0,
         | 
| 320 | 
            +
                                :SelectionEndIndex => args[:points].length,
         | 
| 321 | 
            +
                                :Style => style,
         | 
| 322 | 
            +
                                :Label => args[:label],
         | 
| 323 | 
            +
                                :Id => "primary",
         | 
| 324 | 
            +
                                :YLabels => args[:y_labels],
         | 
| 325 | 
            +
                                :ValueCategory => "visits",
         | 
| 326 | 
            +
                                :Points => args[:points]
         | 
| 327 | 
            +
                            } # end graph
         | 
| 328 | 
            +
                end
         | 
| 329 | 
            +
                protected :setup_series
         | 
| 330 | 
            +
                
         | 
| 331 | 
            +
                def range_to_flashvars(args = {})
         | 
| 332 | 
            +
                    raise ArgumentError unless args.length > 0
         | 
| 333 | 
            +
                    x_labels = args[0][:x_labels]
         | 
| 295 334 | 
             
                    raise ArgumentError unless x_labels
         | 
| 296 | 
            -
                    raise ArgumentError unless y_labels
         | 
| 297 | 
            -
                    raise ArgumentError unless label
         | 
| 298 | 
            -
                    raise ArgumentError unless points
         | 
| 299 335 |  | 
| 336 | 
            +
                    ct = 0
         | 
| 300 337 | 
             
                        # this is the structure necessary to support the Google Analytics OTG
         | 
| 301 338 |  | 
| 302 339 | 
             
                        options = {:Graph => {
         | 
| @@ -308,29 +345,12 @@ eos | |
| 308 345 | 
             
                        :XAxisLabels => x_labels,
         | 
| 309 346 | 
             
                        :HoverType => "primary_compare",
         | 
| 310 347 | 
             
                        :SelectedSeries => ["primary", "compare"],
         | 
| 311 | 
            -
                        :Series =>  | 
| 312 | 
            -
             | 
| 313 | 
            -
             | 
| 314 | 
            -
                                 | 
| 315 | 
            -
                                :Style => 
         | 
| 316 | 
            -
                                {
         | 
| 317 | 
            -
                                    :PointShape => "CIRCLE",
         | 
| 318 | 
            -
                                    :PointRadius => 9,
         | 
| 319 | 
            -
                                    :FillColor => 30668,
         | 
| 320 | 
            -
                                    :FillAlpha => 10,
         | 
| 321 | 
            -
                                    :LineThickness => 4,
         | 
| 322 | 
            -
                                    :ActiveColor => 30668,
         | 
| 323 | 
            -
                                    :InactiveColor => 11654895
         | 
| 324 | 
            -
                                },
         | 
| 325 | 
            -
                                :Label => label,
         | 
| 326 | 
            -
                                :Id => "primary",
         | 
| 327 | 
            -
                                :YLabels => y_labels,
         | 
| 328 | 
            -
                                :ValueCategory => "visits",
         | 
| 329 | 
            -
                                :Points => points
         | 
| 330 | 
            -
                                    }]        
         | 
| 348 | 
            +
                        :Series => args.map {|arg| 
         | 
| 349 | 
            +
                                    ct += 1
         | 
| 350 | 
            +
                                    setup_series(arg, ct == 1 ? PRIMARY_STYLE : COMPARE_STYLE) 
         | 
| 351 | 
            +
                                }
         | 
| 331 352 | 
             
                            } # end graph
         | 
| 332 353 | 
             
                        } # end options
         | 
| 333 | 
            -
             | 
| 334 354 | 
             
                    return URI::encode(options.to_json)
         | 
| 335 355 | 
             
                end
         | 
| 336 356 | 
             
                protected :range_to_flashvars
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: google_otg
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.12
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - esilverberg
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2009-10- | 
| 12 | 
            +
            date: 2009-10-05 00:00:00 -07:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         |