[
  {
    "path": ".gitignore",
    "content": ".DS_Store\nlog/*\n.manifest\npkg\n.rspec\n.rvmrc\nGemfile.lock"
  },
  {
    "path": ".travis.yml",
    "content": "language: ruby\nrvm:\n  - 1.8.7\n  - ree\n  - 1.9.2\n  - 1.9.3\n  - 2.0.0\n  - jruby\n"
  },
  {
    "path": "Gemfile",
    "content": "source \"http://rubygems.org\"\ngemspec\n\ngroup :test do\n  gem 'rspec'\n  gem 'rake', '>= 0.8.7'\nend\n\n\n\n"
  },
  {
    "path": "History.txt",
    "content": "== 1.6.12\n* added license to gemspec\n* added pie_c type for concentric pie charts\n\n== 1.6.10\n* added support for custom position on axis with label (parameter chxp)\n* refactored bar chart\n* fixed issue #44\n* allows GChart to take a theme \n\n== 1.6.8\n* added title alignment support\n\n== 1.6.7\n* changed url for ssl connection\n\n== 1.6.6\n* added ssl support\n* refactored code\n* аdded ability to set the legend position\n* fixed legend position value\n* separated labels and legends for pies\n\n== 1.3.6\n* support nil values. The Google Charts API specifies that a single underscore (_) can be used to omit a value from a line chart with 'simple' data encoding, and a double underscore (__) can do the same for a chart with 'extended' data encoding. (Matt Moyer)\n* allow a label to appear on a google-o-meter via the :legend option. (hallettj)\n\n== 1.3.5\n* added code to properly escape image tag URLs (mokolabs)\n* added themes support + 4 default themes (keynote, thirty7signals, pastel, greyscale) chart.line(:theme=>:keynote) (jakehow)\n\n== 1.3.4\n* updated documentation and cleaned it up (mokolabs)\n* added support for custom class, id and alt tags when using the image_tag format (i.e Gchart.line(:data => [0, 26], :format => 'image_tag')) (mokolabs)\n\n== 1.3.2 - 1.3.3\n* changes required by github\n\n== 1.3.1\n* added width and spacing options\n\n== 1.3.0\n* added support for google-o-meter\n* fixed a bug when the max value of a data set was 0\n\n== 1.2.0\n* added support for sparklines\n\n== 1.1.0\n* fixed another bug fix related to the uri escaping required to download the file properly.\n\n== 1.0.0\n* fixed the (URI::InvalidURIError) issue\n\n== 0.2.0\n* added export options (file and image tag)\n* added support for all arguments to be passed as a string or an array\n\n== 0.1.0 2007-12-11\n* fixed the axis labels\n\n== 0.0.3 2007-12-11\n* added :chart_background alias and fixed a bug related to the background colors.\n\n== 0.0.2 2007-12-11\n* added support for more features and aliases\n\n== 0.0.1 2007-12-08\n\n* 1 major enhancement:\n  * Initial release\n"
  },
  {
    "path": "License.txt",
    "content": "Copyright (c) 2007 Matt Aimonetti\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
  },
  {
    "path": "README",
    "content": ""
  },
  {
    "path": "README.markdown",
    "content": "## Googlecharts\n\n[![Build Status](https://travis-ci.org/mattetti/googlecharts.png?branch=master)](https://travis-ci.org/mattetti/googlecharts)\n\nThe goal of this Gem is to make the creation of Google Charts a simple and easy task.\n    \n    require 'googlecharts'\n    Gchart.line(  :size => '200x300', \n                  :title => \"example title\",\n                  :bg => 'efefef',\n                  :legend => ['first data set label', 'second data set label'],\n                  :data => [10, 30, 120, 45, 72])\n              \n\nCheck out the [full documentation over there](http://googlecharts.rubyforge.org/)\n\nThis gem is fully tested using Rspec, check the rspec folder for more examples.\n\nSee at the bottom of this file who reported using this gem.\n\nChart Type\n-------------\n\nThis gem supports the following types of charts:\n  \n  * line, \n  * line_xy\n  * sparkline\n  * scatter\n  * bar\n  * venn\n  * pie\n  * pie_3d\n  * google meter\n  \nGooglecharts also supports graphical themes and you can easily load your own.\n\nTo create a chart, simply require Gchart and call any of the existing type:\n\n    require 'gchart'\n    Gchart.pie\n  \n  \nChart Title\n-------------\n\n  To add a title to a chart pass the title to your chart:\n  \n    Gchart.line(:title => 'Sexy Charts!')\n    \nYou can also specify the color and/or size\n    \n    Gchart.line(:title => 'Sexy Charts!', :title_color => 'FF0000', :title_size => '20')\n\nColors\n-------------\n\nSpecify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example:\n\n    * FF0000 = red\n    * 00FF00 = green\n    * 0000FF = blue\n    * 000000 = black\n    * FFFFFF = white\n\nYou can optionally specify transparency by appending a value between 00 and FF where 00 is completely transparent and FF completely opaque. For example:\n\n    * 0000FFFF = solid blue\n    * 0000FF00 = transparent blue\n\nIf you need to use multiple colors, check the doc. Usually you just need to pass :attribute => 'FF0000,00FF00'\n\nSome charts have more options than other, make sure to refer to the documentation.\n\nBackground options:\n-------------\n\nIf you don't set the background option, your graph will be transparent.\n\n* You have 3 types of background  http://code.google.com/apis/chart/#chart_or_background_fill\n\n- solid\n- gradient\n- stripes\n\nBy default, if you set a background color, the fill will be solid:\n\n    Gchart.bar(:bg => 'efefef')\n\nHowever you can specify another fill type such as:\n            \n    Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})\n  \nIn the above code, we decided to have a gradient background, however since we only passed one color, the chart will start by the specified color and transition to white. By the default, the gradient angle is 0. Change it as follows:\n\n    Gchart.line(:title =>'bg example', :bg => {:color => 'efefef', :type => 'gradient', :angle => 90})\n    \nFor a more advance use of colors, refer to http://code.google.com/apis/chart/#linear_gradient\n\n    Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'})\n    \n    \nThe same way you set the background color, you can also set the graph background:\n\n    Gchart.line(:graph_bg => 'cccccc')\n    \nor both\n\n    Gchart.line(:bg => {:color => '76A4FB,1,ffffff,0', :type => 'gradient'}, :graph_bg => 'cccccc', :title => 'Sexy Chart')\n    \n    \nAnother type of fill is stripes http://code.google.com/apis/chart/#linear_stripes\n\n    Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})\n    \nYou can customize the amount of stripes, colors and width by changing the color value.\n\n\nThemes\n--------\n\n  Googlecharts comes with 4 themes: keynote, thirty7signals, pastel and greyscale. (ganked from [Gruff](http://github.com/topfunky/gruff/tree/master)\n\n\n    Gchart.line(\n                :theme => :keynote, \n                :data => [[0,40,10,70,20],[41,10,80,50,40],[20,60,30,60,80],[5,23,35,10,56],[80,90,5,30,60]], \n                :title => 'keynote'\n                )\n\n  * keynote\n\n    ![keynote](http://chart.apis.google.com/chart?chtt=keynote&chco=6886B4,FDD84E,72AE6E,D1695E,8A6EAF,EFAA43&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=c,s,FFFFFF|bg,s,000000)\n\n  * thirty7signals\n\n    ![37signals](http://chart.apis.google.com/chart?chtt=thirty7signals&chco=FFF804,336699,339933,ff0000,cc99cc,cf5910&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo&chf=bg,s,FFFFFF)\n\n  * pastel\n\n    ![pastel](http://chart.apis.google.com/chart?chtt=pastel&chco=a9dada,aedaa9,daaea9,dadaa9,a9a9da&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo)\n\n  * greyscale\n\n    ![greyscale](http://chart.apis.google.com/chart?chtt=greyscale&chco=282828,383838,686868,989898,c8c8c8,e8e8e8&chs=300x200&cht=lc&chd=s:AbGvN,bG2hb,NoUo2,DPXGl,29DUo)\n\n\nYou can also use your own theme. Create a yml file using the same format as the themes located in lib/themes.yml\n\nLoad your theme(s):\n\n      Chart::Theme.add_theme_file(\"#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml\")\n\nAnd use the standard method signature to use your own theme:\n\n      Gchart.line(:theme => :custom_theme, :data => [[0, 40, 10, 70, 20],[41, 10, 80, 50]], :title => 'greyscale')\n\n    \n    \nLegend & Labels\n-------------\n\nYou probably will want to use a legend or labels for your graph.\n\n    Gchart.line(:legend => 'legend label')\nor\n    Gchart.line(:legend => ['legend label 1', 'legend label 2'])\n    \nWill do the trick. You can also use the labels alias (makes more sense when using the pie charts)\n\n    chart = Gchart.pie(:labels => ['label 1', 'label 2'])\n\nMultiple axis labels \n-------------\n\nMultiple axis labels are available for line charts, bar charts and scatter plots.\n\n* x = bottom x-axis\n* t = top x-axis\n* y = left y-axis\n* r = right y-axis\n\n    Gchart.line(:axis_with_label => 'x,y,r,t')\n  \nTo add labels on these axis:\n\n    Gchart.line(:axis_with_label => 'x,y,r,t',\n                :axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])\n\nNote that each array entry could also be an array but represent the\nlabels for the corresponding axis.\n\nA question which comes back often is how do I only display the y axis\nlabel? Solution:\n\n    Gchart.line(\n            :data => [0,20, 40, 60, 140, 230, 60],\n            :axis_with_labels => 'y')\n\nCustom axis ranges\n---------------\n\nIf you want to display a custom range for an axis, you need to set the\nrange as described in the Google charts documentation: min, max, step:\n\n     Gchart.line( :data => [17, 17, 11, 8, 2], \n                  :axis_with_labels => ['x', 'y'], \n                  :axis_labels => [['J', 'F', 'M', 'A', 'M']], \n                  :axis_range => [nil, [2,17,5]])\n\n\nIn this case, the custom axis range is only defined for y (second\nentry) with a minimum value of 2, max 17 and a step of 5.\n\nThis is also valid if you want to set a x axis and automatically define\nthe y labels.\n    \n\nData options\n-------------\n\nData are passed using an array or a nested array.    \n\n    Gchart.bar(:data => [1,2,4,67,100,41,234])  \n  \n    Gchart.bar(:data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]])\n  \nBy default, the graph is drawn with your max value representing 100% of the height or width of the graph. You can change that my passing the max value.\n\n    Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 300)\n    Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => 'auto')\n  \nor if you want to use the real values from your dataset:\n\n    Gchart.bar(:data => [1,2,4,67,100,41,234], :max_value => false)\n  \n  \nYou can also define a different encoding to add more granularity:\n\n    Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'simple') \n    Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'extended') \n    Gchart.bar(:data => [1,2,4,67,100,41,234], :encoding => 'text') \n  \n\nPies:\n-------------\n  \nyou have 2 type of pies:\n  - Gchart.pie() the standard 2D pie\n  _ Gchart.pie_3d() the fancy 3D pie\n  \nTo set labels, you can use one of these two options:\n\n    @legend = ['Matt_fu', 'Rob_fu']\n    Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data, :size => '400x200')\n    Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data, :size => '400x200')\n  \nBars:\n-------------\n\nA bar chart can accept options to set the width of the bars, spacing between bars and spacing between bar groups. To set these, you can either provide a string, array or hash.\n\nThe Google API sets these options in the order of width, spacing, and group spacing, with both spacing values being optional. So, if you provide a string or array, provide them in that order:\n\n    Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6') # width of 25, spacing of 6\n    Gchart.bar(:data => @data, :bar_width_and_spacing => '25,6,12') # width of 25, spacing of 6, group spacing of 12\n    Gchart.bar(:data => @data, :bar_width_and_spacing => [25,6]) # width of 25, spacing of 6\n    Gchart.bar(:data => @data, :bar_width_and_spacing => 25) # width of 25\n  \nThe hash lets you set these values directly, with the Google default values set for any options you don't include:\n\n    Gchart.bar(:data => @data, :bar_width_and_spacing => {:width => 19})\n    Gchart.bar(:data => @data, :bar_width_and_spacing => {:spacing => 10, :group_spacing => 12})\n\nRadar:\n-------------\n    In a Radar graph, the x-axis is circular. The points can be connected by straight lines or curved lines.\n    Gchart.radar(:data => @data, :curved => true)\n\nSparklines:\n-------------\n\nA sparkline chart has exactly the same parameters as a line chart. The only difference is that the axes lines are not drawn for sparklines by default.\n  \n\nGoogle-o-meter\n-------------\n\nA Google-o-meter has a few restrictions. It may only use a solid filled background and it may only have one label.\n\nRecord Chart PNG file in filesystem Sample :\n--------------------------------------------\n\nMulti Lines Chart Sample :\n\n\tchart = Gchart.new(\t:type => 'line',\n\t\t\t\t\t\t:title => \"example title\",\n\t\t\t\t\t\t:theme => :keynote,\n\t\t\t\t\t\t:data => [[17, 17, 11, 8, 2],[10, 20, 15, 5, 7],[2, 3, 7, 9, 12]], \n\t\t\t\t\t\t:line_colors => 'e0440e,e62ae5,287eec',\n\t\t\t\t\t\t:legend => ['courbe 1','courbe 2','courbe 3'],\n\t\t\t\t\t\t:axis_with_labels => ['x', 'y'], \n\t\t\t\t\t\t:axis_range => [[0,100,20], [0,20,5]],\n\t\t\t\t\t\t:filename => \"tmp/chart.png\")\n\t\t\t\n\t# Record file in filesystem\n\tchart.file\n\ntry yourself\n-------------\n\n    Gchart.bar( :data => [[1,2,4,67,100,41,234],[45,23,67,12,67,300, 250]], \n                :title => 'SD Ruby Fu level', \n                :legend => ['matt','patrick'], \n                :bg => {:color => '76A4FB', :type => 'gradient'}, \n                :bar_colors => 'ff0000,00ff00')\n\n \"http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00\"  \n \n    Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan'])\nhttp://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan\n"
  },
  {
    "path": "README.txt",
    "content": "CHECK README.markdown  (open as a text file)\n\nhttp://github.com/mattetti/googlecharts"
  },
  {
    "path": "Rakefile",
    "content": "require 'rspec/core/rake_task'\n\ndesc 'Default: run specs.'\ntask :default => :spec\n\ndesc \"Run specs\"\nRSpec::Core::RakeTask.new do |task|\n    task.pattern = \"**/spec/*_spec.rb\"\n    task.rspec_opts = []\n    task.rspec_opts << '--color'\n    task.rspec_opts << '-f documentation'\nend"
  },
  {
    "path": "googlecharts.gemspec",
    "content": "# -*- encoding: utf-8 -*-\n$:.push File.expand_path(\"../lib\", __FILE__)\nrequire \"gchart/version\"\n\nGem::Specification.new do |s|\n  s.name = %q{googlecharts}\n  s.version = GchartInfo::VERSION\n  s.platform    = Gem::Platform::RUBY\n  s.authors = [\"Matt Aimonetti\", \"Andrey Deryabin\", \"Pedro Pimentel\"]\n  s.date = %q{2015-08-12}\n  s.summary = %q{Generate charts using Google API & Ruby}\n  s.description = %q{Generate charts using Google API & Ruby}\n  s.email = %q{mattaimonetti@gmail.com deriabin@gmail.com zukunft@gmail.com}\n  s.homepage = %q{http://googlecharts.rubyforge.org/}\n  s.license = 'MIT'\n\n  s.files         = `git ls-files`.split(\"\\n\")\n  s.test_files    = `git ls-files -- {test,spec,features}/*`.split(\"\\n\")\n  s.executables   = `git ls-files -- bin/*`.split(\"\\n\").map{ |f| File.basename(f) }\n  s.require_paths = [\"lib\"]\nend\n"
  },
  {
    "path": "lib/gchart/aliases.rb",
    "content": "class Gchart\n  \n  alias_method :background=, :bg=\n  alias_method :chart_bg=, :graph_bg=\n  alias_method :chart_color=, :graph_bg=\n  alias_method :chart_background=, :graph_bg=\n  alias_method :bar_color=, :bar_colors=\n  alias_method :line_colors=, :bar_colors=\n  alias_method :line_color=, :bar_colors=\n  alias_method :slice_colors=, :bar_colors=\n  alias_method :horizontal?, :horizontal\n  alias_method :curved?, :curved\n\nend\n"
  },
  {
    "path": "lib/gchart/theme.rb",
    "content": "require 'yaml'\n\nmodule Chart\n  class Theme\n    class ThemeNotFound < RuntimeError; end\n    \n    @@theme_files = [\"#{File.dirname(__FILE__)}/../themes.yml\"]\n\n    attr_accessor :colors\n    attr_accessor :bar_colors\n    attr_accessor :background\n    attr_accessor :chart_background\n    \n    def self.load(theme_name)\n      theme = new(theme_name)\n    end\n    \n    def self.theme_files\n      @@theme_files\n    end\n    \n    # Allows you to specify paths for custom theme files in YAML format\n    def self.add_theme_file(file)\n      @@theme_files << file\n    end\n    \n    def initialize(theme_name)\n      themes = {}\n      @@theme_files.each {|f| themes.update YAML::load(File.open(f))}\n      theme = themes[theme_name]\n      if theme\n        self.colors = theme[:colors]\n        self.bar_colors = theme[:bar_colors]\n        self.background = theme[:background]\n        self.chart_background = theme[:chart_background]\n        self\n      else\n        raise(ThemeNotFound, \"Could not locate the #{theme_name} theme ...\")\n      end\n    end\n    \n    def to_options\n      {:background => background, :chart_background => chart_background, :bar_colors => bar_colors.join(',')}\n    end\n  end\nend"
  },
  {
    "path": "lib/gchart/version.rb",
    "content": "module GchartInfo #:nodoc:\n  VERSION = \"1.6.12\"\nend\n"
  },
  {
    "path": "lib/gchart.rb",
    "content": "$:.unshift File.dirname(__FILE__)\nrequire 'gchart/version'\nrequire 'gchart/theme'\nrequire \"net/http\"\nrequire \"net/https\"\nrequire \"uri\"\nrequire \"cgi\"\nrequire 'enumerator'\n\nclass Gchart\n  include GchartInfo\n\n  def self.url(use_ssl = false)\n    if use_ssl\n      'https://chart.googleapis.com/chart?'\n    else\n      'http://chart.apis.google.com/chart?'\n    end\n  end\n\n  def self.types\n    @types ||= ['line', 'line_xy', 'scatter', 'bar', 'venn', 'pie', 'pie_3d', 'pie_c', 'jstize', 'sparkline', 'meter', 'map', 'radar']\n  end\n\n  def self.simple_chars\n    @simple_chars ||= ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a\n  end \n\n  def self.chars\n    @chars ||= simple_chars + ['-', '.']\n  end\n\n  def self.ext_pairs\n    @ext_pairs ||= chars.map { |char_1| chars.map { |char_2| char_1 + char_2 } }.flatten\n  end\n\n  def self.default_filename\n    'chart.png'\n  end\n\n  attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :overlapped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors,\n  :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :custom_axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass,\n  :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap\n\n  attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl\n\n  attr_accessor :min_value, :max_value\n\n  types.each do |type|\n    instance_eval <<-DYNCLASSMETH\n    def #{type}(options = {})\n      # Start with theme defaults if a theme is set\n      theme = options[:theme]\n      options = theme ? Chart::Theme.load(theme).to_options.merge(options) : options \n      # # Extract the format and optional filename, then clean the hash\n      format = options[:format] || 'url'\n      options[:filename] ||= default_filename\n      options.delete(:format)\n      #update map_colors to become bar_colors\n      options.update(:bar_colors => options[:map_colors]) if options.has_key?(:map_colors)\n      chart = new(options.merge!({:type => \"#{type}\"}))\n      chart.send(format)\n    end\n    DYNCLASSMETH\n  end\n\n  def self.version\n    VERSION::STRING\n  end\n\n  def self.method_missing(m, options={})\n    raise NoMethodError, \"#{m} is not a supported chart format. Please use one of the following: #{supported_types}.\"\n  end\n\n  def initialize(options={})\n    # Allow Gchart to take a theme too\n    @theme = options[:theme] \n    options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options\n    options.delete(:theme)\n\n    @type = options[:type] || 'line'\n    @data = []\n    @width = 300\n    @height = 200\n    @curved = false\n    @horizontal = false\n\n    @grouped = false\n    @overlapped = false\n\n    @use_ssl = false\n    @encoding = 'simple'\n    # @max_value = 'auto'\n    # @min_value defaults to nil meaning zero\n    @filename = options[:filename]\n    # Sets the alt tag when chart is exported as image tag\n    @alt = 'Google Chart'\n    # Sets the CSS id selector when chart is exported as image tag\n    @id = false\n    # Sets the CSS class selector when chart is exported as image tag\n    @klass = options[:class] || false\n    # set the options value if definable\n    options.each do |attribute, value| \n      send(\"#{attribute}=\", value) if self.respond_to?(\"#{attribute}=\")\n    end\n  end\n\n  def self.supported_types\n    self.types.join(' ')\n  end\n\n  # Defines the Graph size using the following format:\n  # width X height\n  def size=(size='300x200')\n    @width, @height = size.split(\"x\").map { |dimension| dimension.to_i }\n  end\n\n  def size\n    \"#{width}x#{height}\"\n  end\n\n  def dimensions\n    # TODO: maybe others?\n    [:line_xy, :scatter].include?(type) ? 2 : 1\n  end\n\n  # Sets the orientation of a bar graph\n  def orientation=(orientation='h')\n    if orientation == 'h' || orientation == 'horizontal'\n      self.horizontal = true\n    elsif orientation == 'v' || orientation == 'vertical'\n      self.horizontal = false\n    end\n  end\n\n  def bar_presentation\n    if @overlapped\n      'o'\n    elsif @grouped\n      'g'\n    else\n      's'\n    end\n  end\n\n  def bg=(options)\n    if options.is_a?(String)\n      @bg_color = options\n    elsif options.is_a?(Hash)\n      @bg_color = options[:color]\n      @bg_type  = options[:type]\n      @bg_angle = options[:angle]\n    end\n  end\n\n  def graph_bg=(options)\n    if options.is_a?(String)\n      @chart_color = options\n    elsif options.is_a?(Hash)\n      @chart_color = options[:color]\n      @chart_type  =  options[:type]\n      @chart_angle = options[:angle]\n    end\n  end\n\n  def max_value=(max_v)\n    if max_v =~ /false/\n      @max_value = false\n    else\n      @max_value = max_v\n    end\n  end\n\n  def min_value=(min_v)\n    if min_v =~ /false/\n      @min_value = false\n    else\n      @min_value = min_v\n    end\n  end\n\n  # returns the full data range as an array\n  # it also sets the data range if not defined\n  def full_data_range(ds)\n    return if max_value == false\n\n    ds.each_with_index do |mds, mds_index|\n      mds[:min_value] ||= min_value\n      mds[:max_value] ||= max_value\n\n      if mds_index == 0 && type.to_s == 'bar'\n        # TODO: unless you specify a zero line (using chp or chds),\n        #       the min_value of a bar chart is always 0.\n        #mds[:min_value] ||= mds[:data].first.to_a.compact.min\n        mds[:min_value] ||= 0\n      end\n      if (mds_index == 0 && type.to_s == 'bar' && \n        !grouped && mds[:data].first.is_a?(Array))\n        totals = []\n        mds[:data].each do |l|\n          l.each_with_index do |v, index|\n            next if v.nil?\n            totals[index] ||= 0\n            totals[index] += v\n          end\n        end\n        mds[:max_value] ||= totals.compact.max\n      else\n        all = mds[:data].flatten.compact\n        # default min value should be 0 unless set to auto\n        if mds[:min_value] == 'auto'\n          mds[:min_value] = all.min\n        else\n          min = all.min\n          mds[:min_value] ||=  (min && min < 0 ? min : 0)\n        end\n        mds[:max_value] ||= all.max\n      end\n    end\n\n    unless axis_range\n      @calculated_axis_range = true\n      @axis_range = ds.map{|mds| [mds[:min_value], mds[:max_value]]}\n      if dimensions == 1 && (type.to_s != 'bar' || horizontal)\n        tmp = axis_range.fetch(0, [])\n        @axis_range[0] = axis_range.fetch(1, [])\n        @axis_range[1] = tmp\n      end\n    end\n    # return [min, max] unless (min.nil? || max.nil?)\n    # @max = (max_value.nil? || max_value == 'auto') ? ds.compact.map{|mds| mds.compact.max}.max : max_value\n    # \n    # if min_value.nil? \n    #   min_ds_value = ds.compact.map{|mds| mds.compact.min}.min || 0\n    #   @min = (min_ds_value < 0) ? min_ds_value : 0\n    # else\n    #   @min = min_value == 'auto' ? ds.compact.map{|mds| mds.compact.min}.min || 0 : min_value      \n    # end\n    # @axis_range = [[min,max]]\n  end\n\n  def dataset\n    if @dataset\n      @dataset \n    else\n      @dataset = convert_dataset(data || [])\n      full_data_range(@dataset)   # unless axis_range\n      @dataset\n    end\n  end\n\n  # Sets of data to handle multiple sets\n  def datasets\n    datasets = []\n    dataset.each do |d|\n      if d[:data].first.is_a?(Array)\n        datasets += d[:data]\n      else\n        datasets << d[:data]\n      end\n    end\n    datasets\n  end\n\n  def self.jstize(string)\n    # See http://github.com/mattetti/googlecharts/issues#issue/27\n    #URI.escape( string ).gsub(\"%7C\", \"|\")\n    # See discussion: http://github.com/mattetti/googlecharts/commit/9b5cfb93aa51aae06611057668e631cd515ec4f3#comment_51347\n    string.gsub(' ', '+').gsub(/\\[|\\{|\\}|\\\\|\\^|\\[|\\]|\\`|\\]/) {|c| \"%#{c[0].to_s.upcase}\"}\n    #string.gsub(' ', '+').gsub(/\\[|\\{|\\}|\\||\\\\|\\^|\\[|\\]|\\`|\\]/) {|c| \"%#{c[0].to_s.upcase}\"}\n  end    \n  # load all the custom aliases\n  require 'gchart/aliases'\n\n  # Returns the chart's generated PNG as a blob. (borrowed from John's gchart.rubyforge.org)\n  def fetch\n    url = URI.parse(self.class.url(use_ssl))\n    req = Net::HTTP::Post.new(url.path)\n    req.body = query_builder\n    req.content_type = 'application/x-www-form-urlencoded'\n    http = Net::HTTP.new(url.host, url.port)\n    http.verify_mode = OpenSSL::SSL::VERIFY_PEER if use_ssl\n    http.use_ssl = use_ssl\n    http.start {|resp| resp.request(req) }.body\n  end\n\n  # Writes the chart's generated PNG to a file. (borrowed from John's gchart.rubyforge.org)\n  def write\n    io_or_file = filename || self.class.default_filename\n    return io_or_file.write(fetch) if io_or_file.respond_to?(:write)\n    open(io_or_file, \"wb+\") { |io| io.write(fetch) }\n  end\n\n  # Format\n\n  def image_tag\n    image = \"<img\"\n    image += \" id=\\\"#{id}\\\"\" if id  \n    image += \" class=\\\"#{klass}\\\"\" if klass      \n    image += \" src=\\\"#{url_builder(:html)}\\\"\"\n    image += \" width=\\\"#{width}\\\"\"\n    image += \" height=\\\"#{height}\\\"\"\n    image += \" alt=\\\"#{alt}\\\"\"\n    image += \" title=\\\"#{title}\\\"\" if title\n    image += \" usemap=\\\"#{usemap}\\\"\" if usemap\n    image += \" />\"\n  end\n\n  alias_method :img_tag, :image_tag\n\n  def url\n    url_builder\n  end\n\n  def file\n    write\n  end\n\n  #\n  def jstize(string)\n    self.class.jstize(string)\n  end\n\n  private\n\n  # The title size cannot be set without specifying a color.\n  # A dark key will be used for the title color if no color is specified \n  def set_title\n    title_params = \"chtt=#{title}\".gsub(/\\|/,\"\\n\")\n    unless (title_color.nil? && title_size.nil? && title_alignment.nil?)\n      title_params << \"&chts=\" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',')\n    end\n    title_params\n  end\n\n  def set_size\n    \"chs=#{size}\"\n  end\n\n  def set_data\n    data = send(\"#{@encoding}_encoding\")\n    \"chd=#{data}\"\n  end\n\n  def set_colors\n    @bg_type = fill_type(bg_type) || 's' if bg_color\n    @chart_type = fill_type(chart_type) || 's' if chart_color\n\n    \"chf=\" + {'bg' => fill_for(bg_type, bg_color, bg_angle), 'c' => fill_for(chart_type, chart_color, chart_angle)}.map{|k,v| \"#{k},#{v}\" unless v.nil?}.compact.join('|')      \n  end\n\n  # set bar, line colors\n  def set_bar_colors\n    @bar_colors = bar_colors.join(',') if bar_colors.is_a?(Array)\n    \"chco=#{bar_colors}\"\n  end\n\n  def set_country_codes\n    @country_codes = country_codes.join() if country_codes.is_a?(Array)\n    \"chld=#{country_codes}\"\n  end\n\n  # set bar spacing\n  # chbh=\n  # <bar width in pixels>,\n  # <optional space between bars in a group>,\n  # <optional space between groups>\n  def set_bar_width_and_spacing\n    width_and_spacing_values = case bar_width_and_spacing\n    when String\n      bar_width_and_spacing\n    when Array\n      bar_width_and_spacing.join(',')\n    when Hash\n      width         = bar_width_and_spacing[:width] || 23\n      spacing       = bar_width_and_spacing[:spacing] || 4\n      group_spacing = bar_width_and_spacing[:group_spacing] || 8\n      [width,spacing,group_spacing].join(',')\n    else\n      bar_width_and_spacing.to_s\n    end\n    \"chbh=#{width_and_spacing_values}\"\n  end\n\n  def set_range_markers\n    markers = case range_markers\n    when Hash\n      set_range_marker(range_markers)\n    when Array\n      range_markers.collect{|marker| set_range_marker(marker)}.join('|')\n    end\n    \"chm=#{markers}\"\n  end\n\n  def set_range_marker(options)\n    orientation = ['vertical', 'Vertical', 'V', 'v', 'R'].include?(options[:orientation]) ? 'R' : 'r'\n    \"#{orientation},#{options[:color]},0,#{options[:start_position]},#{options[:stop_position]}#{',1' if options[:overlaid?]}\"  \n  end\n\n  def fill_for(type=nil, color='', angle=nil)\n    unless type.nil? \n      case type\n      when 'lg'\n        angle ||= 0\n        color = \"#{color},0,ffffff,1\" if color.split(',').size == 1\n        \"#{type},#{angle},#{color}\"\n      when 'ls'\n        angle ||= 90\n        color = \"#{color},0.2,ffffff,0.2\" if color.split(',').size == 1\n        \"#{type},#{angle},#{color}\"\n      else\n        \"#{type},#{color}\"\n      end\n    end\n  end\n\n  # A chart can have one or many legends. \n  # Gchart.line(:legend => 'label')\n  # or\n  # Gchart.line(:legend => ['first label', 'last label'])\n  def set_legend\n    if type.to_s =~ /meter/\n      @labels = legend\n      return set_labels\n    end\n    if legend.is_a?(Array)\n      \"chdl=#{@legend.map{|label| \"#{CGI::escape(label.to_s)}\"}.join('|')}\"\n    else\n      \"chdl=#{legend}\"\n    end\n\n  end\n\n  def set_legend_position\n    case @legend_position.to_s\n    when /(bottom|b)$/\n      \"chdlp=b\"\n    when /(bottom_vertical|bv)$/\n      \"chdlp=bv\"\n    when /(top|t)$/\n      \"chdlp=t\"\n    when /(top_vertical|tv)$/\n      \"chdlp=tv\"\n    when /(right|r)$/\n      \"chdlp=r\"\n    when /(left|l)$/\n      \"chdlp=l\"\n    end\n  end\n\n  def set_line_thickness\n    \"chls=#{thickness}\"\n  end\n\n  def set_line_markers\n    \"chm=#{new_markers}\"\n  end\n\n  def set_grid_lines\n    \"chg=#{grid_lines}\"\n  end\n\n  def set_labels\n    if labels.is_a?(Array)\n      \"chl=#{@labels.map{|label| \"#{CGI::escape(label.to_s)}\"}.join('|')}\"\n    else\n      \"chl=#{@labels}\"\n    end\n  end\n\n  def set_axis_with_labels\n    @axis_with_labels = axis_with_labels.join(',') if @axis_with_labels.is_a?(Array)\n    \"chxt=#{axis_with_labels}\"\n  end\n\n  def set_custom_axis_with_labels\n    @custom_axis_with_labels = custom_axis_with_labels.join(',') if @custom_axis_with_labels.is_a?(Array)\n    \"chxp=#{custom_axis_with_labels}\"\n  end\n\n  def set_axis_labels\n    if axis_labels.is_a?(Array)\n      if RUBY_VERSION.to_f < 1.9\n        labels_arr = axis_labels.enum_with_index.map{|labels,index| [index,labels]}\n      else\n        labels_arr = axis_labels.map.with_index.map{|labels,index| [index,labels]}\n      end\n    elsif axis_labels.is_a?(Hash)\n      labels_arr = axis_labels.to_a\n    end\n    labels_arr.map! do |index,labels|\n      if labels.is_a?(Array)\n        \"#{index}:|#{labels.map{|label| \"#{CGI::escape(label.to_s)}\"}.join('|')}\"\n      else\n        \"#{index}:|#{labels}\"\n      end\n    end\n    \"chxl=#{labels_arr.join('|')}\"\n  end\n\n  # http://code.google.com/apis/chart/labels.html#axis_range\n  # Specify a range for axis labels\n  def set_axis_range\n    # a passed axis_range should look like:\n    # [[10,100]] or [[10,100,4]] or [[10,100], [20,300]]\n    # in the second example, 4 is the interval \n    set = @calculated_axis_range ? datasets : axis_range || datasets\n\n    return unless set && set.respond_to?(:each) && set.find {|o| o}.respond_to?(:each)\n\n    'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index|\n      next nil if axis_range.nil? # ignore this axis\n      min, max, step = axis_range\n      if axis_range.size > 3 || step && max && step > max # this is a full series\n        max = axis_range.compact.max\n        step = nil\n      end\n      [index, (min_value || min || 0), (max_value || max), step].compact.join(',')\n    end.compact.join(\"|\")\n  end\n\n  def set_geographical_area\n    \"chtm=#{geographical_area}\"\n  end\n\n  def set_type\n    'cht=' + case type.to_s\n    when 'line'      then \"lc\"\n    when 'line_xy'   then \"lxy\"\n    when 'pie_3d'    then \"p3\"\n    when 'pie_c'     then \"pc\"\n    when 'pie'       then \"p\"\n    when 'venn'      then \"v\"\n    when 'scatter'   then \"s\"\n    when 'sparkline' then \"ls\"\n    when 'meter'     then \"gom\"\n    when 'map'       then \"t\"\n    when 'radar'\n      \"r\" + (curved? ? 's' : '')\n    when 'bar'\n      \"b\" + (horizontal? ? \"h\" : \"v\") + bar_presentation\n    end\n  end\n\n  def fill_type(type)\n    case type\n    when 'solid'    then 's'\n    when 'gradient' then 'lg'\n    when 'stripes'  then 'ls'\n    end\n  end\n\n  def number_visible\n    n = 0\n    dataset.each do |mds|\n      return n.to_s if mds[:invisible] == true\n      if mds[:data].first.is_a?(Array)\n        n += mds[:data].length\n      else\n        n += 1\n      end\n    end\n    \"\"\n  end\n\n  # Turns input into an array of axis hashes, dependent on the chart type\n  def convert_dataset(ds)\n    if dimensions == 2\n      # valid inputs include:\n      # an array of >=2 arrays, or an array of >=2 hashes\n      ds = ds.map do |d|\n        d.is_a?(Hash) ? d : {:data => d}\n      end\n    elsif dimensions == 1\n      # valid inputs include:\n      # a hash, an array of data, an array of >=1 array, or an array of >=1 hash\n      if ds.is_a?(Hash)\n        ds = [ds]\n      elsif not ds.first.is_a?(Hash)\n        ds = [{:data => ds}]\n      end\n    end\n    ds\n  end\n\n  # just an alias\n  def axis_set\n    dataset\n  end\n\n  def convert_to_simple_value(number)\n    if number.nil?\n      \"_\"\n    else\n      value = self.class.simple_chars[number.to_i]\n      value.nil? ? \"_\" : value\n    end\n  end\n\n  def convert_to_extended_value(number)\n    if number.nil?\n      '__'\n    else\n      value = self.class.ext_pairs[number.to_i]\n      value.nil? ? \"__\" : value\n    end\n  end\n\n  def encode_scaled_dataset(chars, nil_char)\n    dsets = []\n    dataset.each do |ds|\n      if max_value != false\n        range = ds[:max_value] - ds[:min_value]\n        range = 1 if range == 0\n      end\n      unless ds[:data].first.is_a?(Array)\n        ldatasets = [ds[:data]]\n      else\n        ldatasets = ds[:data]\n      end\n      ldatasets.each do |l|\n        dsets << l.map do |number|\n          if number.nil?\n            nil_char\n          else\n            unless range.nil? || range.zero?\n              number = chars.size * (number - ds[:min_value]) / range.to_f\n              number = [number, chars.size - 1].min\n            end\n            chars[number.to_i]\n          end\n        end.join\n      end\n    end\n    dsets.join(',')\n  end\n\n  # http://code.google.com/apis/chart/#simple\n  # Simple encoding has a resolution of 62 different values. \n  # Allowing five pixels per data point, this is sufficient for line and bar charts up\n  # to about 300 pixels. Simple encoding is suitable for all other types of chart regardless of size.\n  def simple_encoding\n    \"s\" + number_visible + \":\" + encode_scaled_dataset(self.class.simple_chars, '_')\n  end\n\n  # http://code.google.com/apis/chart/#text\n  # Text encoding with data scaling lets you specify arbitrary positive or\n  # negative floating point numbers, in combination with a scaling parameter\n  # that lets you specify a custom range for your chart. This chart is useful\n  # when you don't want to worry about limiting your data to a specific range,\n  # or do the calculations to scale your data down or up to fit nicely inside\n  # a chart.\n  #\n  # Valid values range from (+/-)9.999e(+/-)100, and only four non-zero digits are supported (that is, 123400, 1234, 12.34, and 0.1234 are valid, but 12345, 123.45 and 123400.5 are not).\n  #\n  # This encoding is not available for maps.\n  #\n  def text_encoding\n    chds = dataset.map{|ds| \"#{ds[:min_value]},#{ds[:max_value]}\" }.join(\",\")\n    \"t\" + number_visible + \":\" + datasets.map{ |ds| ds.map{|e|e||'_'}.join(',') }.join('|') + \"&chds=\" + chds\n  end\n\n  # http://code.google.com/apis/chart/#extended\n  # Extended encoding has a resolution of 4,096 different values \n  # and is best used for large charts where a large data range is required.\n  def extended_encoding\n    \"e\" + number_visible + \":\" + encode_scaled_dataset(self.class.ext_pairs, '__')\n  end\n\n  def url_builder(options=\"\")\n    self.class.url(use_ssl) + query_builder(options)\n  end\n\n  def query_builder(options=\"\")\n    query_params = instance_variables.sort.map do |var|\n      case var.to_s\n\n      when '@data'\n        set_data unless data == []  \n        # Set the graph size  \n      when '@width'\n        set_size unless width.nil? || height.nil?\n      when '@type'\n        set_type\n      when '@title'\n        set_title unless title.nil?\n      when '@legend'\n        set_legend unless legend.nil?\n      when '@labels'\n        set_labels unless labels.nil?\n      when '@legend_position'\n        set_legend_position unless legend_position.nil?\n      when '@thickness'\n        set_line_thickness\n      when '@new_markers'\n        set_line_markers\n      when '@bg_color'\n        set_colors\n      when '@chart_color'\n        set_colors if bg_color.nil?\n      when '@bar_colors'\n        set_bar_colors\n      when '@bar_width_and_spacing'\n        set_bar_width_and_spacing\n      when '@axis_with_labels'\n        set_axis_with_labels\n      when '@axis_labels'\n        set_axis_labels\n      when '@range_markers'\n        set_range_markers\n      when '@grid_lines'\n        set_grid_lines\n      when '@custom_axis_with_labels'\n        set_custom_axis_with_labels\n      when '@geographical_area'\n        set_geographical_area\n      when '@country_codes'\n        set_country_codes\n      when '@custom'\n        custom\n      end\n    end.compact\n\n    query_params << set_axis_range\n\n    # Use ampersand as default delimiter\n    unless options == :html\n      delimiter = '&'\n      # Escape ampersand for html image tags\n    else\n      delimiter = '&amp;'\n    end\n\n    jstize(query_params.join(delimiter))\n  end\n\nend\n"
  },
  {
    "path": "lib/googlecharts.rb",
    "content": "require 'gchart'\nGooglecharts = Gchart unless Object.const_defined? 'Googlechart'"
  },
  {
    "path": "lib/themes.yml",
    "content": "#Default themes ganked from Gruff: http://github.com/topfunky/gruff/tree/master\n:keynote:\n  :colors:\n    - &blue 6886B4\n    - &yellow FDD84E\n    - &green 72AE6E\n    - &red D1695E\n    - &purple 8A6EAF\n    - &orange EFAA43\n    - &white FFFFFF\n    - &black !str 000000\n  :bar_colors: [ *blue, *yellow, *green, *red, *purple, *orange ]\n  :background: *black\n  :chart_background: *white\n:thirty7signals:\n  :colors:\n    - &green 339933\n    - &purple cc99cc\n    - &blue 336699\n    - &yellow FFF804\n    - &red ff0000\n    - &orange cf5910\n  :bar_colors: [ *yellow, *blue, *green, *red, *purple, *orange ]\n  :background: *white\n:pastel:\n  :colors:\n    - &blue a9dada\n    - &green aedaa9\n    - &peach daaea9\n    - &yellow dadaa9\n    - &dk_purple a9a9da\n    - &purple daaeda\n    - &grey dadada\n  :bar_colors: [ *blue, *green, *peach, *yellow, *dk_purple ]\n  :background_color: *white\n:greyscale:\n  :bar_colors: [\n            282828,  \n            383838,  \n            686868,  \n            989898,  \n            c8c8c8,  \n            e8e8e8\n            ]\n  :background_color: *white"
  },
  {
    "path": "spec/fixtures/another_test_theme.yml",
    "content": ":test_two:\n  :colors:\n    - &blue 6886B4\n    - &yellow FDD84E\n    - &grey 333333\n  :bar_colors: [ *blue, *yellow ]\n  :background: *grey\n  :chart_background: *grey\n"
  },
  {
    "path": "spec/fixtures/test_theme.yml",
    "content": ":test:\n  :colors:\n    - &blue 6886B4\n    - &yellow FDD84E\n    - &white FFFFFF\n  :bar_colors: [ *blue, *yellow ]\n  :background: *white\n  :chart_background: *white"
  },
  {
    "path": "spec/gchart_spec.rb",
    "content": "require File.dirname(__FILE__) + '/spec_helper.rb'\nrequire File.dirname(__FILE__) + '/../lib/gchart'\n\nChart::Theme.add_theme_file(\"#{File.dirname(__FILE__)}/fixtures/test_theme.yml\")\n\n# Time to add your specs!\n# http://rspec.rubyforge.org/\ndescribe \"The Gchart class\" do\n  it \"should show supported_types on error\" do\n    expect(Gchart.supported_types).to match(/line/)\n  end\n\n  it \"should return supported types\" do\n    expect(Gchart.types).to include('line')\n  end\n\n  it \"should support theme option\" do\n    chart = Gchart.new(:type => 'line',:theme => :test)\n    expect(chart.send('url')).to include('chco=6886B4,FDD84E')\n  end\nend\n\ndescribe \"generating a default Gchart\" do\n\n  before(:each) do\n    @chart = Gchart.line\n  end\n\n  it \"should create a line break when a pipe character is encountered\" do\n    @chart = Gchart.line(:title => \"title|subtitle\")\t\n    expect(@chart).to include(\"chtt=title\\nsubtitle\")\n  end\n\n  it \"should include the Google URL\" do\n    expect(@chart).to include(\"http://chart.apis.google.com/chart?\")\n  end\n\n  it \"should have a default size\" do\n    expect(@chart).to include('chs=300x200')\n  end\n\n  it \"should be able to have a custom size\" do\n    expect(Gchart.line(:size => '400x600')).to include('chs=400x600')\n    expect(Gchart.line(:width => 400, :height => 600)).to include('chs=400x600')\n  end\n\n  it \"should have query parameters in predictable order\" do\n    expect(Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600')).to match(/chxt=.+cht=.+chs=/)\n  end\n\n  it \"should have a type\" do\n    expect(@chart).to include('cht=lc')\n  end\n\n  it 'should use theme defaults if theme is set' do\n    expect(Gchart.line(:theme=>:test)).to include('chco=6886B4,FDD84E')\n    expect(Gchart.line(:theme=>:test)).to match(/chf=(c,s,FFFFFF\\|bg,s,FFFFFF|bg,s,FFFFFF\\|c,s,FFFFFF)/)\n  end\n\n  it \"should use the simple encoding by default with auto max value\" do\n    # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9\n    expect(Gchart.line(:data => [0, 26])).to include('chd=s:A9')\n    expect(Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y')).to include('chxr=0,0,26')\n  end\n\n  it \"should support simple encoding with and without max_value\" do\n    expect(Gchart.line(:data => [0, 26], :max_value => 26)).to include('chd=s:A9')\n    expect(Gchart.line(:data => [0, 26], :max_value => false)).to include('chd=s:Aa')\n  end\n\n  it \"should support the extended encoding and encode properly\" do\n    expect(Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false)).to include('chd=e:AA')\n    expect(Gchart.line(:encoding => 'extended',\n                :max_value => false,\n                :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]]\n                )).to include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0')\n  end\n\n  it \"should auto set the max value for extended encoding\" do\n    expect(Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false)).to include('chd=e:AAAZ')\n    # Extended encoding max value is '..'\n    expect(Gchart.line(:data => [0, 25], :encoding => 'extended')).to include('chd=e:AA..')\n  end\n\n  it \"should be able to have data with text encoding\" do\n    expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,4,45,78')\n  end\n\n  it \"should be able to have missing data points with text encoding\" do\n    expect(Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,_,45,78')\n  end\n\n  it \"should handle max and min values with text encoding\" do\n    expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=0,78')\n  end\n\n  it \"should automatically handle negative values with proper max/min limits when using text encoding\" do\n    expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=-10,78')\n  end\n\n  it \"should handle negative values with manual max/min limits when using text encoding\" do\n   expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100)).to include('chds=-20,100')\n  end\n\n  it \"should set the proper axis values when using text encoding and negative values\" do\n    expect(Gchart.bar( :data       => [[-10], [100]],\n                :encoding   => 'text',\n                :horizontal => true,\n                :min_value  => -20,\n                :max_value  => 100,\n                :axis_with_labels => 'x',\n                :bar_colors => ['FD9A3B', '4BC7DC'])).to include(\"chxr=0,-20,100\")\n  end\n\n  it \"should be able to have multiple set of data with text encoding\" do\n    expect(Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text')).to include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99'))\n  end\n\n  it \"should be able to receive a custom param\" do\n    expect(Gchart.line(:custom => 'ceci_est_une_pipe')).to include('ceci_est_une_pipe')\n  end\n\n  it \"should be able to set label axis\" do\n    expect(Gchart.line(:axis_with_labels => 'x,y,r')).to include('chxt=x,y,r')\n    expect(Gchart.line(:axis_with_labels => ['x','y','r'])).to include('chxt=x,y,r')\n  end\n\n  it \"should be able to have axis labels\" do\n   expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007'))\n   expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan'))\n   expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan'))\n   expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007'))\n  end\n\n  def labeled_line(options = {})\n    Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options))\n  end\n\n  it \"should display ranges properly\" do\n    @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593]\n    expect(labeled_line(:axis_labels => [((1..24).to_a << 1)])).\n      to include('chxr=0,85,672')\n  end\n\n  def labeled_bar(options = {})\n    Gchart.bar({:data => @data,\n            :axis_with_labels => 'x,y',\n            :axis_labels => [(1..12).to_a],\n            :encoding => \"text\"\n    }.merge(options))\n  end\n\n  it \"should force the y range properly\" do\n    @data = [1,1,1,1,1,1,1,1,6,2,1,1]\n    expect(labeled_bar(\n      :axis_range => [[0,0],[0,16]]\n    )).to include('chxr=0,0,0|1,0,16')\n    expect(labeled_bar(\n      :max_value => 16,\n      :axis_range => [[0,0],[0,16]]\n    )).to include('chxr=0,0,16|1,0,16')\n\n    # nil means ignore axis\n    expect(labeled_bar(\n      :axis_range => [nil,[0,16]]\n    )).to include('chxr=1,0,16')\n\n    # empty array means take defaults\n    expect(labeled_bar(\n      :max_value => 16,\n      :axis_range => [[],[0,16]]\n    )).to include('chxr=0,0,16|1,0,16')\n    expect(labeled_bar(\n      :axis_range => [[],[0,16]]\n    )).to include('chxr=0,0|1,0,16')\n\n    expect(Gchart.line(\n            :data => [0,20, 40, 60, 140, 230, 60],\n            :axis_with_labels => 'y')).to include(\"chxr=0,0,230\")\n  end\n\n  it \"should take in consideration the max value when creating a range\" do\n    data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593]\n    url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700)\n    expect(url).to include('chxr=0,85,700')\n  end\n\n  it 'should generate different labels and legend' do\n    expect(Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three))).to(include('chdl=1|2|3') && include('chl=one|two|three'))\n  end\nend\n\ndescribe \"generating different type of charts\" do\n\n  it \"should be able to generate a line chart\" do\n    expect(Gchart.line).to be_an_instance_of(String)\n    expect(Gchart.line).to include('cht=lc')\n  end\n\n  it \"should be able to generate a sparkline chart\" do\n    expect(Gchart.sparkline).to be_an_instance_of(String)\n    expect(Gchart.sparkline).to include('cht=ls')\n  end\n\n  it \"should be able to generate a line xy chart\" do\n    expect(Gchart.line_xy).to be_an_instance_of(String)\n    expect(Gchart.line_xy).to include('cht=lxy')\n  end\n\n  it \"should be able to generate a scatter chart\" do\n    expect(Gchart.scatter).to be_an_instance_of(String)\n    expect(Gchart.scatter).to include('cht=s')\n  end\n\n  it \"should be able to generate a bar chart\" do\n    expect(Gchart.bar).to be_an_instance_of(String)\n    expect(Gchart.bar).to include('cht=bvs')\n  end\n\n  it \"should be able to generate a Venn diagram\" do\n    expect(Gchart.venn).to be_an_instance_of(String)\n    expect(Gchart.venn).to include('cht=v')\n  end\n\n  it \"should be able to generate a Pie Chart\" do\n    expect(Gchart.pie).to be_an_instance_of(String)\n    expect(Gchart.pie).to include('cht=p')\n  end\n\n  it \"should be able to generate a Concentric Pie Chart\" do\n    expect(Gchart.pie_c).to be_an_instance_of(String)\n    expect(Gchart.pie_c).to include('cht=pc')\n    expect(Gchart.pie_c(size: '240x240', data: [[-1], [2,3]])).to include('-1|1,2,3')\n  end\n\n  it \"should be able to generate a Google-O-Meter\" do\n    expect(Gchart.meter).to be_an_instance_of(String)\n    expect(Gchart.meter).to include('cht=gom')\n  end\n\n  it \"should be able to generate a map chart\" do\n    expect(Gchart.map).to be_an_instance_of(String)\n    expect(Gchart.map).to include('cht=t')\n  end\n\n  it \"should not support other types\" do\n    msg = \"sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}.\"\n    expect{Gchart.sexy}.to raise_error(NoMethodError)\n  end\nend\n\n\ndescribe \"range markers\" do\n\n  it \"should be able to generate given a hash of range-marker options\" do\n    expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'})).to include('chm=r,ff0000,0,0.59,0.61')\n  end\n\n  it \"should be able to generate given an array of range-marker hash options\" do\n    expect(Gchart.line(:range_markers => [\n          {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'},\n          {:start_position => 0, :stop_position => 0.6, :color => '666666'},\n          {:color => 'cccccc', :start_position => 0.6, :stop_position => 1}\n        ])).to include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1'))\n  end\n\n  it \"should allow a :overlaid? to be set\" do\n    expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true})).to include('chm=r,ffffff,0,0.59,0.61,1')\n    expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false})).to include('chm=r,ffffff,0,0.59,0.61')\n  end\n\n  describe \"when setting the orientation option\" do\n    before(:each) do\n      @options = {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}\n    end\n\n    it \"to vertical (R) if given a valid option\" do\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'v'))).to include('chm=R')\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'V'))).to include('chm=R')\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'R'))).to include('chm=R')\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'vertical'))).to include('chm=R')\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical'))).to include('chm=R')\n    end\n\n    it \"to horizontal (r) if given a valid option (actually anything other than the vertical options)\" do\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal'))).to include('chm=r')\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'h'))).to include('chm=r')\n      expect(Gchart.line(:range_markers => @options.merge(:orientation => 'etc'))).to include('chm=r')\n    end\n\n    it \"if left blank defaults to horizontal (r)\" do\n      expect(Gchart.line(:range_markers => @options)).to include('chm=r')\n    end\n  end\nend\n\n\ndescribe \"a bar graph\" do\n\n  it \"should have a default vertical orientation\" do\n    expect(Gchart.bar).to include('cht=bvs')\n  end\n\n  it \"should be able to have a different orientation\" do\n    expect(Gchart.bar(:orientation => 'vertical')).to include('cht=bvs')\n    expect(Gchart.bar(:orientation => 'v')).to include('cht=bvs')\n    expect(Gchart.bar(:orientation => 'h')).to include('cht=bhs')\n    expect(Gchart.bar(:orientation => 'horizontal')).to include('cht=bhs')\n    expect(Gchart.bar(:horizontal => false)).to include('cht=bvs')\n  end\n\n  it \"should be set to be stacked by default\" do\n    expect(Gchart.bar).to include('cht=bvs')\n  end\n\n  it \"should be able to stacked, grouped or overlapped\" do\n    expect(Gchart.bar(:stacked => true)).to include('cht=bvs')\n    expect(Gchart.bar(:stacked => false)).to include('cht=bvs')\n    expect(Gchart.bar(:grouped => true)).to include('cht=bvg')\n    expect(Gchart.bar(:grouped => false)).to include('cht=bvs')\n    expect(Gchart.bar(:overlapped => true)).to include('cht=bvo')\n    expect(Gchart.bar(:overlapped => false)).to include('cht=bvs')\n  end\n\n  it \"should be able to have different bar colors\" do\n    expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=')\n    expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=efefef,00ffff')\n    # alias\n    expect(Gchart.bar(:bar_color => 'efefef')).to include('chco=efefef')\n  end\n\n  it \"should be able to have different bar colors when using an array of colors\" do\n    expect(Gchart.bar(:bar_colors => ['efefef','00ffff'])).to include('chco=efefef,00ffff')\n  end\n\n  it 'should be able to accept a string of width and spacing options' do\n    expect(Gchart.bar(:bar_width_and_spacing => '25,6')).to include('chbh=25,6')\n  end\n\n  it 'should be able to accept a single fixnum width and spacing option to set the bar width' do\n    expect(Gchart.bar(:bar_width_and_spacing => 25)).to include('chbh=25')\n  end\n\n  it 'should be able to accept an array of width and spacing options' do\n    expect(Gchart.bar(:bar_width_and_spacing => [25,6,12])).to include('chbh=25,6,12')\n    expect(Gchart.bar(:bar_width_and_spacing => [25,6])).to include('chbh=25,6')\n    expect(Gchart.bar(:bar_width_and_spacing => [25])).to include('chbh=25')\n  end\n\n  describe \"with a hash of width and spacing options\" do\n\n    before(:each) do\n      @default_width         = 23\n      @default_spacing       = 4\n      @default_group_spacing = 8\n    end\n\n    it 'should be able to have a custom bar width' do\n      expect(Gchart.bar(:bar_width_and_spacing => {:width => 19})).to include(\"chbh=19,#{@default_spacing},#{@default_group_spacing}\")\n    end\n\n    it 'should be able to have custom spacing' do\n      expect(Gchart.bar(:bar_width_and_spacing => {:spacing => 19})).to include(\"chbh=#{@default_width},19,#{@default_group_spacing}\")\n    end\n\n    it 'should be able to have custom group spacing' do\n      expect(Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19})).to include(\"chbh=#{@default_width},#{@default_spacing},19\")\n    end\n  end\nend\n\ndescribe \"a radar chart\" do\n\n  before(:each) do\n    @chart = Gchart.radar(:title => 'Chart Title')\n  end\n\n  it \"should be able have a chart title\" do\n    expect(@chart).to include(\"chtt=Chart+Title\")\n  end\n\n  it \"should allow axis labels positions to be used\" do\n    expect(Gchart.radar(:custom_axis_with_labels => '0,0,50,100')).to include('chxp=0,0,50,100')\n  end\n  \n  it \"should allow array of axis labels positions to be used \" do\n    expect(Gchart.radar(:custom_axis_with_labels => ['0', '0', '50', '100'])).to include('chxp=0,0,50,100')\n  end\nend\n\ndescribe \"a line chart\" do\n\n  before(:each) do\n    @title = 'Chart Title'\n    @legend = ['first data set label', 'n data set label']\n    @chart = Gchart.line(:title => @title, :legend => @legend)\n  end\n\n  it 'should be able have a chart title' do\n    expect(@chart).to include(\"chtt=Chart+Title\")\n  end\n\n  it \"should be able to a custom color, size and alignment for title\" do\n     expect(Gchart.line(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000')\n     expect(Gchart.line(:title => @title, :title_size => '20')).to include('chts=454545,20')\n     expect(Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left)).to include('chts=454545,20,l')\n  end\n\n  it \"should be able to have multiple legends\" do\n    expect(@chart).to include(Gchart.jstize(\"chdl=first+data+set+label|n+data+set+label\"))\n  end\n\n  it \"should escape text values in url\" do\n    title = 'Chart & Title'\n    legend = ['first data & set label', 'n data set label']\n    chart = Gchart.line(:title => title, :legend => legend)\n    expect(chart).to include(Gchart.jstize(\"chdl=first+data+%26+set+label|n+data+set+label\"))\n  end\n\n  it \"should be able to have one legend\" do\n    chart = Gchart.line(:legend => 'legend label')\n    expect(chart).to include(\"chdl=legend+label\")\n  end\n\n  it \"should be able to set the position of the legend\" do\n    title = 'Chart & Title'\n    legend = ['first data & set label', 'n data set label']\n\n    chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical)\n    expect(chart).to include(\"chdlp=bv\")\n\n    chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r')\n    expect(chart).to include(\"chdlp=r\")\n  end\n\n  it \"should be able to set the background fill\" do\n    expect(Gchart.line(:bg => 'efefef')).to include(\"chf=bg,s,efefef\")\n    expect(Gchart.line(:bg => {:color => 'efefef', :type => 'solid'})).to include(\"chf=bg,s,efefef\")\n\n    expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})).to include(\"chf=bg,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include(\"chf=bg,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include(\"chf=bg,lg,90,efefef,0,ffffff,1\")\n\n    expect(Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})).to include(\"chf=bg,ls,90,efefef,0.2,ffffff,0.2\")\n  end\n\n  it \"should be able to set a graph fill\" do\n    expect(Gchart.line(:graph_bg => 'efefef')).to include(\"chf=c,s,efefef\")\n    expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include(\"chf=c,s,efefef\")\n    expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include(\"chf=c,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include(\"chf=c,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include(\"chf=c,lg,90,efefef,0,ffffff,1\")\n  end\n\n  it \"should be able to set both a graph and a background fill\" do\n    expect(Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB')).to match /chf=(bg,s,efefef\\|c,s,76A4FB|c,s,76A4FB\\|bg,s,efefef)/\n  end\n\n  it \"should be able to have different line colors\" do\n    expect(Gchart.line(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))\n    expect(Gchart.line(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))\n  end\n\n  it \"should be able to render a graph where all the data values are 0\" do\n    expect(Gchart.line(:data => [0, 0, 0])).to include(\"chd=s:AAA\")\n  end\nend\n\ndescribe \"a sparkline chart\" do\n\n  before(:each) do\n    @title = 'Chart Title'\n    @legend = ['first data set label', 'n data set label']\n    @jstized_legend = Gchart.jstize(@legend.join('|'))\n    @data = [27,25,25,25,25,27,100,31,25,36,25,25,39,25,31,25,25,25,26,26,25,25,28,25,25,100,28,27,31,25,27,27,29,25,27,26,26,25,26,26,35,33,34,25,26,25,36,25,26,37,33,33,37,37,39,25,25,25,25]\n    @chart = Gchart.sparkline(:title => @title, :data => @data, :legend => @legend)\n  end\n\n  it \"should create a sparkline\" do\n    expect(@chart).to include('cht=ls')\n  end\n\n  it 'should be able have a chart title' do\n    expect(@chart).to include(\"chtt=Chart+Title\")\n  end\n\n  it \"should be able to a custom color and size title\" do\n     expect(Gchart.sparkline(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000')\n     expect(Gchart.sparkline(:title => @title, :title_size => '20')).to include('chts=454545,20')\n  end\n\n  it \"should be able to have multiple legends\" do\n    expect(@chart).to include(Gchart.jstize(\"chdl=first+data+set+label|n+data+set+label\"))\n  end\n\n  it \"should be able to have one legend\" do\n    chart = Gchart.sparkline(:legend => 'legend label')\n    expect(chart).to include(\"chdl=legend+label\")\n  end\n\n  it \"should be able to set the background fill\" do\n    expect(Gchart.sparkline(:bg => 'efefef')).to include(\"chf=bg,s,efefef\")\n    expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'})).to include(\"chf=bg,s,efefef\")\n\n    expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'})).to include(\"chf=bg,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include(\"chf=bg,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include(\"chf=bg,lg,90,efefef,0,ffffff,1\")\n\n    expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'})).to include(\"chf=bg,ls,90,efefef,0.2,ffffff,0.2\")\n  end\n\n  it \"should be able to set a graph fill\" do\n    expect(Gchart.sparkline(:graph_bg => 'efefef')).to include(\"chf=c,s,efefef\")\n    expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include(\"chf=c,s,efefef\")\n    expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include(\"chf=c,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include(\"chf=c,lg,0,efefef,0,ffffff,1\")\n    expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include(\"chf=c,lg,90,efefef,0,ffffff,1\")\n  end\n\n  it \"should be able to set both a graph and a background fill\" do\n    expect(Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB')).to match(/chf=(bg,s,efefef\\|c,s,76A4FB|c,s,76A4FB\\|bg,s,efefef)/)\n  end\n\n  it \"should be able to have different line colors\" do\n    expect(Gchart.sparkline(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))\n    expect(Gchart.sparkline(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))\n  end\nend\n\ndescribe \"a 3d pie chart\" do\n\n  before(:each) do\n    @title = 'Chart Title'\n    @legend = ['first data set label', 'n data set label']\n    @jstized_legend = Gchart.jstize(@legend.join('|'))\n    @data = [12,8,40,15,5]\n    @chart = Gchart.pie(:title => @title, :legend => @legend, :data => @data)\n  end\n\n  it \"should create a pie\" do\n    expect(@chart).to include('cht=p')\n  end\n\n  it \"should be able to be in 3d\" do\n    expect(Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)).to include('cht=p3')\n  end\nend\n\ndescribe \"a google-o-meter\" do\n\n  before(:each) do\n    @data = [70]\n    @legend = ['arrow points here']\n    @jstized_legend = Gchart.jstize(@legend.join('|'))\n    @chart = Gchart.meter(:data => @data)\n  end\n\n  it \"should create a meter\" do\n    expect(@chart).to include('cht=gom')\n  end\n\n  it \"should be able to set a solid background fill\" do\n    expect(Gchart.meter(:bg => 'efefef')).to include(\"chf=bg,s,efefef\")\n    expect(Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'})).to include(\"chf=bg,s,efefef\")\n  end\n\n  it \"should be able to set labels by using the legend or labesl accessor\" do\n    expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to include(\"chl=#{@jstized_legend}\")\n    expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to eq(Gchart.meter(:title => @title, :legend => @legend, :data => @data))\n  end\nend\n\ndescribe \"a map chart\" do\n\n  before(:each) do\n    @data = [0,100,50,32]\n    @geographical_area = 'usa'\n    @map_colors = ['FFFFFF', 'FF0000', 'FFFF00', '00FF00']\n    @country_codes = ['MT', 'WY', \"ID\", 'SD']\n    @chart = Gchart.map(:data => @data, :encoding => 'text', :size => '400x300',\n      :geographical_area => @geographical_area, :map_colors => @map_colors,\n      :country_codes => @country_codes)\n  end\n\n  it \"should create a map\" do\n    expect(@chart).to include('cht=t')\n  end\n\n  it \"should set the geographical area\" do\n    expect(@chart).to include('chtm=usa')\n  end\n\n  it \"should set the map colors\" do\n    expect(@chart).to include('chco=FFFFFF,FF0000,FFFF00,00FF00')\n  end\n\n  it \"should set the country/state codes\" do\n    expect(@chart).to include('chld=MTWYIDSD')\n  end\n\n  it \"should set the chart data\" do\n    expect(@chart).to include('chd=t:0,100,50,32')\n  end\nend\n\ndescribe 'exporting a chart' do\n\n  it \"should be available in the url format by default\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'url')).to eq(Gchart.line(:data => [0, 26]))\n  end\n\n  it \"should be available as an image tag\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'image_tag')).to match(/<img src=(.*) width=\"300\" height=\"200\" alt=\"Google Chart\" \\/>/)\n  end\n\n  it \"should be available as an image tag using img_tag alias\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'img_tag')).to match(/<img src=(.*) width=\"300\" height=\"200\" alt=\"Google Chart\" \\/>/)\n  end\n\n  it \"should be available as an image tag using custom dimensions\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400')).to match(/<img src=(.*) width=\"400\" height=\"400\" alt=\"Google Chart\" \\/>/)\n  end\n\n  it \"should be available as an image tag using custom alt text\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart')).to match(/<img src=(.*) width=\"300\" height=\"200\" alt=\"Sexy chart\" \\/>/)\n  end\n\n  it \"should be available as an image tag using custom title text\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart')).to match(/<img src=(.*) width=\"300\" height=\"200\" alt=\"Google Chart\" title=\"Sexy chart\" \\/>/)\n  end\n\n  it \"should be available as an image tag using custom css id selector\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart')).to match(/<img id=\"chart\" src=(.*) width=\"300\" height=\"200\" alt=\"Google Chart\" \\/>/)\n  end\n\n  it \"should be available as an image tag using custom css class selector\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to match(/<img class=\"chart\" src=(.*) width=\"300\" height=\"200\" alt=\"Google Chart\" \\/>/)\n  end\n\n  it \"should use ampersands to separate key/value pairs in URLs by default\" do\n    expect(Gchart.line(:data => [0, 26])).to include \"&\"\n    expect(Gchart.line(:data => [0, 26])).not_to include \"&amp;\"\n  end\n\n  it \"should escape ampersands in URLs when used as an image tag\" do\n    expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to satisfy {|chart| expect(chart).to include \"&amp;\" }\n  end\n\n  it \"should be available as a file\" do\n    File.delete('chart.png') if File.exist?('chart.png')\n    Gchart.line(:data => [0, 26], :format => 'file')\n    expect(File.exist?('chart.png')).to be\n    File.delete('chart.png') if File.exist?('chart.png')\n  end\n\n  it \"should be available as a file using a custom file name\" do\n    File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')\n    Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png')\n    expect(File.exist?('custom_file_name.png')).to be\n    File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')\n  end\n\n  it \"should work even with multiple attrs\" do\n    File.delete('foo.png') if File.exist?('foo.png')\n    Gchart.line(:size => '400x200',\n                :data => [1,2,3,4,5],\n                # :axis_labels => [[1,2,3,4, 5], %w[foo bar]],\n                :axis_with_labels => 'x,r',\n                :format => \"file\",\n                :filename => \"foo.png\"\n                )\n    expect(File.exist?('foo.png')).to be\n    File.delete('foo.png') if File.exist?('foo.png')\n  end\nend\n\ndescribe 'SSL support' do\n  it 'should change url if is presented' do\n    expect(Gchart.line(:use_ssl => true)).to include('https://chart.googleapis.com/chart?')\n  end\n\n  it \"should be available as a file\" do\n    pending \"unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)\"\n    File.delete('chart.png') if File.exist?('chart.png')\n    Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true)\n    expect(File.exist?('chart.png')).to be_true\n    File.delete('chart.png') if File.exist?('chart.png')\n  end\nend\n\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "begin\n  require 'rspec'\nrescue LoadError\n  require 'rubygems'\n  gem 'rspec'\n  require 'rspec'\nend\n"
  },
  {
    "path": "spec/theme_spec.rb",
    "content": "require File.dirname(__FILE__) + '/spec_helper.rb'\nrequire File.dirname(__FILE__) + '/../lib/gchart'\n\ndescribe \"generating a default Gchart\" do\n  it 'should be able to add additional theme files' do\n    expect(Chart::Theme.theme_files).not_to include(\"#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml\")\n    Chart::Theme.add_theme_file(\"#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml\")\n    expect(Chart::Theme.theme_files).to include(\"#{File.dirname(__FILE__)}/fixtures/another_test_theme.yml\")\n  end\n  \n  it 'should be able to load themes from the additional theme files' do\n    expect { Chart::Theme.load(:test_two) }.not_to raise_error\n  end\n  \n  it 'should raise ThemeNotFound if theme does not exist' do\n    expect { Chart::Theme.load(:nonexistent) }.to raise_error(Chart::Theme::ThemeNotFound, \"Could not locate the nonexistent theme ...\")\n  end\n  \n  it 'should set colors array' do\n    expect(Chart::Theme.load(:keynote).colors).to eql([\"6886B4\", \"FDD84E\", \"72AE6E\", \"D1695E\", \"8A6EAF\", \"EFAA43\", \"FFFFFF\", \"000000\"])\n  end\n  \n  it 'should set bar colors array' do\n    expect(Chart::Theme.load(:keynote).bar_colors).to eql([\"6886B4\", \"FDD84E\", \"72AE6E\", \"D1695E\", \"8A6EAF\", \"EFAA43\"])\n  end\n  \n  it 'should set background' do\n    expect(Chart::Theme.load(:keynote).background).to eql(\"000000\")\n  end\n  \n  it 'should set chart background' do\n    expect(Chart::Theme.load(:keynote).chart_background).to eql(\"FFFFFF\")\n  end\nend"
  }
]