Sha256: faae1b96da1a99505b1e343af154154e8578336ff546b842d9209f7dc49c8efe
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
def data_table @cols = [ { :type => "string", :label => "Year" }, { :type => "number", :label => "Sales" }, { :type => "number", :label => "Expenses" } ] @rows = [ { :c => [ {:v => "2004"}, {:v => 1000}, {:v => 400} ] }, { :c => [ {:v => "2005"}, {:v => 1200}, {:v => 450} ] }, { :c => [ {:v => "2006"}, {:v => 1500}, {:v => 600} ] }, { :c => [ {:v => "2007"}, {:v => 800 }, {:v => 500} ] } ] GoogleVisualr::DataTable.new(:cols => @cols, :rows => @rows) end def base_chart(data_table=data_table) GoogleVisualr::BaseChart.new( data_table, { :legend => "Test Chart", :width => 800, :is3D => true } ) end def base_chart_js(div_class="div_class") js = "\n<script type='text/javascript'>" js << "\n google.load('visualization','1', {packages: ['basechart'], callback: function() {" js << "\n var data_table = new google.visualization.DataTable();data_table.addColumn('string', 'Year');data_table.addColumn('number', 'Sales');data_table.addColumn('number', 'Expenses');data_table.addRow([{v: '2004'}, {v: 1000}, {v: 400}]);data_table.addRow([{v: '2005'}, {v: 1200}, {v: 450}]);data_table.addRow([{v: '2006'}, {v: 1500}, {v: 600}]);data_table.addRow([{v: '2007'}, {v: 800}, {v: 500}]);\n var chart = new google.visualization.BaseChart(document.getElementById('#{div_class}'));" js << "\n chart.draw(data_table, {legend: 'Test Chart', width: 800, is3D: true});" js << "\n }});" js << "\n</script>" end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
google_visualr-2.1.1 | spec/support/common.rb |
google_visualr-2.1.0 | spec/support/common.rb |