Sha256: 268914cd59f3fe5115cec831bbeb7544cf5c72b91c46f542d19c595382672e3e

Contents?: true

Size: 1.56 KB

Versions: 14

Compression:

Stored size: 1.56 KB

Contents

module GoogleVisualr
  module Image

    # http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html
    class BarChart < BaseChart
      include GoogleVisualr::Packages::ImageChart

      # For Configuration Options, please refer to:
      # http://code.google.com/apis/chart/interactive/docs/gallery/imagebarchart.html

      # Create URI for image bar chart.  Override parameters by passing in a hash.
      # (see http://code.google.com/apis/chart/image/docs/chart_params.html)
      #
      # Parameters:
      #  *params         [Optional] Hash of url query parameters
      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
    end

  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
google_visualr_rails5-2.5.2 lib/google_visualr/image/bar_chart.rb
google_visualr-2.5.1 lib/google_visualr/image/bar_chart.rb
google_visualr-2.5.0 lib/google_visualr/image/bar_chart.rb
google_visualr-2.4.0 lib/google_visualr/image/bar_chart.rb
google_visualr-2.3.0 lib/google_visualr/image/bar_chart.rb
google_visualr-2.2.0 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.9 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.8 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.7 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.6 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.5 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.4 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.3 lib/google_visualr/image/bar_chart.rb
google_visualr-2.1.2 lib/google_visualr/image/bar_chart.rb