amcharts with Rails - 不抓取数据源

发布于 2024-08-24 15:34:09 字数 1605 浏览 1 评论 0原文

我目前正在关注: http:// /railsontherun.com/2007/10/04/sexy-charts-in-less-than-5-months/

我很容易地完成了这一切,但是当查看带有图表的页面时,它加载了(在 Flash 中)一个带有错误的黑色矩形:

“加载文件时出错 http://localhost:3000/reports/ population.xml

评论中有人说这可能与 XML 构建器文件中的代码有关。

  xml.instruct!  :xml, :version=>"1.0", :encoding=>"UTF-8"
  xml.chart do
    # xml.message "You can broadcast any message to chart from data XML file", :bg_color => "#FFFFFF", :text_color => "#000000"
    xml.series do    
      @cities.each_with_index do |city, index|
        xml.value city.name,  :xid => index
      end
    end

    xml.graphs do
     #the gid is used in the settings file to set different settings just for this graph
      xml.graph :gid => 'population' do
        @cities.each_with_index do |city, index|
          population = city.population
          case population
            # When the population is > 1 million, show the bar in red/pink
            when > 100000
              xml.value value,  :xid => index, :color => "#ff43a8", :gradient_fill_colors => "#960040,#ff43a8", :description => level
            else
              xml.value value,  :xid => index, :color => "#00C3C6", :gradient_fill_colors => "#009c9d,#00C3C6", :description => level
            end
        end
      end
    end

  end

我不太确定错误来自哪里,但我希望得到任何帮助!

最好的, 艾略特

I'm currently following: http://railsontherun.com/2007/10/04/sexy-charts-in-less-than-5-minutes/

I went through it all pretty easily, but then when viewing the page with the chart, it loads (in flash) a black rectangle with the error:

"Error loading file http://localhost:3000/reports/population.xml"

Someone in the comments said it may have to do with the code in the XML builder file.

  xml.instruct!  :xml, :version=>"1.0", :encoding=>"UTF-8"
  xml.chart do
    # xml.message "You can broadcast any message to chart from data XML file", :bg_color => "#FFFFFF", :text_color => "#000000"
    xml.series do    
      @cities.each_with_index do |city, index|
        xml.value city.name,  :xid => index
      end
    end

    xml.graphs do
     #the gid is used in the settings file to set different settings just for this graph
      xml.graph :gid => 'population' do
        @cities.each_with_index do |city, index|
          population = city.population
          case population
            # When the population is > 1 million, show the bar in red/pink
            when > 100000
              xml.value value,  :xid => index, :color => "#ff43a8", :gradient_fill_colors => "#960040,#ff43a8", :description => level
            else
              xml.value value,  :xid => index, :color => "#00C3C6", :gradient_fill_colors => "#009c9d,#00C3C6", :description => level
            end
        end
      end
    end

  end

I'm not exactly sure where the error is coming from, but I'd love any help!

Best,
Elliot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半岛未凉 2024-08-31 15:34:09

我在那一行中发现了这一点

          xml.value value,  :xid => index, :color => "#00C3C6", :gradient_fill_colors => "#009c9d,#00C3C6", :description => level

,第二个“值”和“级别”变量没有定义。一旦它们完成,一切就正常了。

I figured this out

          xml.value value,  :xid => index, :color => "#00C3C6", :gradient_fill_colors => "#009c9d,#00C3C6", :description => level

in that line, the second "value" and the "level" var are not defined. Once they are it all works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文