开发者

Cannot get FusionCharts setDataXML method to work in Ruby on Rails

This may be a sad implementation to start with but...

I have an XML string that I want to pass to a FusionChart but it fails (without errors...).

Controller code: trying to pull XML from a page

data_url = "[removed URL]/run/custom.xml?start=#{@start_week}&end=#{@end_week}&x=daychart=line&application=#{@application}".html_safe
data_uri = URI::escape(data_url)
@response = RestClient.get(data_uri)
Rails.logger.debug("Data: " + @response.inspect)

View Code: instantiating the Chart and passing the XML

开发者_StackOverflow
<script>
     var chart = new FusionCharts("/charts/MSLine.swf", "quality_center_stats", "700", "400", "1", "0");
     chart.setDataXML("<%= @response %>");
     chart.render("quality_center_stats");
</script>

Let me know if there is more I can add


Can be any of the following:

  1. The XML contains special characters which needs to be encoded in the DataXML method. e.g., % should be passed as %25, & as %26, " as %26quot; or &quot;

  2. Make sure you do not have any newline character in that XML string. That would break the string in JavaScript (and you will get "unterminated string" error in JavaScript console)

  3. Make sure the XML data which is passed conforms to FusionCharts Mulit-series data format

  4. Make sure you have placed the SWF and JS files in proper paths and are accessed correctly. (can check through network tab of Firebug or Developer Console of Chrome)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