Parent

Included Modules

Class Index

Quicksearch

Ziya::Charts::Support::Draw

Sets up a drawing area on the chart to draw text, rect, circles...

Holds any number of elements to draw. A draw element can be a circle, image (JPEG or SWF), line, rectangle, or text. Use draw “image” to include SWF flash file with animation, roll-over buttons, sounds, scripts, etc.

:

See www.maani.us/xml_charts/index.php?menu=Reference&submenu=draw for additional documentation, examples and futher detail.

Public Instance Methods

flatten( xml, composite_urls=nil ) click to toggle source


Dump has_attribute into xml element

    # File lib/ziya/charts/support/draw.rb, line 27
27:     def flatten( xml, composite_urls=nil )
28:       if components or composite_urls
29:         xml.draw do 
30:           components.each { |comp| comp.flatten( xml ) } if components
31:           gen_composites( xml, composite_urls ) if composite_urls
32:         end
33:       end
34:     end
gen_composites( xml, composite_urls ) click to toggle source


Generates Draw component for composite charts

    # File lib/ziya/charts/support/draw.rb, line 38
38:     def gen_composites( xml, composite_urls ) 
39:       composite_urls.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |chart_id|
40:         # composite descriptor can either be a string for the comp url or a pair for the swf lib_path and url
41:         raise "You must specify a hash of options" unless composite_urls[chart_id].is_a? Hash
42:         opts = composite_urls[chart_id].clone
43:         url  = opts.delete( :url )
44:         raise "Unable to find composite chart url" unless url
45:         path = opts.delete(:path ) || chart_path 
46:         opts[:url] = gen_composite_path( path, url, chart_id )
47:         
48:         self.class.module_eval "xml.image( \#{opts_as_string( opts )} )\n"
49:         
50:         # xml.image( opts )
51:       end
52:     end
opts_as_string( opts ) click to toggle source


Turns options hash into string representation

    # File lib/ziya/charts/support/draw.rb, line 59
59:     def opts_as_string( opts )
60:       buff = []
61:       opts.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |k|
62:         value = opts[k]
63:         buff << sprintf( ":%s => '%s'", k, value.to_s ) if value
64:       end    
65:       buff.join( "," )
66:     end

secsequence

--- SEC00102

seccomment

--- ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000087
    name: flatten
    sourcecode: "    <span class=\"ruby-comment cmt\"># File lib/ziya/charts/support/draw.rb, line 27</span>\n\
      27:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">flatten</span>( <span class=\"ruby-identifier\">xml</span>, <span class=\"ruby-identifier\">composite_urls</span>=<span class=\"ruby-keyword kw\">nil</span> )\n\
      28:       <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">components</span> <span class=\"ruby-keyword kw\">or</span> <span class=\"ruby-identifier\">composite_urls</span>\n\
      29:         <span class=\"ruby-identifier\">xml</span>.<span class=\"ruby-identifier\">draw</span> <span class=\"ruby-keyword kw\">do</span> \n\
      30:           <span class=\"ruby-identifier\">components</span>.<span class=\"ruby-identifier\">each</span> { <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">comp</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">comp</span>.<span class=\"ruby-identifier\">flatten</span>( <span class=\"ruby-identifier\">xml</span> ) } <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">components</span>\n\
      31:           <span class=\"ruby-identifier\">gen_composites</span>( <span class=\"ruby-identifier\">xml</span>, <span class=\"ruby-identifier\">composite_urls</span> ) <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">composite_urls</span>\n\
      32:         <span class=\"ruby-keyword kw\">end</span>\n\
      33:       <span class=\"ruby-keyword kw\">end</span>\n\
      34:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <hr size="10"></hr><p>
      Dump has_attribute into xml element
      </p>
    params: ( xml, composite_urls=nil )
  - visibility: public
    aref: M000088
    name: gen_composites
    sourcecode: "    <span class=\"ruby-comment cmt\"># File lib/ziya/charts/support/draw.rb, line 38</span>\n\
      38:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">gen_composites</span>( <span class=\"ruby-identifier\">xml</span>, <span class=\"ruby-identifier\">composite_urls</span> ) \n\
      39:       <span class=\"ruby-identifier\">composite_urls</span>.<span class=\"ruby-identifier\">keys</span>.<span class=\"ruby-identifier\">sort</span>{ <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">a</span>,<span class=\"ruby-identifier\">b</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">a</span>.<span class=\"ruby-identifier\">to_s</span> <span class=\"ruby-operator\">&lt;=&gt;</span> <span class=\"ruby-identifier\">b</span>.<span class=\"ruby-identifier\">to_s</span> }.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">chart_id</span><span class=\"ruby-operator\">|</span>\n\
      40:         <span class=\"ruby-comment cmt\"># composite descriptor can either be a string for the comp url or a pair for the swf lib_path and url</span>\n\
      41:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-value str\">&quot;You must specify a hash of options&quot;</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">composite_urls</span>[<span class=\"ruby-identifier\">chart_id</span>].<span class=\"ruby-identifier\">is_a?</span> <span class=\"ruby-constant\">Hash</span>\n\
      42:         <span class=\"ruby-identifier\">opts</span> = <span class=\"ruby-identifier\">composite_urls</span>[<span class=\"ruby-identifier\">chart_id</span>].<span class=\"ruby-identifier\">clone</span>\n\
      43:         <span class=\"ruby-identifier\">url</span>  = <span class=\"ruby-identifier\">opts</span>.<span class=\"ruby-identifier\">delete</span>( <span class=\"ruby-identifier\">:url</span> )\n\
      44:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-value str\">&quot;Unable to find composite chart url&quot;</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">url</span>\n\
      45:         <span class=\"ruby-identifier\">path</span> = <span class=\"ruby-identifier\">opts</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">:path</span> ) <span class=\"ruby-operator\">||</span> <span class=\"ruby-identifier\">chart_path</span> \n\
      46:         <span class=\"ruby-identifier\">opts</span>[<span class=\"ruby-identifier\">:url</span>] = <span class=\"ruby-identifier\">gen_composite_path</span>( <span class=\"ruby-identifier\">path</span>, <span class=\"ruby-identifier\">url</span>, <span class=\"ruby-identifier\">chart_id</span> )\n\
      47:         \n\
      48:         <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">class</span>.<span class=\"ruby-identifier\">module_eval</span> <span class=\"ruby-value str\">&quot;xml.image( \\#{opts_as_string( opts )} )\\n&quot;</span>\n\
      49:         \n\
      50:         <span class=\"ruby-comment cmt\"># xml.image( opts )</span>\n\
      51:       <span class=\"ruby-keyword kw\">end</span>\n\
      52:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <hr size="10"></hr><p>
      Generates <a href="Draw.html">Draw</a> component for composite charts
      </p>
    params: ( xml, composite_urls )
  - visibility: public
    aref: M000089
    name: opts_as_string
    sourcecode: "    <span class=\"ruby-comment cmt\"># File lib/ziya/charts/support/draw.rb, line 59</span>\n\
      59:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">opts_as_string</span>( <span class=\"ruby-identifier\">opts</span> )\n\
      60:       <span class=\"ruby-identifier\">buff</span> = []\n\
      61:       <span class=\"ruby-identifier\">opts</span>.<span class=\"ruby-identifier\">keys</span>.<span class=\"ruby-identifier\">sort</span>{ <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">a</span>,<span class=\"ruby-identifier\">b</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">a</span>.<span class=\"ruby-identifier\">to_s</span> <span class=\"ruby-operator\">&lt;=&gt;</span> <span class=\"ruby-identifier\">b</span>.<span class=\"ruby-identifier\">to_s</span> }.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">k</span><span class=\"ruby-operator\">|</span>\n\
      62:         <span class=\"ruby-identifier\">value</span> = <span class=\"ruby-identifier\">opts</span>[<span class=\"ruby-identifier\">k</span>]\n\
      63:         <span class=\"ruby-identifier\">buff</span> <span class=\"ruby-operator\">&lt;&lt;</span> <span class=\"ruby-identifier\">sprintf</span>( <span class=\"ruby-value str\">&quot;:%s =&gt; '%s'&quot;</span>, <span class=\"ruby-identifier\">k</span>, <span class=\"ruby-identifier\">value</span>.<span class=\"ruby-identifier\">to_s</span> ) <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">value</span>\n\
      64:       <span class=\"ruby-keyword kw\">end</span>    \n\
      65:       <span class=\"ruby-identifier\">buff</span>.<span class=\"ruby-identifier\">join</span>( <span class=\"ruby-value str\">&quot;,&quot;</span> )\n\
      66:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <hr size="10"></hr><p>
      Turns options hash into string representation
      </p>
    params: ( opts )
  category: Instance
  type: Public

sectitle

--- 

[Validate]

Generated with the Darkfish Rdoc Generator.