module OFC2::InstanceMethods

Public Instance Methods

ofc2(width, height, url, id =Time.now.usec, flash_attributes = {}, flash_params = {}) click to toggle source

generate a ofc object using data from url

+width+ width for div
+height+ height for div
+url+ an url which return data in json format, if you use url_for method to set url param the base param must be set to '' (empty string)
+id+ id for div with graph, default Time.now.usec
+flash_attributes+ attributes for swf
+flash_params+ params for swf
# File lib/ofc2.rb, line 83
    def ofc2(width, height, url, id =Time.now.usec, flash_attributes = {}, flash_params = {})
      url = CGI::escape(url)
      div_name = "flashcontent_#{id}"
      <<-EOF
        <div id='#{div_name}'></div>
        <script type="text/javascript">
          swfobject.embedSWF(
          "/assets/open-flash-chart.swf","#{div_name}",
          "#{width}", "#{height}", "9.0.0", "/assets/expressInstall.swf",
          {"data-file":"#{url}"}, #{flash_params.to_json}, #{flash_attributes.to_json} );

        </script>
      EOF
    end
ofc2_inline(width, height, graph, id=Time.now.usec, flash_attributes = {}, flash_params = {}) click to toggle source

generate a ofc object using Graph object, it's more handy than ofc2 method

+width+ width for div
+height+ height for div
+graph+ a OFC2::Graph object
+id+ id for div with graph, default Time.now.usec
+flash_attributes+ attributes for swf
+flash_params+ params for swf
# File lib/ofc2.rb, line 57
    def ofc2_inline(width, height, graph, id=Time.now.usec, flash_attributes = {}, flash_params = {})
      div_name = "flashcontent_#{id}"
      <<-EOF
        <div id="#{div_name}"></div>
        <script type="text/javascript">

          function #{div_name}_data(){
            return '#{graph.render}';
          };

          swfobject.embedSWF(
            '/assets/open-flash-chart.swf', '#{div_name}',
            '#{width}', '#{height}','9.0.0', '/assets/expressInstall.swf',
            {'get-data':'#{div_name}_data'}, #{flash_params.to_json}, #{flash_attributes.to_json} );

        </script>
      EOF
    end