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.
@@ -16,6 +16,10 @@ module Vis
16
16
  @native.JS.call(js_name, options_to_native(options))
17
17
  end
18
18
  end
19
+
20
+ def test_container
21
+ `document.body.appendChild(document.createElement('div'))`
22
+ end
19
23
  end
20
24
 
21
25
  def hash_array_to_native(array)
@@ -33,208 +37,12 @@ module Vis
33
37
  end
34
38
 
35
39
  def lower_camelize_hash(hash)
36
- camel_options = {}
40
+ camel_hash = {}
37
41
  hash.each do |key, value|
38
42
  value = lower_camelize_hash(value) if `Opal.is_a(value, Opal.Hash)`
39
- camel_options[lower_camelize(key)] = value
40
- end
41
- camel_options
42
- end
43
-
44
- def options_to_native(options)
45
- return unless options
46
- # options must be duplicated, so callbacks dont get wrapped twice
47
- new_opts = {}.merge!(options)
48
- _rubyfy_configure_options(new_opts) if new_opts.has_key?(:configure)
49
- _rubyfy_edges_options(new_opts) if new_opts.has_key?(:edges)
50
- _rubyfy_manipulation_options(new_opts) if new_opts.has_key?(:manipulation)
51
- _rubyfy_nodes_options(new_opts) if new_opts.has_key?(:nodes)
52
-
53
- if new_opts.has_key?(:join_condition)
54
- block = new_opts[:join_condition]
55
- if `typeof block === "function"`
56
- unless new_opts[:join_condition].JS[:hyper_wrapped]
57
- new_opts[:join_condition] = %x{
58
- function(node_options, child_options) {
59
- if (child_options !== undefined && child_options !== null) {
60
- return #{block.call(`Opal.Hash.$new(node_options)`, `Opal.Hash.$new(child_options)`)};
61
- } else {
62
- return #{block.call(`Opal.Hash.$new(node_options)`)};
63
- }
64
- }
65
- }
66
- new_opts[:join_condition].JS[:hyper_wrapped] = true
67
- end
68
- end
69
- end
70
-
71
- if new_opts.has_key?(:process_properties)
72
- block = new_opts[:process_properties]
73
- if `typeof block === "function"`
74
- unless new_opts[:process_properties].JS[:hyper_wrapped]
75
- new_opts[:process_properties] = %x{
76
- function(item) {
77
- var res = #{block.call(`Opal.Hash.$new(item)`)};
78
- return res.$to_n();
79
- }
80
- }
81
- new_opts[:process_properties].JS[:hyper_wrapped] = true
82
- end
83
- end
84
- end
85
-
86
- if new_opts.has_key?(:filter)
87
- block = new_opts[:filter]
88
- if `typeof block === "function"`
89
- unless new_opts[:filter].JS[:hyper_wrapped]
90
- new_opts[:filter] = %x{
91
- function(item) {
92
- return #{block.call(`Opal.Hash.$new(item)`)};
93
- }
94
- }
95
- new_opts[:filter].JS[:hyper_wrapped] = true
96
- end
97
- end
98
- end
99
-
100
- lower_camelize_hash(new_opts).to_n
101
- end
102
-
103
- def _rubyfy_configure_options(options)
104
- if options[:configure].has_key?(:filter)
105
- block = options[:configure][:filter]
106
- if `typeof block === "function"`
107
- unless options[:configure][:filter].JS[:hyper_wrapped]
108
- options[:configure][:filter] = %x{
109
- function(option, path) {
110
- return #{block.call(`Opal.Hash.$new(options)`, `path`)};
111
- }
112
- }
113
- options[:configure][:filter].JS[:hyper_wrapped] = true
114
- end
115
- end
116
- end
117
- end
118
-
119
- def _rubyfy_edges_options(options)
120
- if options[:edges].has_key?(:chosen)
121
- chosen = options[:edges][:chosen]
122
- [:edge, :label].each do |key|
123
- if chosen.has_key?(key)
124
- block = chosen[key]
125
- if `typeof block === "function"`
126
- unless options[:edges][:chosen][key].JS[:hyper_wrapped]
127
- options[:edges][:chosen][key] = %x{
128
- function(values, id, selected, hovering) {
129
- return #{block.call(`Opal.Hash.$new(values)`, `id`, `selected`, `hovering`)};
130
- }
131
- }
132
- options[:edges][:chosen][key].JS[:hyper_wrapped] = true
133
- end
134
- end
135
- end
136
- end
137
- end
138
- [:hover_width, :selection_width].each do |key|
139
- if options[:edges].has_key?(key)
140
- block = options[:edges][key]
141
- if `typeof block === "function"`
142
- unless options[:edges][key].JS[:hyper_wrapped]
143
- options[:edges][key] = %x{
144
- function(width) {
145
- return #{block.call(`width`)};
146
- }
147
- }
148
- options[:edges][key].JS[:hyper_wrapped] = true
149
- end
150
- end
151
- end
152
- end
153
- if options[:edges].has_key?(:scaling)
154
- if options[:edges][:scaling].has_key?(:custom_scaling_function)
155
- block = options[:edges][:scaling][:custom_scaling_function]
156
- if `typeof block === "function"`
157
- unless options[:edges][:scaling][:custom_scaling_function].JS[:hyper_wrapped]
158
- options[:edges][:scaling][:custom_scaling_function] = %x{
159
- function(min, max, total, value) {
160
- return #{block.call(`min`, `max`, `total`, `value`)};
161
- }
162
- }
163
- options[:edges][:scaling][:custom_scaling_function].JS[:hyper_wrapped] = true
164
- end
165
- end
166
- end
167
- end
168
- end
169
-
170
- def _rubyfy_manipulation_options(options)
171
- [:add_edge, :add_node, :edit_edge, :edit_node].each do |key|
172
- next unless options[:manipulation].has_key?(key)
173
- block = options[:manipulation][key]
174
- if `typeof block === "function"`
175
- unless options[:manipulation][key].JS[:hyper_wrapped]
176
- options[:manipulation][key] = %x{
177
- function(nodeData, callback) {
178
- var wrapped_callback = #{ proc { |new_node_data| `callback(new_node_data.$to_n());` }};
179
- block.$call(Opal.Hash.$new(nodeData), wrapped_callback);
180
- }
181
- }
182
- end
183
- options[:manipulation][key].JS[:hyper_wrapped] = true
184
- end
185
- end
186
- # for delete the order of args for the callback is not clear
187
- [:delete_edge, :delete_node].each do |key|
188
- next unless options[:manipulation].has_key?(key)
189
- block = options[:manipulation][key]
190
- if `typeof block === "function"`
191
- unless options[:manipulation][key].JS[:hyper_wrapped]
192
- options[:manipulation][key] = %x{
193
- function(nodeData, callback) {
194
- var wrapped_callback = #{ proc { |new_node_data| `callback(new_node_data.$to_n());` }};
195
- block.$call(Opal.Hash.$new(nodeData), wrapped_callback);
196
- }
197
- }
198
- options[:manipulation][key].JS[:hyper_wrapped] = true
199
- end
200
- end
201
- end
202
- end
203
-
204
- def _rubyfy_nodes_options(options)
205
- if options[:nodes].has_key?(:chosen)
206
- chosen = options[:nodes][:chosen]
207
- [:node, :label].each do |key|
208
- if chosen.has_key?(key)
209
- block = chosen[key]
210
- if `typeof block === "function"`
211
- unless options[:nodes][:chosen][key].JS[:hyper_wrapped]
212
- options[:nodes][:chosen][key] = %x{
213
- function(values, id, selected, hovering) {
214
- return #{block.call(`Opal.Hash.$new(values)`, `id`, `selected`, `hovering`)};
215
- }
216
- }
217
- options[:nodes][:chosen][key].JS[:hyper_wrapped] = true
218
- end
219
- end
220
- end
221
- end
222
- end
223
- if options[:nodes].has_key?(:scaling)
224
- if options[:nodes][:scaling].has_key?(:custom_scaling_function)
225
- block = options[:nodes][:scaling][:custom_scaling_function]
226
- if `typeof block === "function"`
227
- unless options[:nodes][:scaling][:custom_scaling_function].JS[:hyper_wrapped]
228
- options[:nodes][:scaling][:custom_scaling_function] = %x{
229
- function(min, max, total, value) {
230
- return #{block.call(`min`, `max`, `total`, `value`)};
231
- }
232
- }
233
- options[:nodes][:scaling][:custom_scaling_function].JS[:hyper_wrapped] = true
234
- end
235
- end
236
- end
43
+ camel_hash[lower_camelize(key)] = value
237
44
  end
