hyper-vis 1.0.0.lap34 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +154 -23
- data/hyper-vis.gemspec +5 -5
- data/lib/hyper-vis.rb +7 -0
- data/lib/hyperloop/vis/graph2d/component.rb +16 -0
- data/lib/hyperloop/vis/graph2d/mixin.rb +89 -0
- data/lib/hyperloop/vis/graph3d/component.rb +15 -0
- data/lib/hyperloop/vis/graph3d/mixin.rb +79 -0
- data/lib/hyperloop/vis/network/mixin.rb +1 -1
- data/lib/hyperloop/vis/timeline/component.rb +16 -0
- data/lib/hyperloop/vis/timeline/mixin.rb +89 -0
- data/lib/hyperloop/vis/version.rb +1 -1
- data/lib/vis.rb +4 -1
- data/lib/vis/data_common.rb +46 -0
- data/lib/vis/data_set.rb +6 -1
- data/lib/vis/graph2d.rb +145 -0
- data/lib/vis/graph3d.rb +135 -0
- data/lib/vis/network.rb +187 -8
- data/lib/vis/railtie.rb +7 -0
- data/lib/vis/timeline.rb +338 -0
- data/lib/vis/utilities.rb +7 -199
- data/spec/test_app/Gemfile +2 -4
- data/spec/test_app/app/assets/stylesheets/application.css +2 -1
- data/spec/test_app/db/schema.rb +28 -0
- data/spec/vis_graph2d_component_spec.rb +89 -0
- data/spec/vis_graph2d_spec.rb +304 -0
- data/spec/vis_graph3d_component_spec.rb +124 -0
- data/spec/vis_graph3d_spec.rb +247 -0
- data/spec/vis_timeline_component_spec.rb +89 -0
- data/spec/vis_timeline_spec.rb +425 -0
- metadata +37 -13
| @@ -0,0 +1,425 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe 'Vis::Timeline', js: true do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              it 'creates a new Timeline' do
         | 
| 6 | 
            +
                expect_evaluate_ruby do
         | 
| 7 | 
            +
                  items = [
         | 
| 8 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 9 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 10 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 11 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 12 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 13 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 14 | 
            +
                  ]
         | 
| 15 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 16 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 17 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 18 | 
            +
                  [tl.is_a?(Vis::Timeline), dom_node.JS[:children].JS[:length]]
         | 
| 19 | 
            +
                end.to eq([true, 1])
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              it 'creates a new Timeline and destroys it' do
         | 
| 23 | 
            +
                expect_evaluate_ruby do
         | 
| 24 | 
            +
                  items = [
         | 
| 25 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 26 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 27 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 28 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 29 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 30 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 31 | 
            +
                  ]
         | 
| 32 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 33 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 34 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 35 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 36 | 
            +
                  tl.destroy
         | 
| 37 | 
            +
                  [tl.is_a?(Vis::Timeline), created, dom_node.JS[:children].JS[:length]]
         | 
| 38 | 
            +
                end.to eq([true, 1, 0])
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
              
         | 
| 41 | 
            +
              it 'it can replace the items' do
         | 
| 42 | 
            +
                expect_evaluate_ruby do
         | 
| 43 | 
            +
                  items = [
         | 
| 44 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 45 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 46 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 47 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 48 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 49 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 50 | 
            +
                  ]
         | 
| 51 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 52 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 53 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 54 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 55 | 
            +
                  new_items = [
         | 
| 56 | 
            +
                    {id: 1, content: 'item 1', start: '2013-05-20'},
         | 
| 57 | 
            +
                    {id: 2, content: 'item 2', start: '2013-05-14'},
         | 
| 58 | 
            +
                    {id: 3, content: 'item 3', start: '2013-05-18'},
         | 
| 59 | 
            +
                    {id: 4, content: 'item 4', start: '2013-05-16', end: '2013-05-19'},
         | 
| 60 | 
            +
                    {id: 5, content: 'item 5', start: '2013-05-25'},
         | 
| 61 | 
            +
                    {id: 6, content: 'item 6', start: '2013-05-27'}
         | 
| 62 | 
            +
                  ]
         | 
| 63 | 
            +
                  new_dataset = Vis::DataSet.new(new_items)
         | 
| 64 | 
            +
                  tl.set_items(new_dataset)
         | 
