Class: GoogleVisualr::Image::BarChart

Inherits:
BaseChart
  • Object
show all
Includes:
Packages::ImageChart
Defined in:
lib/google_visualr/image/bar_chart.rb

Overview

Constant Summary

Constants included from Packages::ImageChart

Packages::ImageChart::IMAGE_DEFAULTS

Constants inherited from BaseChart

BaseChart::DEFAULT_VERSION

Instance Attribute Summary

Attributes inherited from BaseChart

#data_table, #language, #listeners, #material, #version

Instance Method Summary collapse

Methods included from Packages::ImageChart

#chart_image_url, #class_name, #package_name

Methods inherited from BaseChart

#add_listener, #chart_class, #chart_function_name, #chart_name, #class_name, #draw_js, #initialize, #load_js, #options, #options=, #package_name, #to_js

Methods included from ParamHelpers

#js_parameters, #stringify_keys!, #typecast

Constructor Details

This class inherits a constructor from GoogleVisualr::BaseChart

Instance Method Details

#uri(params = {}) ⇒ Object

Create URI for image bar chart. Override parameters by passing in a hash. (see code.google.com/apis/chart/image/docs/chart_params.html)

Parameters:

*params         [Optional] Hash of url query parameters


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/google_visualr/image/bar_chart.rb', line 16

def uri(params = {})
  query_params = {}
  
  # isStacked/isVertical, Chart Type
  chart_type = "b"
  chart_type += @options["isVertical"] ? "v" : "h"
  chart_type += @options["isStacked"] == false ? "g" : "s"
  query_params[:cht] = chart_type

  # showCategoryLabels (works as long as :chxt => "x,y")
  labels = ""
  val_column = @options["isVertical"] ? 1 : 0
  cat_column = @options["isVertical"] ? 0 : 1
  if @options["showCategoryLabels"] == false
    labels = "#{cat_column}:||"
  else
    labels = "#{cat_column}:|" + data_table.get_column(0).join('|') + "|"
  end
  
  # showValueLabels  (works as long as :chxt => "x,y")
  if @options["showValueLabels"] == false
    labels += "#{val_column}:||"
  end
  
  query_params[:chxl] = labels unless labels.blank?
  
  chart_image_url(query_params.merge(params))
end