# File lib/fusion_charts_helper.rb, line 31
  def render_chart(chart_swf,str_url,str_data,chart_id,chart_width,chart_height,debug_mode=false,register_with_js=false,options={})
    chart_width=chart_width.to_s
    chart_height=chart_height.to_s
    concat("\t\t<!-- START Script Block for Chart "+chart_id+" -->\n\t\t") 
    concat(content_tag("div","\n\t\t\t\tChart.\n\t\t",{:id=>chart_id+"Div",:align=>"center"}))
    concat("\n\t\t<script type='text/javascript'>\n")
        
    debug_mode_num= debug_mode ? "1" : "0"
    register_with_js_num= register_with_js ? "1" : "0" 
    
    w_mode = ""
    color = ""
    scale_mode = ""
    lang = ""
    detect_flash_version = ""
    auto_install_redirect = ""
    data_format = ""
    renderer=""
      
    if !options.nil? && options.is_a?(Hash)
      w_mode = options[:w_mode].nil? ? "" : options[:w_mode]
      color = options[:color].nil? ? "" : options[:color]
      scale_mode = options[:scale_mode].nil? ? "" : options[:scale_mode]
      lang = options[:lang].nil? ? "" : options[:lang]
      detect_flash_version = options[:detect_flash_version] ? "1" : "0"
      auto_install_redirect = options[:auto_install_redirect] ? "1" : "0"
      data_format = options[:data_format].nil? ? "" : options[:data_format] #default value is "xml"
      renderer = options[:renderer].nil? ? "flash" : options[:renderer] # default value is "flash"
    end
    # Instantiating the chart renderer
    concat("\t\t\t\t//Instantiate the Chart     \n\t\t\t\tif( FusionCharts.setCurrentRenderer ) FusionCharts.setCurrentRenderer(\""+renderer+"\");\n")

    concat("\t\t\t\tvar chart_"+chart_id+"=new FusionCharts('"+chart_swf+"','"+chart_id+"','"+chart_width+"','"+chart_height+"',"+debug_mode_num+","+register_with_js_num+", '"+color+"', '"+scale_mode+"', '"+lang+"', '"+detect_flash_version+"', '"+auto_install_redirect+"');\n")
    
    if str_data.empty?
      concat("\t\t\t\t<!-- Set the dataURL of the chart -->\n")
      if data_format==""
        data_format="xmlurl"
      end
      concat("\t\t\t\tchart_"+chart_id+".setChartDataUrl(\""+str_url+"\",\""+data_format+"\");\n")
      logger.info("The method used is setDataURL.The URL is " + str_url)
    else
      concat("\t\t\t\t<!-- Provide entire XML data using DataXML method -->\n")
      concat("\t\t\t\t")
      if data_format==""
        data_format="xml"
      end
      concat('chart_'+chart_id+'.setChartData(\''+str_data+'\',\''+data_format+'\');')
      concat("\n")
      logger.info("The method used is setDataXML.The XML is " + str_data)
    end
    
    # only 'transparent' and 'opaque' values are considered for w_mode.
    if w_mode=='transparent' || w_mode=='opaque' || w_mode=='window'
      if w_mode=='window'
        transparency = "" # null => window in new JS API
      elsif w_mode=='transparent'
        transparency = "true"
      else 
        transparency = "false"
      end
      concat("\t\t\t\tchart_"+chart_id+".setTransparent("+transparency+");\n")
    end
    
    concat("\t\t\t\t<!-- Finally render the chart. -->\n")
    concat("\t\t\t\tchart_"+chart_id+".render('"+chart_id+"Div');\n")
    concat("\t\t</script>\n")
    concat("\t\t<!-- END Script Block for Chart "+chart_id+" -->\n")
    
  end