Sha256: 06876d1dbb2c6635a6a118a29f746895707b3c5b594e45f12bd58c3c9ce8069f

Contents?: true

Size: 1.37 KB

Versions: 14

Compression:

Stored size: 1.37 KB

Contents


require 'omf_oml/network'
require 'omf_oml/table'

include OMF::OML
  
nw = OmlNetwork.new 'network'
nw.node_schema [[:x, :float], [:y, :float], [:capacity, :float]]
nw.create_node :n0, :x => 0.2, :y => 0.2, :capacity =>  0.3
nw.create_node :n1, :x => 0.6, :y => 0.6, :capacity =>  0.5
nw.create_node :n2, :x => 0.8, :y => 0.3, :capacity =>  0.8

nw.link_schema [[:load, :float]]
nw.create_link :l01, :n0, :n1, :load => 0.8
nw.create_link :l12, :n1, :n2, :load => 0.4
nw.create_link :l21, :n2, :n1, :load => 0.9

require 'omf_web'
OMF::Web.register_datasource nw.to_table(:nodes, :index => :id)
OMF::Web.register_datasource nw.to_table(:links, :index => :id)

# opts = {
  # #:data_sources => table,
  # #:viz_type => 'line_chart',
  # :wtype => 'graph',
  # :wopts => {
    # :viz_type => 'network2',
    # :data_sources => nw.to_tables,
    # :mapping => {
      # :nodes => {
        # :x => {:property => :x},
        # :y => {:property => :y},
        # :radius => {:property => :capacity, :scale => 20, :min => 4},
        # :fill_color => {:property => :capacity, :color => :green_yellow80_red}
      # },
      # :links => {
        # :stroke_width => {:property => :load, :scale => 20},
        # :stroke_color => {:property => :load, :color => :green_yellow80_red}
      # }
    # }
  # }
# }
# OMF::Web::Widget::Graph.addGraph('Network', opts) 
# #OMF::Web::Widget.register('Amplitude', opts) 

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
omf_web-1.2.9 example/demo/data_sources/network.rb
omf_web-1.2.8 example/demo/data_sources/network.rb
omf_web-1.2.7 example/demo/data_sources/network.rb
omf_web-1.2.6 example/demo/data_sources/network.rb
omf_web-1.2.5 example/demo/data_sources/network.rb
omf_web-1.2.4 example/demo/data_sources/network.rb
omf_web-1.2.3 example/demo/data_sources/network.rb
omf_web-1.2.2 example/demo/data_sources/network.rb
omf_web-1.2.1 example/demo/data_sources/network.rb
omf_web-1.2.0 example/demo/data_sources/network.rb
omf_web-1.0.0 example/demo/data_sources/network.rb
omf_web-0.9.9 example/demo/data_sources/network.rb
omf_web-0.9.8 example/demo/data_sources/network.rb
omf_web-0.9.7 example/demo/data_sources/network.rb