45
+ camel_hash
238
46
  end
239
47
  end
240
48
  end
@@ -14,16 +14,14 @@ gem 'sqlite3'
14
14
  gem 'puma', '~> 3.7'
15
15
 
16
16
  gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: "master"
17
- gem 'hyperloop', '~> 1.0.0.lap23'
17
+ gem 'hyperloop', '~> 1.0.0.lap27'
18
18
  gem 'hyper-vis', path: '../../'
19
19
 
20
20
  # Use Capistrano for deployment
21
21
  # gem 'capistrano-rails', group: :development
22
22
 
23
23
  group :development, :test do
24
- gem 'hyper-spec', '~> 1.0.0.lap23'
25
- # Call 'byebug' anywhere in the code to stop execution and get a debugger console
26
- gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
24
+ gem 'hyper-spec', '~> 1.0.0.lap27'
27
25
  # Adds support for Capybara system testing and selenium driver
28
26
  gem 'capybara', '~> 2.13'
29
27
  gem 'selenium-webdriver'
@@ -12,4 +12,5 @@
12
12
  *
13
13
  *= require_tree .
14
14
  *= require_self
15
- */
15
+ *= require vis.css
16
+ */
@@ -0,0 +1,28 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 0) do
14
+
15
+ create_table "hyperloop_connections", force: :cascade do |t|
16
+ t.string "channel"
17
+ t.string "session"
18
+ t.datetime "created_at"
19
+ t.datetime "expires_at"
20
+ t.datetime "refresh_at"
21
+ end
22
+
23
+ create_table "hyperloop_queued_messages", force: :cascade do |t|
24
+ t.text "data"
25
+ t.integer "connection_id"
26
+ end
27
+
28
+ end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hyperloop::Vis::Graph2d::Component', js: true do
4
+
5
+ it 'creates a component by using the mixin and renders it' do
6
+ mount 'OuterComponent' do
7
+ class VisComponent
8
+ include Hyperloop::Vis::Graph2d::Mixin
9
+
10
+ render_with_dom_node do |dom_node, items|
11
+ net = Vis::Graph2d.new(dom_node, items)
12
+ end
13
+ end
14
+ class OuterComponent < Hyperloop::Component
15
+ render do
16
+ data = Vis::DataSet.new([
17
+ {x: '2014-06-11', y: 10},
18
+ {x: '2014-06-12', y: 25},
19
+ {x: '2014-06-13', y: 30},
20
+ {x: '2014-06-14', y: 10},
21
+ {x: '2014-06-15', y: 15},
22
+ {x: '2014-06-16', y: 30}
23
+ ])
24
+ DIV { VisComponent(items: data) }
25
+ end
26
+ end
27
+ end
28
+ expect(page.body).to include('class="vis-timeline')
29
+ end
30
+
31
+ it 'creates a component by inheriting and renders it' do
32
+ mount 'OuterComponent' do
33
+ class VisComponent < Hyperloop::Vis::Graph2d::Component
34
+ render_with_dom_node do |dom_node, items|
35
+ net = Vis::Graph2d.new(dom_node, items)
36
+ end
37
+ end
38
+ class OuterComponent < Hyperloop::Component
39
+ render do
40
+ data = Vis::DataSet.new([
41
+ {x: '2014-06-11', y: 10},
42
+ {x: '2014-06-12', y: 25},
43
+ {x: '2014-06-13', y: 30},
44
+ {x: '2014-06-14', y: 10},
45
+ {x: '2014-06-15', y: 15},
46
+ {x: '2014-06-16', y: 30}
47
+ ])
48
+ DIV { VisComponent(items: data) }
49
+ end
50
+ end
51
+ end
52
+ expect(page.body).to include('class="vis-timeline')
53
+ end
54
+
55
+ it 'actually passes the params to the component' do
56
+ mount 'OuterComponent' do
57
+ class VisComponent < Hyperloop::Vis::Graph2d::Component
58
+ def self.passed_data
59
+ @@passed_data
60
+ end
61
+ def self.passed_options
62
+ @@passed_options
63
+ end
64
+ render_with_dom_node do |dom_node, items, groups, options|
65
+ @@passed_data = items
66
+ @@passed_options = options
67
+ net = Vis::Graph2d.new(dom_node, items, options)
68
+ end
69
+ end
70
+ class OuterComponent < Hyperloop::Component
71
+ render do
72
+ data = Vis::DataSet.new([
73
+ {x: '2014-06-11', y: 10},
74
+ {x: '2014-06-12', y: 25},
75
+ {x: '2014-06-13', y: 30},
76
+ {x: '2014-06-14', y: 10},
77
+ {x: '2014-06-15', y: 15},
78
+ {x: '2014-06-16', y: 30}
79
+ ])
80
+ options = { align: 'left' }
81
+ DIV { VisComponent(items: data, options: options)}
82
+ end
83
+ end
84
+ end
85
+ expect(page.body).to include('class="vis-timeline')
86
+ expect_evaluate_ruby('VisComponent.passed_data.is_a?(Vis::DataSet)').to eq(true)
87
+ expect_evaluate_ruby('VisComponent.passed_options.has_key?(:align)').to eq(true)
88
+ end
89
+ end
@@ -0,0 +1,304 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Vis::Graph2d', js: true do
4
+
5
+ it 'creates a new Graph' do
6
+ expect_evaluate_ruby do
7
+ items = [
8
+ {x: '2014-06-11', y: 10},
9
+ {x: '2014-06-12', y: 25},
10
+ {x: '2014-06-13', y: 30},
11
+ {x: '2014-06-14', y: 10},
12
+ {x: '2014-06-15', y: 15},
13
+ {x: '2014-06-16', y: 30}
14
+ ]
15
+ options = { start: '2014-06-10', end: '2014-06-18' }
16
+ dataset = Vis::DataSet.new(items)
17
+ dom_node = Vis::Graph2d.test_container
18
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
19
+ [g2d.is_a?(Vis::Graph2d), dom_node.JS[:children].JS[:length]]
20
+ end.to eq([true, 1])
21
+ end
22
+
23
+ it 'creates a new Graph and destroys it' do
24
+ expect_evaluate_ruby do
25
+ items = [
26
+ {x: '2014-06-11', y: 10},
27
+ {x: '2014-06-12', y: 25},
28
+ {x: '2014-06-13', y: 30},
29
+ {x: '2014-06-14', y: 10},
30
+ {x: '2014-06-15', y: 15},
31
+ {x: '2014-06-16', y: 30}
32
+ ]
33
+ options = { start: '2014-06-10', end: '2014-06-18' }
34
+ dataset = Vis::DataSet.new(items)
35
+ dom_node = Vis::Graph2d.test_container
36
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
37
+ created = dom_node.JS[:children].JS[:length]
38
+ g2d.destroy
39
+ [g2d.is_a?(Vis::Graph2d), created, dom_node.JS[:children].JS[:length]]
40
+ end.to eq([true, 1, 0])
41
+ end
42
+
43
+ it 'it can replace the items' do
44
+ expect_evaluate_ruby do
45
+ items = [
46
+ {x: '2014-06-11', y: 10},
47
+ {x: '2014-06-12', y: 25},
48
+ {x: '2014-06-13', y: 30},
49
+ {x: '2014-06-14', y: 10},
50
+ {x: '2014-06-15', y: 15},
51
+ {x: '2014-06-16', y: 30}
52
+ ]
53
+ options = { start: '2014-06-10', end: '2014-06-18' }
54
+ dataset = Vis::DataSet.new(items)
55
+ dom_node = Vis::Graph2d.test_container
56
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
57
+ created = dom_node.JS[:children].JS[:length]
58
+ new_items = [
59
+ {x: '2014-06-12', y: 20},
60
+ {x: '2014-06-13', y: 10},
61
+ {x: '2014-06-14', y: 25},
62
+ {x: '2014-06-15', y: 30},
63
+ {x: '2014-06-16', y: 25},
64
+ {x: '2014-06-17', y: 20}
65
+ ]
66
+ new_dataset = Vis::DataSet.new(new_items)
67
+ g2d.set_items(new_dataset)
68
+ [g2d.is_a?(Vis::Graph2d), created]
69
+ end.to eq([true, 1])
70
+ end
71
+
72
+ it 'it can set options' do
73
+ expect_evaluate_ruby do
74
+ items = [
75
+ {x: '2014-06-11', y: 10},
76
+ {x: '2014-06-12', y: 25},
77
+ {x: '2014-06-13', y: 30},
78
+ {x: '2014-06-14', y: 10},
79
+ {x: '2014-06-15', y: 15},
80
+ {x: '2014-06-16', y: 30}
81
+ ]
82
+ options = { start: '2014-06-10', end: '2014-06-18' }
83
+ dataset = Vis::DataSet.new(items)
84
+ dom_node = Vis::Graph2d.test_container
85
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
86
+ created = dom_node.JS[:children].JS[:length]
87
+ error = false
88
+ begin
89
+ g2d.set_options({
90
+ shaded: { enabled: true },
91
+ graph_height: 200
92
+ })
93
+ rescue
94
+ error = true
95
+ end
96
+ [g2d.is_a?(Vis::Graph2d), created, error]
97
+ end.to eq([true, 1, false])
98
+ end
99
+
100
+ it 'it can set and remove a event listener' do
101
+ expect_evaluate_ruby do
102
+ items = [
103
+ {x: '2014-06-11', y: 10},
104
+ {x: '2014-06-12', y: 25},
105
+ {x: '2014-06-13', y: 30},
106
+ {x: '2014-06-14', y: 10},
107
+ {x: '2014-06-15', y: 15},
108
+ {x: '2014-06-16', y: 30}
109
+ ]
110
+ options = { start: '2014-06-10', end: '2014-06-18' }
111
+ dataset = Vis::DataSet.new(items)
112
+ dom_node = Vis::Graph2d.test_container
113
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
114
+ created = dom_node.JS[:children].JS[:length]
115
+ received = []
116
+ handler_id = g2d.on(:changed) do
117
+ received << 1
118
+ end
119
+ new_items = [
120
+ {x: '2014-06-12', y: 20},
121
+ {x: '2014-06-13', y: 10},
122
+ {x: '2014-06-14', y: 25},
123
+ {x: '2014-06-15', y: 30},
124
+ {x: '2014-06-16', y: 25},
125
+ {x: '2014-06-17', y: 20}
126
+ ]
127
+ new_dataset = Vis::DataSet.new(new_items)
128
+ g2d.set_items(new_dataset)
129
+ g2d.off(:changed, handler_id)
130
+ g2d.set_items(dataset)
131
+ [g2d.is_a?(Vis::Graph2d), created, received.size]
132
+ end.to eq([true, 1, 2])
133
+ end
134
+
135
+ it 'can call redraw' do
136
+ expect_evaluate_ruby do
137
+ items = [
138
+ {x: '2014-06-11', y: 10},
139
+ {x: '2014-06-12', y: 25},
140
+ {x: '2014-06-13', y: 30},
141
+ {x: '2014-06-14', y: 10},
142
+ {x: '2014-06-15', y: 15},
143
+ {x: '2014-06-16', y: 30}
144
+ ]
145
+ options = { start: '2014-06-10', end: '2014-06-18' }
146
+ dataset = Vis::DataSet.new(items)
147
+ dom_node = Vis::Graph2d.test_container
148
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
149
+ created = dom_node.JS[:children].JS[:length]
150
+ g2d.redraw
151
+ redrawn = dom_node.JS[:children].JS[:length]
152
+ [g2d.is_a?(Vis::Graph2d), created, redrawn]
153
+ end.to eq([true, 1, 1])
154
+ end
155
+
156
+ it 'can call fit' do
157
+ expect_evaluate_ruby do
158
+ items = [
159
+ {x: '2014-06-11', y: 10},
160
+ {x: '2014-06-12', y: 25},
161
+ {x: '2014-06-13', y: 30},
162
+ {x: '2014-06-14', y: 10},
163
+ {x: '2014-06-15', y: 15},
164
+ {x: '2014-06-16', y: 30}
165
+ ]
166
+ options = { start: '2014-06-10', end: '2014-06-18' }
167
+ dataset = Vis::DataSet.new(items)
168
+ dom_node = Vis::Graph2d.test_container
169
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
170
+ created = dom_node.JS[:children].JS[:length]
171
+ g2d.fit
172
+ fitted = dom_node.JS[:children].JS[:length]
173
+ [g2d.is_a?(Vis::Graph2d), created, fitted]
174
+ end.to eq([true, 1, 1])
175
+ end
176
+
177
+ it 'can set and get current time' do
178
+ expect_evaluate_ruby do
179
+ items = [
180
+ {x: '2014-06-11', y: 10},
181
+ {x: '2014-06-12', y: 25},
182
+ {x: '2014-06-13', y: 30},
183
+ {x: '2014-06-14', y: 10},
184
+ {x: '2014-06-15', y: 15},
185
+ {x: '2014-06-16', y: 30}
186
+ ]
187
+ options = { start: '2014-06-10', end: '2014-06-18', show_current_time: true }
188
+ dataset = Vis::DataSet.new(items)
189
+ dom_node = Vis::Graph2d.test_container
190
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
191
+ created = dom_node.JS[:children].JS[:length]
192
+ now = Time.now
193
+ time_get = g2d.get_current_time
194
+ same_get_year = time_get.year == now.year
195
+ g2d.set_current_time(Time.now + 1.year)
196
+ time_set = g2d.get_current_time
197
+ same_set_year = time_set.year == (now + 1.year).year
198
+ [g2d.is_a?(Vis::Graph2d), created, same_get_year, same_set_year]
199
+ end.to eq([true, 1, true, true])
200
+ end
201
+
202
+ it 'can set and get custom time' do
203
+ # option showCustomTime is deprecated in vis, throws error
204
+ expect_evaluate_ruby do
205
+ items = [
206
+ {x: '2014-06-11', y: 10},
207
+ {x: '2014-06-12', y: 25},
208
+ {x: '2014-06-13', y: 30},
209
+ {x: '2014-06-14', y: 10},
210
+ {x: '2014-06-15', y: 15},
211
+ {x: '2014-06-16', y: 30}
212
+ ]
213
+ options = { start: '2014-06-10', end: '2014-06-18' }
214
+ dataset = Vis::DataSet.new(items)
215
+ dom_node = Vis::Graph2d.test_container
216
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
217
+ created = dom_node.JS[:children].JS[:length]
218
+ now = Time.now
219
+ g2d.add_custom_time(now, 'time 1')
220
+ time_get = g2d.get_custom_time('time 1')
221
+ same_get_year = time_get.year == now.year
222
+ g2d.set_custom_time(Time.now + 1.year, 'time 1')
223
+ time_set = g2d.get_custom_time('time 1')
224
+ same_set_year = time_set.year == (now + 1.year).year
225
+ g2d.remove_custom_time('time 1')
226
+ [g2d.is_a?(Vis::Graph2d), created, same_get_year, same_set_year]
227
+ end.to eq([true, 1, true, true])
228
+ end
229
+
230
+ it 'can get the data range' do
231
+ expect_evaluate_ruby do
232
+ items = [
233
+ {x: '2014-06-11', y: 10},
234
+ {x: '2014-06-12', y: 25},
235
+ {x: '2014-06-13', y: 30},
236
+ {x: '2014-06-14', y: 10},
237
+ {x: '2014-06-15', y: 15},
238
+ {x: '2014-06-16', y: 30}
239
+ ]
240
+ options = { start: '2014-06-10', end: '2014-06-18' }
241
+ dataset = Vis::DataSet.new(items)
242
+ dom_node = Vis::Graph2d.test_container
243
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
244
+ created = dom_node.JS[:children].JS[:length]
245
+ data_range = g2d.get_data_range
246
+ min = data_range[:min].strftime('%Y-%m-%d')
247
+ max = data_range[:max].strftime('%Y-%m-%d')
248
+ [g2d.is_a?(Vis::Graph2d), created, min, max]
249
+ end.to eq([true, 1, '2014-06-11', '2014-06-16'])
250
+ end
251
+
252
+ it 'can get and set the window' do
253
+ expect_evaluate_ruby do
254
+ items = [
255
+ {x: '2014-06-11', y: 10},
256
+ {x: '2014-06-12', y: 25},
257
+ {x: '2014-06-13', y: 30},
258
+ {x: '2014-06-14', y: 10},
259
+ {x: '2014-06-15', y: 15},
260
+ {x: '2014-06-16', y: 30}
261
+ ]
262
+ options = { start: '2014-06-10', end: '2014-06-18' }
263
+ dataset = Vis::DataSet.new(items)
264
+ dom_node = Vis::Graph2d.test_container
265
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
266
+ created = dom_node.JS[:children].JS[:length]
267
+ window = g2d.get_window
268
+ gws = window[:start].strftime('%Y-%m-%d')
269
+ gwe = window[:end].strftime('%Y-%m-%d')
270
+ g2d.set_window('2014-06-12', '2014-06-15')
271
+ # window is set, but
272
+ # get_window doesnt work here, gives back the orignal values, but not the current ones
273
+ # window_fc = g2d.get_window
274
+ # sws = window_fc[:start].strftime('%Y-%m-%d')
275
+ # swe = window_fc[:end].strftime('%Y-%m-%d')
276
+ [g2d.is_a?(Vis::Graph2d), created, gws, gwe]
277
+ end.to eq([true, 1, '2014-06-10', '2014-06-18'])
278
+ end
279
+
280
+ it 'can move the window' do
281
+ expect_evaluate_ruby do
282
+ items = [
283
+ {x: '2014-06-11', y: 10},
284
+ {x: '2014-06-12', y: 25},
285
+ {x: '2014-06-13', y: 30},
286
+ {x: '2014-06-14', y: 10},
287
+ {x: '2014-06-15', y: 15},
288
+ {x: '2014-06-16', y: 30}
289
+ ]
290
+ options = { start: '2014-06-10', end: '2014-06-18' }
291
+ dataset = Vis::DataSet.new(items)
292
+ dom_node = Vis::Graph2d.test_container
293
+ g2d = Vis::Graph2d.new(dom_node, dataset, options)
294
+ created = dom_node.JS[:children].JS[:length]
295
+ g2d.move_to('2014-06-12')
296
+ [g2d.is_a?(Vis::Graph2d), created]
297
+ end.to eq([true, 1])
298
+ end
299
+
300
+ xit 'get_event_properties'
301
+ xit 'is_group_visible'
302
+ xit 'set_groups'
303
+ xit 'get_legend'
304
+ end