google_chart 画图 插件
def venn_diagram
require 'google_chart'
GoogleChart::VennDiagram.new("400x400", 'Venn Diagram') do |vd|
vd.data "Blue", 500,'0000ff'
vd.data "Green", 400, '00ff00'
vd.data "Red", 300, 'ff0000'
vd.intersections 200, 100, 50
@chart1 = vd.to_url
end
GoogleChart::BarChart.new('800x200', "Bar Chart", :vertical, false) do |bc|
bc.data "beijing", [20000], '0000ff'
bc.data "shanghai", [18000], 'ff0000'
bc.data "tianjin", [10000], '00ff00'
bc.data "nanjing", [8000], '00aaff'
bc.data "guangzhou", [16000], '0effee'
bc.data "shenzhen", [14000], 'eeff00'
@chart2 = bc.to_url
end
GoogleChart::PieChart.new('320x200', "Pie Chart",false) do |pc|
pc.data "very good", 300
pc.data "good", 200
pc.data "just so so", 100
pc.data "bad", 180
pc.show_labels = true
@chart3 = pc.to_url
end
GoogleChart::LineChart.new('320x200', "Line XY Chart", true) do |lcxy|
lcxy.data "amount", [[1,56], [2,48], [3,68], [4,59], [5,66], [6,67], [7,59]], '0000ff'
@chart4 = lcxy.to_url
end
end
view 代码:
<%= image_tag @chart1 %>
<%= image_tag @chart2 %>
<%= image_tag @chart3 %>
<%= image_tag @chart4 %>
网上看到了 以后也许要用备注下