| 65 | 
            +
                  [tl.is_a?(Vis::Timeline), created]
         | 
| 66 | 
            +
                end.to eq([true, 1])
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              it 'it can set options' do
         | 
| 70 | 
            +
                expect_evaluate_ruby do
         | 
| 71 | 
            +
                  items = [
         | 
| 72 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 73 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 74 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 75 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 76 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 77 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 78 | 
            +
                  ]
         | 
| 79 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 80 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 81 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 82 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 83 | 
            +
                  error = false
         | 
| 84 | 
            +
                  begin
         | 
| 85 | 
            +
                    tl.set_options(selectable: false)
         | 
| 86 | 
            +
                  rescue
         | 
| 87 | 
            +
                    error = true
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
                  [tl.is_a?(Vis::Timeline), created, error]
         | 
| 90 | 
            +
                end.to eq([true, 1, false])
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
              xit 'it can set and remove a event listener' do
         | 
| 94 | 
            +
                # needs simulation of user interaction
         | 
| 95 | 
            +
                expect_evaluate_ruby do
         | 
| 96 | 
            +
                  items = [
         | 
| 97 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 98 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 99 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 100 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 101 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 102 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 103 | 
            +
                  ]
         | 
| 104 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 105 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 106 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 107 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 108 | 
            +
                  received = []
         | 
| 109 | 
            +
                  handler_id = tl.on(:changed) do
         | 
| 110 | 
            +
                    received << 1
         | 
| 111 | 
            +
                  end
         | 
| 112 | 
            +
                  new_items = [
         | 
| 113 | 
            +
                    {id: 1, content: 'item 1', start: '2013-05-20'},
         | 
| 114 | 
            +
                    {id: 2, content: 'item 2', start: '2013-05-14'},
         | 
| 115 | 
            +
                    {id: 3, content: 'item 3', start: '2013-05-18'},
         | 
| 116 | 
            +
                    {id: 4, content: 'item 4', start: '2013-05-16', end: '2013-05-19'},
         | 
| 117 | 
            +
                    {id: 5, content: 'item 5', start: '2013-05-25'},
         | 
| 118 | 
            +
                    {id: 6, content: 'item 6', start: '2013-05-27'}
         | 
| 119 | 
            +
                  ]
         | 
| 120 | 
            +
                  new_dataset = Vis::DataSet.new(new_items)
         | 
| 121 | 
            +
                  tl.set_items(new_dataset)
         | 
| 122 | 
            +
                  tl.redraw
         | 
| 123 | 
            +
                  tl.off(:changed, handler_id)
         | 
| 124 | 
            +
                  tl.set_items(dataset)
         | 
| 125 | 
            +
                  [tl.is_a?(Vis::Timeline), created, received.size]
         | 
| 126 | 
            +
                end.to eq([true, 1, 2])
         | 
| 127 | 
            +
              end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
              it 'can call redraw' do
         | 
| 130 | 
            +
                expect_evaluate_ruby do
         | 
| 131 | 
            +
                  items = [
         | 
| 132 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 133 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 134 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 135 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 136 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 137 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 138 | 
            +
                  ]
         | 
| 139 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 140 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 141 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 142 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 143 | 
            +
                  tl.redraw
         | 
| 144 | 
            +
                  redrawn = dom_node.JS[:children].JS[:length]
         | 
| 145 | 
            +
                  [tl.is_a?(Vis::Timeline), created, redrawn]
         | 
| 146 | 
            +
                end.to eq([true, 1, 1])
         | 
| 147 | 
            +
              end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
              it 'can call fit' do
         | 
| 150 | 
            +
                expect_evaluate_ruby do
         | 
| 151 | 
            +
                  items = [
         | 
| 152 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 153 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 154 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 155 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 156 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 157 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 158 | 
            +
                  ]
         | 
| 159 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 160 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 161 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 162 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 163 | 
            +
                  tl.fit
         | 
| 164 | 
            +
                  fitted = dom_node.JS[:children].JS[:length]
         | 
| 165 | 
            +
                  [tl.is_a?(Vis::Timeline), created, fitted]
         | 
| 166 | 
            +
                end.to eq([true, 1, 1])
         | 
| 167 | 
            +
              end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
              it 'can set and get current time' do
         | 
| 170 | 
            +
                expect_evaluate_ruby do
         | 
