我想知道如何在 ruby 中显示用 gchartrb 制作的图表。我试图通过简单地要求给定 URL 中的图片来做到这一点,但这会给出错误“Bad URI”。我该怎么做?谢谢
require 'rubygems'
require 'google_chart'
# Pie Chart
GoogleChart::PieChart.new('320x200', "Pie Chart",false) do |pc|
pc.data "Apples", 40
pc.data "Banana", 20
pc.data "Peach", 30
pc.data "darn", 600
$chart = pc.to_url
end
require 'fox16'
include Fox
class Image_Viewer <FXMainWindow
def initialize(app)
super(app, "Image Viewer", :opts => DECOR_ALL, :width => 500, :height => 450)
require 'open-uri'
@pic = Kernel.open($chart, "rb")
@pic2 = FXPNGImage.new(app, @pic.read)
FXImageFrame.new(self, @pic2)
end
def create
super
self.show(PLACEMENT_SCREEN)
end
end
app = FXApp.new
mainwin = Image_Viewer.new(app)
app.create
app.run