开发者

amcharts with rails - not grabbing data feed

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