| 171 | 
            +
                  items = [
         | 
| 172 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 173 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 174 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 175 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 176 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 177 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 178 | 
            +
                  ]
         | 
| 179 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 180 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 181 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 182 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 183 | 
            +
                  now = Time.now
         | 
| 184 | 
            +
                  time_get = tl.get_current_time
         | 
| 185 | 
            +
                  same_get_year = time_get.year == now.year
         | 
| 186 | 
            +
                  tl.set_current_time(Time.now + 1.year)
         | 
| 187 | 
            +
                  time_set = tl.get_current_time
         | 
| 188 | 
            +
                  same_set_year = time_set.year == (now + 1.year).year
         | 
| 189 | 
            +
                  [tl.is_a?(Vis::Timeline), created, same_get_year, same_set_year]
         | 
| 190 | 
            +
                end.to eq([true, 1, true, true])
         | 
| 191 | 
            +
              end
         | 
| 192 | 
            +
             | 
| 193 | 
            +
              it 'can add, set, get and remove a custom time, also can set a custom time title' do
         | 
| 194 | 
            +
                expect_evaluate_ruby do
         | 
| 195 | 
            +
                  items = [
         | 
| 196 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 197 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 198 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 199 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 200 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 201 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 202 | 
            +
                  ]
         | 
| 203 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 204 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 205 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 206 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 207 | 
            +
                  now = Time.now
         | 
| 208 | 
            +
                  tl.add_custom_time(now, 'time 1')
         | 
| 209 | 
            +
                  tl.set_custom_time_title("Oh waht a time!", 'time 1')
         | 
| 210 | 
            +
                  time_get = tl.get_custom_time('time 1')
         | 
| 211 | 
            +
                  same_get_year = time_get.year == now.year
         | 
| 212 | 
            +
                  tl.set_custom_time(Time.now + 1.year, 'time 1')
         | 
| 213 | 
            +
                  time_set = tl.get_custom_time('time 1')
         | 
| 214 | 
            +
                  same_set_year = time_set.year == (now + 1.year).year
         | 
| 215 | 
            +
                  tl.remove_custom_time('time 1')
         | 
| 216 | 
            +
                  [tl.is_a?(Vis::Timeline), created, same_get_year, same_set_year]
         | 
| 217 | 
            +
                end.to eq([true, 1, true, true])
         | 
| 218 | 
            +
              end
         | 
| 219 | 
            +
             | 
| 220 | 
            +
              it 'can set new data' do
         | 
| 221 | 
            +
                expect_evaluate_ruby do
         | 
| 222 | 
            +
                  items = [
         | 
| 223 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 224 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 225 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 226 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 227 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 228 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 229 | 
            +
                  ]
         | 
| 230 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 231 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 232 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 233 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 234 | 
            +
                  received = []
         | 
| 235 | 
            +
                  handler_id = tl.on(:changed) do
         | 
| 236 | 
            +
                    received << 1
         | 
| 237 | 
            +
                  end
         | 
| 238 | 
            +
                  new_items = [
         | 
| 239 | 
            +
                    {id: 1, content: 'item 1', start: '2013-05-20'},
         | 
| 240 | 
            +
                    {id: 2, content: 'item 2', start: '2013-05-14'},
         | 
| 241 | 
            +
                    {id: 3, content: 'item 3', start: '2013-05-18'},
         | 
| 242 | 
            +
                    {id: 4, content: 'item 4', start: '2013-05-16', end: '2013-05-19'},
         | 
| 243 | 
            +
                    {id: 5, content: 'item 5', start: '2013-05-25'},
         | 
| 244 | 
            +
                    {id: 6, content: 'item 6', start: '2013-05-27'}
         | 
| 245 | 
            +
                  ]
         | 
| 246 | 
            +
                  new_dataset = Vis::DataSet.new(new_items)
         | 
| 247 | 
            +
                  tl.set_data({items: new_dataset})
         | 
| 248 | 
            +
                  [tl.is_a?(Vis::Timeline), created]
         | 
| 249 | 
            +
                end.to eq([true, 1])
         | 
| 250 | 
            +
              end
         | 
| 251 | 
            +
             | 
| 252 | 
            +
              it 'can get and set the window' do
         | 
| 253 | 
            +
                expect_evaluate_ruby do
         | 
