Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用ruby显示谷歌图表?_Ruby_Url_Uri_Fxruby_Gchart - Fatal编程技术网

如何用ruby显示谷歌图表?

如何用ruby显示谷歌图表?,ruby,url,uri,fxruby,gchart,Ruby,Url,Uri,Fxruby,Gchart,我想知道如何在ruby中显示用gchartrb制作的图表。我试图通过简单地要求来自给定URL的图片来实现这一点,但这会导致错误“坏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

我想知道如何在ruby中显示用gchartrb制作的图表。我试图通过简单地要求来自给定URL的图片来实现这一点,但这会导致错误“坏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
需要“rubygems”
需要“谷歌图表”
#饼图
GoogleChart::PieChart.new('320x200',“饼图”,false)do | pc|
电脑数据“苹果”,40
pc.data“香蕉”,20
pc.data“Peach”,30
电脑数据“该死”,600
$chart=pc.to\U url
结束
需要“fox16”
包括福克斯
类图像\u查看器装饰\u全部,:宽度=>500,:高度=>450)
需要“打开uri”
@pic=Kernel.open($chart,“rb”)
@pic2=fxpgimage.new(app@pic.read)
FXImageFrame.new(self,@pic2)
结束
def创建
超级的
自我展示(放置屏幕)
结束
结束
app=FXApp.new
mainwin=Image_Viewer.new(应用程序)
app.create
app.run

似乎
URI::parse
不喜欢google生成的URL(可能是因为使用了
|
)。因此,请在使用前对其进行编码:

@pic = Kernel.open(URI::encode($chart))

不需要全局变量$chart,pc=GoogleChart::PieChart{..};pc.to_url