Class: Sol

Inherits:
Object
  • Object
show all
Defined in:
lib/jx/sol.rb,
lib/jx/js.rb,
lib/sol/chart.rb,
lib/sol/scale.rb,
lib/sol/stack.rb,
lib/jx/jsarray.rb,
lib/jx/callback.rb,
lib/jx/jsobject.rb,
lib/jx/rbobject.rb,
lib/sol/margins.rb,
lib/jx/irbobject.rb,
lib/sol/interval.rb,
lib/jx/jsfunction.rb,
lib/sol/bar_chart.rb,
lib/jx/jsundefined.rb,
lib/jx/proxy_array.rb,
lib/sol/base_chart.rb,
lib/sol/line_chart.rb,
lib/jx/jsstyle_sheet.rb,
lib/ruby_rich/bootstrap.rb,
lib/ruby_rich/dashboard.rb,
lib/sol/coordinate_chart.rb

Overview

Copyright © 2013 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation, without fee and without a signed licensing agreement, is hereby granted, provided that the above copyright notice, this paragraph and the following two paragraphs appear in all copies, modifications, and distributions.

IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED “AS IS”. RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Author:

  • Rodrigo Botafogo

Defined Under Namespace

Modules: BaseChart, CoordinateChart, Margins, Stack Classes: ArrayCallback, BarChart, Bootstrap, CSSRule, CSSRules, CSSStyleSheet, CSSStyleSheets, Callback, Chart, Dashboard, HashCallback, IRBObject, Interval, JSArray, JSFunction, JSObject, JSUndefined, Js, LineChart, LinearScale, OrdinalScale, ProxyArray, RBObject, Scale, TimeScale

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.mutexObject

Returns the value of attribute mutex.



32
33
34
# File 'lib/jx/sol.rb', line 32

def mutex
  @mutex
end

.resourceObject

Returns the value of attribute resource.



33
34
35
# File 'lib/jx/sol.rb', line 33

def resource
  @resource
end

Instance Attribute Details

#scope=(value) ⇒ Object (writeonly)

Sets the attribute scope

Parameters:

  • value

    the value to set the attribute scope to.



26
27
28
# File 'lib/jx/jsfunction.rb', line 26

def scope=(value)
  @scope = value
end

Class Method Details

.camelcase(str, *separators) ⇒ Object





40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/jx/sol.rb', line 40

def self.camelcase(str, *separators)
  
  case separators.first
    
  when Symbol, TrueClass, FalseClass, NilClass
    first_letter = separators.shift
  end
  
  separators = ['_', '\s'] if separators.empty?
  
  # str = self.dup
  
  separators.each do |s|
    str = str.gsub(/(?:#{s}+)([a-z])/){ $1.upcase }
  end
  
  case first_letter
  when :upper, true
    str = str.gsub(/(\A|\s)([a-z])/){ $1 + $2.upcase }
  when :lower, false
    str = str.gsub(/(\A|\s)([A-Z])/){ $1 + $2.downcase }
  end
  
  str
  
end

.dashboard(name, data, dimension_labels, date_columns = []) ⇒ Object





71
72
73
# File 'lib/jx/sol.rb', line 71

def self.dashboard(name, data, dimension_labels, date_columns = [])
  return Dashboard.new(name, data, dimension_labels, date_columns)
end

.scale(type) ⇒ Object





30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/sol/scale.rb', line 30

def self.scale(type)
  
  case type
  when :time
    scale = Sol::TimeScale.new
  when :time_utc
    scale = Sol::TimeScale.new(true)
  when :linear
    scale = Sol::LinearScale.new
  when :identity
    identity_scale(domain, range)
  when :power
    power_scale(domain, range)
  when :log
    log_scale(domain, range)
  when :quantize
    qunatize_scale(domain, range)
  when :quantile
    quantile_scale(domain, range)
  when :treshold
    treshold_scale(domain, range)
  when :ordinal
    ordinal_scale(domain, range)
  when :categorial_colors
      cat_colors_scale(domain, range)
  when :color_brewer
    color_brewer_scale(domain, range)
  end
  
  scale
  
end

.start(width, height) ⇒ Object





79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/jx/sol.rb', line 79

def self.start(width, height)
  
  @mutex = Mutex.new
  @resource = ConditionVariable.new
  @width = width
  @height = height
  
  Thread.new { RubyRich.launch(@width, @height) }  if !RubyRich.launched?

  # wait for the browser to initialize.  browser should call B.resource.signal
  # after initialization
  @mutex.synchronize {
    @resource.wait(@mutex)
  }

  require_relative 'js_init'

end