| 254 | 
            +
                  items = [
         | 
| 255 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 256 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 257 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 258 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 259 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 260 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 261 | 
            +
                  ]
         | 
| 262 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 263 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 264 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 265 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 266 | 
            +
                  window = tl.get_window
         | 
| 267 | 
            +
                  gws = window[:start].strftime('%Y-%m-%d')
         | 
| 268 | 
            +
                  gwe = window[:end].strftime('%Y-%m-%d')
         | 
| 269 | 
            +
                  tl.set_window('2014-06-12', '2014-06-15')
         | 
| 270 | 
            +
                  # window is set, but
         | 
| 271 | 
            +
                  # get_window doesnt work here, gives back the orignal values, but not the current ones
         | 
| 272 | 
            +
                  # window_fc = tl.get_window
         | 
| 273 | 
            +
                  # sws = window_fc[:start].strftime('%Y-%m-%d')
         | 
| 274 | 
            +
                  # swe = window_fc[:end].strftime('%Y-%m-%d')
         | 
| 275 | 
            +
             | 
| 276 | 
            +
                  # this is flaky, depending on browser window size,
         | 
| 277 | 
            +
                  # so we dont check for the exact day and chop the last digit off
         | 
| 278 | 
            +
                  [tl.is_a?(Vis::Timeline), created, gws.chop, gwe.chop] 
         | 
| 279 | 
            +
                end.to eq([true, 1, '2013-04-1', '2013-04-2'])
         | 
| 280 | 
            +
              end
         | 
| 281 | 
            +
             | 
| 282 | 
            +
              it 'can move the window' do
         | 
| 283 | 
            +
                expect_evaluate_ruby do
         | 
| 284 | 
            +
                  items = [
         | 
| 285 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 286 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 287 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 288 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 289 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 290 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 291 | 
            +
                  ]
         | 
| 292 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 293 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 294 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 295 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 296 | 
            +
                  tl.move_to('2014-06-12')
         | 
| 297 | 
            +
                  [tl.is_a?(Vis::Timeline), created]
         | 
| 298 | 
            +
                end.to eq([true, 1])
         | 
| 299 | 
            +
              end
         | 
| 300 | 
            +
             | 
| 301 | 
            +
              it 'can focus on item' do
         | 
| 302 | 
            +
                expect_evaluate_ruby do
         | 
| 303 | 
            +
                  items = [
         | 
| 304 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 305 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 306 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 307 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 308 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 309 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 310 | 
            +
                  ]
         | 
| 311 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 312 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 313 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 314 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 315 | 
            +
                  tl.focus(4)
         | 
| 316 | 
            +
                  [tl.is_a?(Vis::Timeline), created]
         | 
| 317 | 
            +
                end.to eq([true, 1])
         | 
| 318 | 
            +
              end
         | 
| 319 | 
            +
             | 
| 320 | 
            +
              it 'can select a item and get it' do
         | 
| 321 | 
            +
                expect_evaluate_ruby do
         | 
| 322 | 
            +
                  items = [
         | 
| 323 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 324 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 325 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 326 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 327 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 328 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 329 | 
            +
                  ]
         | 
| 330 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 331 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 332 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 333 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 334 | 
            +
                  tl.set_selection(4)
         | 
| 335 | 
            +
                  sel = tl.get_selection
         | 
| 336 | 
            +
                  [tl.is_a?(Vis::Timeline), created, sel.first]
         | 
| 337 | 
            +
                end.to eq([true, 1, 4])
         | 
| 338 | 
            +
              end
         | 
| 339 | 
            +
             | 
| 340 | 
            +
              xit 'can get visible items' do
         | 
| 341 | 
            +
                # result is always [] ?
         | 
| 342 | 
            +
                expect_evaluate_ruby do
         | 
| 343 | 
            +
                  items = [
         | 
| 344 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 345 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 346 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 347 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 348 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 349 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 350 | 
            +
                  ]
         | 
| 351 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 352 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 353 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset)
         | 
| 354 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 355 | 
            +
                  tl.focus(3)
         | 
| 356 | 
            +
                  vis_i = tl.get_visible_items
         | 
| 357 | 
            +
                  [tl.is_a?(Vis::Timeline), created, vis_i.size]
         | 
| 358 | 
            +
                end.to eq([true, 1, 1])
         | 
| 359 | 
            +
              end
         | 
| 360 | 
            +
              
         | 
| 361 | 
            +
              it 'can toggle rolling mode' do
         | 
| 362 | 
            +
                expect_evaluate_ruby do
         | 
| 363 | 
            +
                  items = [
         | 
| 364 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 365 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 366 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 367 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 368 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 369 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 370 | 
            +
                  ]
         | 
| 371 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 372 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 373 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset, rolling_mode: { offset: 0.5 })
         | 
| 374 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 375 | 
            +
                  tl.toggle_rolling_mode
         | 
| 376 | 
            +
                  [tl.is_a?(Vis::Timeline), created]
         | 
| 377 | 
            +
                end.to eq([true, 1])
         | 
| 378 | 
            +
              end
         | 
| 379 | 
            +
             | 
| 380 | 
            +
              it 'can get the range of items' do
         | 
| 381 | 
            +
                expect_evaluate_ruby do
         | 
| 382 | 
            +
                  items = [
         | 
| 383 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 384 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 385 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 386 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 387 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 388 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 389 | 
            +
                  ]
         | 
| 390 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 391 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 392 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset, rolling_mode: { offset: 0.5 })
         | 
| 393 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 394 | 
            +
                  data_range = tl.get_item_range
         | 
| 395 | 
            +
                  # this is flaky, depending on something,
         | 
| 396 | 
            +
                  # so we dont check for the exact day and chop the last digit off
         | 
| 397 | 
            +
                  min = data_range[:min].strftime('%Y-%m-%d').chop
         | 
| 398 | 
            +
                  max = data_range[:max].strftime('%Y-%m-%d').chop
         | 
| 399 | 
            +
                  [tl.is_a?(Vis::Timeline), created, min, max]
         | 
| 400 | 
            +
                end.to eq([true, 1, '2013-04-1', '2013-04-2'])
         | 
| 401 | 
            +
              end
         | 
| 402 | 
            +
             | 
| 403 | 
            +
              it 'can zoom in and out' do
         | 
| 404 | 
            +
                expect_evaluate_ruby do
         | 
| 405 | 
            +
                  items = [
         | 
| 406 | 
            +
                    {id: 1, content: 'item 1', start: '2013-04-20'},
         | 
| 407 | 
            +
                    {id: 2, content: 'item 2', start: '2013-04-14'},
         | 
| 408 | 
            +
                    {id: 3, content: 'item 3', start: '2013-04-18'},
         | 
| 409 | 
            +
                    {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
         | 
| 410 | 
            +
                    {id: 5, content: 'item 5', start: '2013-04-25'},
         | 
| 411 | 
            +
                    {id: 6, content: 'item 6', start: '2013-04-27'}
         | 
| 412 | 
            +
                  ]
         | 
| 413 | 
            +
                  dataset = Vis::DataSet.new(items)
         | 
| 414 | 
            +
                  dom_node = Vis::Timeline.test_container
         | 
| 415 | 
            +
                  tl = Vis::Timeline.new(dom_node, dataset, rolling_mode: { offset: 0.5 })
         | 
| 416 | 
            +
                  created = dom_node.JS[:children].JS[:length]
         | 
| 417 | 
            +
                  tl.zoom_in(0.1)
         | 
| 418 | 
            +
                  tl.zoom_out(0.2)
         | 
| 419 | 
            +
                  [tl.is_a?(Vis::Timeline), created]
         | 
| 420 | 
            +
                end.to eq([true, 1])
         | 
| 421 | 
            +
              end
         | 
| 422 | 
            +
             | 
| 423 | 
            +
              xit 'get_event_properties'
         | 
| 424 | 
            +
              xit 'set_groups'
         | 
| 425 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: hyper-vis
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jan Biedermann
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-03- | 
| 11 | 
            +
            date: 2018-03-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: opal
         | 
| @@ -44,56 +44,56 @@ dependencies: | |
| 44 44 | 
             
                requirements:
         | 
| 45 45 | 
             
                - - "~>"
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version: 1.0.0. | 
| 47 | 
            +
                    version: 1.0.0.lap27
         | 
| 48 48 | 
             
              type: :runtime
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 52 | 
             
                - - "~>"
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: 1.0.0. | 
| 54 | 
            +
                    version: 1.0.0.lap27
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 56 | 
             
              name: hyperloop-config
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 59 | 
             
                - - "~>"
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: 1.0.0. | 
| 61 | 
            +
                    version: 1.0.0.lap27
         | 
| 62 62 | 
             
              type: :runtime
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 66 | 
             
                - - "~>"
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: 1.0.0. | 
| 68 | 
            +
                    version: 1.0.0.lap27
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: hyperloop
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 73 | 
             
                - - "~>"
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version: 1.0.0. | 
| 75 | 
            +
                    version: 1.0.0.lap27
         | 
| 76 76 | 
             
              type: :development
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 80 | 
             
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: 1.0.0. | 
| 82 | 
            +
                    version: 1.0.0.lap27
         | 
| 83 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 84 | 
             
              name: hyper-spec
         | 
| 85 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 86 | 
             
                requirements:
         | 
| 87 87 | 
             
                - - "~>"
         | 
| 88 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            -
                    version: 1.0.0. | 
| 89 | 
            +
                    version: 1.0.0.lap27
         | 
| 90 90 | 
             
              type: :development
         | 
| 91 91 | 
             
              prerelease: false
         | 
| 92 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 93 | 
             
                requirements:
         | 
| 94 94 | 
             
                - - "~>"
         | 
| 95 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version: 1.0.0. | 
| 96 | 
            +
                    version: 1.0.0.lap27
         | 
| 97 97 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 98 | 
             
              name: listen
         | 
| 99 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -177,16 +177,25 @@ files: | |
| 177 177 | 
             
            - README.md
         | 
| 178 178 | 
             
            - hyper-vis.gemspec
         | 
| 179 179 | 
             
            - lib/hyper-vis.rb
         | 
| 180 | 
            +
            - lib/hyperloop/vis/graph2d/component.rb
         | 
| 181 | 
            +
            - lib/hyperloop/vis/graph2d/mixin.rb
         | 
| 182 | 
            +
            - lib/hyperloop/vis/graph3d/component.rb
         | 
| 183 | 
            +
            - lib/hyperloop/vis/graph3d/mixin.rb
         | 
| 180 184 | 
             
            - lib/hyperloop/vis/network/component.rb
         | 
| 181 185 | 
             
            - lib/hyperloop/vis/network/mixin.rb
         | 
| 186 | 
            +
            - lib/hyperloop/vis/timeline/component.rb
         | 
| 187 | 
            +
            - lib/hyperloop/vis/timeline/mixin.rb
         | 
| 182 188 | 
             
            - lib/hyperloop/vis/version.rb
         | 
| 183 189 | 
             
            - lib/vis.rb
         | 
| 184 190 | 
             
            - lib/vis/data_common.rb
         | 
| 185 191 | 
             
            - lib/vis/data_set.rb
         | 
| 186 192 | 
             
            - lib/vis/data_view.rb
         | 
| 187 193 | 
             
            - lib/vis/event_support.rb
         | 
| 194 | 
            +
            - lib/vis/graph2d.rb
         | 
| 195 | 
            +
            - lib/vis/graph3d.rb
         | 
| 188 196 | 
             
            - lib/vis/native.rb
         | 
| 189 197 | 
             
            - lib/vis/network.rb
         | 
| 198 | 
            +
            - lib/vis/railtie.rb
         | 
| 190 199 | 
             
            - lib/vis/source/img/network/acceptDeleteIcon.png
         | 
| 191 200 | 
             
            - lib/vis/source/img/network/addNodeIcon.png
         | 
| 192 201 | 
             
            - lib/vis/source/img/network/backIcon.png
         | 
| @@ -204,6 +213,7 @@ files: | |
| 204 213 | 
             
            - lib/vis/source/img/network/zoomExtends.png
         | 
| 205 214 | 
             
            - lib/vis/source/vis.css
         | 
| 206 215 | 
             
            - lib/vis/source/vis.js
         | 
| 216 | 
            +
            - lib/vis/timeline.rb
         | 
| 207 217 | 
             
            - lib/vis/utilities.rb
         | 
| 208 218 | 
             
            - spec/spec_helper.rb
         | 
| 209 219 | 
             
            - spec/test_app/.gitignore
         | 
| @@ -263,6 +273,7 @@ files: | |
| 263 273 | 
             
            - spec/test_app/config/routes.rb
         | 
| 264 274 | 
             
            - spec/test_app/config/secrets.yml
         | 
| 265 275 | 
             
            - spec/test_app/config/spring.rb
         | 
| 276 | 
            +
            - spec/test_app/db/schema.rb
         | 
| 266 277 | 
             
            - spec/test_app/db/seeds.rb
         | 
| 267 278 | 
             
            - spec/test_app/lib/assets/.keep
         | 
| 268 279 | 
             
            - spec/test_app/lib/tasks/.keep
         | 
| @@ -289,8 +300,14 @@ files: | |
| 289 300 | 
             
            - spec/test_app/vendor/.keep
         | 
| 290 301 | 
             
            - spec/vis_data_set_spec.rb
         | 
| 291 302 | 
             
            - spec/vis_data_view_spec.rb
         | 
| 303 | 
            +
            - spec/vis_graph2d_component_spec.rb
         | 
| 304 | 
            +
            - spec/vis_graph2d_spec.rb
         | 
| 305 | 
            +
            - spec/vis_graph3d_component_spec.rb
         | 
| 306 | 
            +
            - spec/vis_graph3d_spec.rb
         | 
| 292 307 | 
             
            - spec/vis_network_component_spec.rb
         | 
| 293 308 | 
             
            - spec/vis_network_spec.rb
         | 
| 309 | 
            +
            - spec/vis_timeline_component_spec.rb
         | 
| 310 | 
            +
            - spec/vis_timeline_spec.rb
         | 
| 294 311 | 
             
            homepage: https://github.com/janbiedermann/hyper-vis
         | 
| 295 312 | 
             
            licenses: []
         | 
| 296 313 | 
             
            metadata: {}
         | 
| @@ -305,15 +322,15 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 305 322 | 
             
                  version: '0'
         | 
| 306 323 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 307 324 | 
             
              requirements:
         | 
| 308 | 
            -
              - - " | 
| 325 | 
            +
              - - ">="
         | 
| 309 326 | 
             
                - !ruby/object:Gem::Version
         | 
| 310 | 
            -
                  version:  | 
| 327 | 
            +
                  version: '0'
         | 
| 311 328 | 
             
            requirements: []
         | 
| 312 329 | 
             
            rubyforge_project: 
         | 
| 313 330 | 
             
            rubygems_version: 2.7.3
         | 
| 314 331 | 
             
            signing_key: 
         | 
| 315 332 | 
             
            specification_version: 4
         | 
| 316 | 
            -
            summary: Ruby  | 
| 333 | 
            +
            summary: A Opal Ruby wraper for Vis.js with a Ruby-Hyperloop Component.
         | 
| 317 334 | 
             
            test_files:
         | 
| 318 335 | 
             
            - spec/spec_helper.rb
         | 
| 319 336 | 
             
            - spec/test_app/.gitignore
         | 
| @@ -373,6 +390,7 @@ test_files: | |
| 373 390 | 
             
            - spec/test_app/config/routes.rb
         | 
| 374 391 | 
             
            - spec/test_app/config/secrets.yml
         | 
| 375 392 | 
             
            - spec/test_app/config/spring.rb
         | 
| 393 | 
            +
            - spec/test_app/db/schema.rb
         | 
| 376 394 | 
             
            - spec/test_app/db/seeds.rb
         | 
| 377 395 | 
             
            - spec/test_app/lib/assets/.keep
         | 
| 378 396 | 
             
            - spec/test_app/lib/tasks/.keep
         | 
| @@ -399,5 +417,11 @@ test_files: | |
| 399 417 | 
             
            - spec/test_app/vendor/.keep
         | 
| 400 418 | 
             
            - spec/vis_data_set_spec.rb
         | 
| 401 419 | 
             
            - spec/vis_data_view_spec.rb
         | 
| 420 | 
            +
            - spec/vis_graph2d_component_spec.rb
         | 
| 421 | 
            +
            - spec/vis_graph2d_spec.rb
         | 
| 422 | 
            +
            - spec/vis_graph3d_component_spec.rb
         | 
| 423 | 
            +
            - spec/vis_graph3d_spec.rb
         | 
| 402 424 | 
             
            - spec/vis_network_component_spec.rb
         | 
| 403 425 | 
             
            - spec/vis_network_spec.rb
         | 
| 426 | 
            +
            - spec/vis_timeline_component_spec.rb
         | 
| 427 | 
            +
            - spec/vis_timeline_spec.rb
         |