omf_web 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/omf_web_server +18 -0
- data/example/bridge/README.md +7 -0
- data/example/bridge/data_sources/sensor-sqlite.rb +15 -15
- data/example/bridge/htdocs/graph/js/bridge.js +35 -45
- data/example/bridge/htdocs/graph/js/event_line_chart.js +20 -18
- data/example/bridge/htdocs/graph/js/event_table.js +26 -28
- data/example/bridge/viz_server.rb +5 -9
- data/example/demo/demo_viz_server.rb +2 -2
- data/example/demo/widgets/linked_graphs_tab.yaml +9 -32
- data/example/openflow-gec15/code_tab.yaml +7 -12
- data/example/openflow-gec15/dashboard_tab.yaml +11 -12
- data/example/openflow-gec15/exp_source.rb +26 -26
- data/example/openflow-gec15/of_viz_server.rb +7 -7
- data/example/simple/simple.yaml +2 -1
- data/example/simple/simple_dynamic.yaml +1 -1
- data/example/web_rtc/web_rtc.yaml +54 -0
- data/example/web_rtc/webrtc-exp_1381786573.sq3 +0 -0
- data/lib/omf-web/config.ru +1 -1
- data/lib/omf-web/content/content_proxy.rb +2 -2
- data/lib/omf-web/content/file_repository.rb +11 -53
- data/lib/omf-web/content/git_repository.rb +1 -1
- data/lib/omf-web/content/irods_repository.rb +1 -1
- data/lib/omf-web/content/repository.rb +5 -3
- data/lib/omf-web/content/static_repository.rb +25 -11
- data/lib/omf-web/data_source_proxy.rb +3 -3
- data/lib/omf-web/rack/content_handler.rb +2 -2
- data/lib/omf-web/rack/session_authenticator.rb +3 -3
- data/lib/omf-web/rack/tab_mapper.rb +2 -2
- data/lib/omf-web/rack/update_handler.rb +2 -2
- data/lib/omf-web/rack/websocket_handler.rb +3 -3
- data/lib/omf-web/rack/widget_mapper.rb +2 -2
- data/lib/omf-web/session_store.rb +2 -2
- data/lib/omf-web/theme/abstract_page.rb +15 -24
- data/lib/omf-web/theme/bright/code_renderer.rb +24 -30
- data/lib/omf-web/theme/bright/data_renderer.rb +7 -5
- data/lib/omf-web/theme/bright/page.rb +2 -1
- data/lib/omf-web/theme/bright/widget_chrome.rb +16 -14
- data/lib/omf-web/theme.rb +1 -1
- data/lib/omf-web/thin/logging.rb +18 -13
- data/lib/omf-web/thin/runner.rb +2 -2
- data/lib/omf-web/thin/server.rb +105 -27
- data/lib/omf-web/version.rb +1 -1
- data/lib/omf-web/widget/abstract_widget.rb +3 -3
- data/lib/omf-web/widget/data_widget.rb +1 -0
- data/lib/omf-web/widget/text/maruku.rb +1 -1
- data/lib/omf-web/widget.rb +22 -22
- data/lib/omf_web.rb +1 -1
- data/omf_web.gemspec +18 -15
- data/share/htdocs/graph/js/abstract_chart.js +69 -68
- data/share/htdocs/graph/js/abstract_nv_chart.js +35 -33
- data/share/htdocs/graph/js/abstract_widget.js +61 -62
- data/share/htdocs/graph/js/axis.js +30 -25
- data/share/htdocs/graph/js/barchart_brush.js +23 -21
- data/share/htdocs/graph/js/code_mirror.js +35 -33
- data/share/htdocs/graph/js/discrete_bar_chart.js +27 -30
- data/share/htdocs/graph/js/histogram2.js +37 -47
- data/share/htdocs/graph/js/line_chart3.js +36 -30
- data/share/htdocs/graph/js/line_chart_with_focus.js +10 -9
- data/share/htdocs/graph/js/multi_barchart.js +33 -30
- data/share/htdocs/graph/js/network2.js +98 -97
- data/share/htdocs/graph/js/pie_chart2.js +25 -23
- data/share/htdocs/graph/js/scatter_plot.js +38 -36
- data/share/htdocs/graph/js/table2.js +60 -54
- data/share/htdocs/js/app.js +43 -0
- data/share/htdocs/js/{data_source2.js → data_source3.js} +44 -73
- data/share/htdocs/js/data_source_repo.js +42 -0
- data/share/htdocs/require/nv_d3.js +2 -0
- data/share/htdocs/theme/abstract/abstract.js +4 -4
- data/share/htdocs/vendor/VERSION_MAP.yaml +2 -0
- data/share/htdocs/vendor/require-2.1.8/require.js +2053 -0
- data/share/htdocs/vendor/require-2.1.8/require.min.js +36 -0
- data/share/htdocs/vendor/require-css-0.0.7/.gitignore +1 -0
- data/share/htdocs/vendor/require-css-0.0.7/LICENSE +10 -0
- data/share/htdocs/vendor/require-css-0.0.7/README.md +231 -0
- data/share/htdocs/vendor/require-css-0.0.7/bower.json +5 -0
- data/share/htdocs/vendor/require-css-0.0.7/css-builder.js +251 -0
- data/share/htdocs/vendor/require-css-0.0.7/css.js +436 -0
- data/share/htdocs/vendor/require-css-0.0.7/normalize.js +138 -0
- data/share/htdocs/vendor/require-css-0.0.7/package.json +5 -0
- data/share/htdocs/vendor/spin/jquery.spin.js +6 -4
- metadata +100 -74
- checksums.yaml +0 -7
- data/bin/omf_web_demo +0 -3
- data/bin/omf_web_demo.sh +0 -7
- data/bin/omf_web_server.rb +0 -157
- data/lib/omf_common/lobject.rb +0 -187
- data/lib/omf_common/log4r_outputter.rb +0 -69
- data/sample.sq3 +0 -0
- data/share/htdocs/js/data_source.js +0 -173
- data/share/htdocs/js/require3.js +0 -292
@@ -1,46 +1,45 @@
|
|
1
|
-
L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], function () {
|
2
1
|
|
2
|
+
define(["graph/abstract_chart"], function (abstract_chart) {
|
3
3
|
|
4
|
-
|
5
|
-
OML.network2 = OML.abstract_chart.extend({
|
4
|
+
var network2 = abstract_chart.extend({
|
6
5
|
decl_properties: {
|
7
|
-
nodes: [['key', 'key', {property: 'id'}],
|
8
|
-
['radius', 'int', 30],
|
9
|
-
['fill_color', 'color', 'blue'],
|
10
|
-
['stroke_width', 'int', 1],
|
11
|
-
['stroke_color', 'color', 'black'],
|
6
|
+
nodes: [['key', 'key', {property: 'id'}],
|
7
|
+
['radius', 'int', 30],
|
8
|
+
['fill_color', 'color', 'blue'],
|
9
|
+
['stroke_width', 'int', 1],
|
10
|
+
['stroke_color', 'color', 'black'],
|
12
11
|
['x', 'int', 10],
|
13
12
|
['y', 'int', 10],
|
14
|
-
['label_text', 'key', {property: 'name'}],
|
15
|
-
['label_font', 'string', null],
|
16
|
-
['label_size', 'int', 16],
|
17
|
-
['label_color', 'color', 'white'],
|
18
|
-
|
13
|
+
['label_text', 'key', {property: 'name'}],
|
14
|
+
['label_font', 'string', null],
|
15
|
+
['label_size', 'int', 16],
|
16
|
+
['label_color', 'color', 'white'],
|
17
|
+
|
19
18
|
],
|
20
|
-
links: [['key', 'key', {property: 'id'}],
|
21
|
-
['stroke_width', 'int', 2],
|
19
|
+
links: [['key', 'key', {property: 'id'}],
|
20
|
+
['stroke_width', 'int', 2],
|
22
21
|
['stroke_color', 'color', 'black'],
|
23
22
|
['stroke_fill', 'color', 'blue'],
|
24
|
-
['from', 'index', {key: 'from_id', join_stream: 'nodes', join_key: 'id'}],
|
23
|
+
['from', 'index', {key: 'from_id', join_stream: 'nodes', join_key: 'id'}],
|
25
24
|
['to', 'index', {key: 'to_id', join_stream: 'nodes'}] // join_key: 'id' ... default
|
26
25
|
]
|
27
26
|
},
|
28
|
-
|
27
|
+
|
29
28
|
defaults: function() {
|
30
29
|
return this.deep_defaults({
|
31
30
|
interaction_mode: 'none', // none, hover, click
|
32
|
-
},
|
33
|
-
},
|
34
|
-
|
31
|
+
}, network2.__super__.defaults.call(this));
|
32
|
+
},
|
33
|
+
|
35
34
|
configure_base_layer: function(vis) {
|
36
35
|
var ca = this.widget_area;
|
37
|
-
|
36
|
+
|
38
37
|
this.graph_layer = vis.append("svg:g")
|
39
38
|
.attr("transform", "translate(0, " + ca.h + ")")
|
40
39
|
;
|
41
40
|
this.legend_layer = vis.append("svg:g");
|
42
41
|
},
|
43
|
-
|
42
|
+
|
44
43
|
base_css_class: 'oml-network',
|
45
44
|
|
46
45
|
// Find the appropriate data source and bind to it
|
@@ -49,12 +48,12 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
49
48
|
var o = this.opts;
|
50
49
|
var sources = o.data_sources;
|
51
50
|
var self = this;
|
52
|
-
|
51
|
+
|
53
52
|
if (! (sources instanceof Array)) {
|
54
|
-
throw "Expected an array"
|
53
|
+
throw "Expected an array";
|
55
54
|
}
|
56
55
|
if (sources.length == 1) {
|
57
|
-
// Check if the source name is 'default' and we can find
|
56
|
+
// Check if the source name is 'default' and we can find
|
58
57
|
// a _links and _nodes source
|
59
58
|
var s = sources[0];
|
60
59
|
if (s.name == 'default') {
|
@@ -69,11 +68,11 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
69
68
|
sources = [
|
70
69
|
{name: 'nodes', stream: sn},
|
71
70
|
{name: 'links', stream: sl},
|
72
|
-
]
|
71
|
+
];
|
73
72
|
}
|
74
73
|
}
|
75
74
|
if (sources.length != 2) {
|
76
|
-
throw "Expected TWO data source, one for nodes and one for links"
|
75
|
+
throw "Expected TWO data source, one for nodes and one for links";
|
77
76
|
}
|
78
77
|
var dsh = this.data_source = {};
|
79
78
|
_.map(sources, function(s) {
|
@@ -88,8 +87,8 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
88
87
|
this.schema = {
|
89
88
|
nodes: this.process_single_schema(this.data_source.nodes),
|
90
89
|
links: this.process_single_schema(this.data_source.links)
|
91
|
-
};
|
92
|
-
|
90
|
+
};
|
91
|
+
|
93
92
|
var om = this.opts.mapping;
|
94
93
|
if (om.links == undefined || om.nodes == undefined) {
|
95
94
|
throw "Missing mapping instructions in 'options' for either 'links' or 'nodes', or both.";
|
@@ -97,25 +96,25 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
97
96
|
this.mapping = {
|
98
97
|
nodes: this.process_single_mapping('nodes', om.nodes, this.decl_properties.nodes),
|
99
98
|
links: this.process_single_mapping('links', om.links, this.decl_properties.links)
|
100
|
-
};
|
99
|
+
};
|
101
100
|
},
|
102
|
-
|
101
|
+
|
103
102
|
/*
|
104
103
|
* Return schema for +stream+.
|
105
104
|
*/
|
106
105
|
schema_for_stream: function(stream) {
|
107
106
|
var schema = this.schema[stream];
|
108
107
|
return schema;
|
109
|
-
},
|
110
|
-
|
108
|
+
},
|
109
|
+
|
111
110
|
data_source_for_stream: function(stream) {
|
112
111
|
var ds = this.data_source[stream];
|
113
112
|
if (ds == undefined) {
|
114
113
|
throw "Unknown data_source '" + stream + "'.";
|
115
114
|
}
|
116
115
|
return ds;
|
117
|
-
},
|
118
|
-
|
116
|
+
},
|
117
|
+
|
119
118
|
update: function() {
|
120
119
|
|
121
120
|
var ldata = this.data_source.links.rows();
|
@@ -123,13 +122,13 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
123
122
|
|
124
123
|
this.redraw({links: ldata, nodes: ndata});
|
125
124
|
},
|
126
|
-
|
125
|
+
|
127
126
|
redraw: function(data) {
|
128
127
|
var self = this;
|
129
128
|
var o = this.opts;
|
130
129
|
var mapping = this.mapping; //o.mapping || {};
|
131
130
|
var ca = this.widget_area;
|
132
|
-
|
131
|
+
|
133
132
|
var x = function(v) {
|
134
133
|
var x = v * ca.w + ca.x;
|
135
134
|
var x = v * ca.w;
|
@@ -137,10 +136,10 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
137
136
|
};
|
138
137
|
var y = function(v) {
|
139
138
|
var y = -1 * (v * ca.h + ca.y);
|
140
|
-
var y = -1 * (v * ca.h);
|
139
|
+
var y = -1 * (v * ca.h);
|
141
140
|
return y;
|
142
141
|
};
|
143
|
-
|
142
|
+
|
144
143
|
var vis = this.base_layer;
|
145
144
|
var lmapping = mapping.links;
|
146
145
|
var nmapping = mapping.nodes;
|
@@ -151,13 +150,13 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
151
150
|
var a = 0.2;
|
152
151
|
var b = 0.3;
|
153
152
|
var o = 30;
|
154
|
-
|
153
|
+
|
155
154
|
var from = lmapping.from(d);
|
156
155
|
var to = lmapping.to(d);
|
157
156
|
|
158
|
-
var x1 = x(nmapping.x(from));
|
157
|
+
var x1 = x(nmapping.x(from));
|
159
158
|
var y1 = y(nmapping.y(from));
|
160
|
-
var x3 = x(nmapping.x(to));
|
159
|
+
var x3 = x(nmapping.x(to));
|
161
160
|
var y3 = y(nmapping.y(to));
|
162
161
|
|
163
162
|
var dx = x3 - x1;
|
@@ -166,13 +165,13 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
166
165
|
|
167
166
|
var mx = x1 + a * dx;
|
168
167
|
var my = y1 + a * dy;
|
169
|
-
var x2 = mx - (dy * o / l)
|
170
|
-
var y2 = my + (dx * o / l);
|
168
|
+
var x2 = mx - (dy * o / l);
|
169
|
+
var y2 = my + (dx * o / l);
|
171
170
|
|
172
171
|
return iline_f([[x1, y1], [x2, y2], [x3, y3]]);
|
173
172
|
};
|
174
173
|
|
175
|
-
var ldata = data.links
|
174
|
+
var ldata = data.links;
|
176
175
|
var link2 = this.graph_layer.selectAll("path.link")
|
177
176
|
.data(d3.values(ldata));
|
178
177
|
link2
|
@@ -185,38 +184,38 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
185
184
|
le.attr("class", "link")
|
186
185
|
.style("stroke", lmapping.stroke_color)
|
187
186
|
.style("stroke-width", lmapping.stroke_width)
|
188
|
-
.attr("fill", "none")
|
187
|
+
.attr("fill", "none")
|
189
188
|
.attr("d", line_f)
|
190
189
|
;
|
191
190
|
this._set_link_interaction_mode(le);
|
192
|
-
|
191
|
+
|
193
192
|
|
194
193
|
var ndata = data.nodes;
|
195
194
|
// first draw white circle to allow actual node to become transparent
|
196
195
|
// without links showing through
|
197
196
|
var bg_node = this.graph_layer.selectAll("circle.bg_node")
|
198
197
|
.data(ndata, function(d) { return nmapping.key(d); })
|
199
|
-
.attr("cx", function(d) { return x(nmapping.x(d)) })
|
200
|
-
.attr("cy", function(d) { return y(nmapping.y(d)) })
|
198
|
+
.attr("cx", function(d) { return x(nmapping.x(d)); })
|
199
|
+
.attr("cy", function(d) { return y(nmapping.y(d)); })
|
201
200
|
.attr("r", nmapping.radius)
|
202
201
|
.style("fill", 'white')
|
203
202
|
.enter().append("svg:circle")
|
204
203
|
.attr("class", "bg_node")
|
205
|
-
.attr("cx", function(d) { return x(nmapping.x(d)) })
|
206
|
-
.attr("cy", function(d) { return y(nmapping.y(d)) })
|
204
|
+
.attr("cx", function(d) { return x(nmapping.x(d)); })
|
205
|
+
.attr("cy", function(d) { return y(nmapping.y(d)); })
|
207
206
|
.attr("r", nmapping.radius)
|
208
207
|
.style("fill", 'white');
|
209
208
|
;
|
210
209
|
|
211
|
-
|
210
|
+
|
212
211
|
function node_f(sel) {
|
213
|
-
sel.attr("cx", function(d) { return x(nmapping.x(d)) })
|
214
|
-
.attr("cy", function(d) { return y(nmapping.y(d)) })
|
212
|
+
sel.attr("cx", function(d) { return x(nmapping.x(d)); })
|
213
|
+
.attr("cy", function(d) { return y(nmapping.y(d)); })
|
215
214
|
.attr("r", nmapping.radius)
|
216
215
|
.style("fill", nmapping.fill_color)
|
217
216
|
.style("stroke", nmapping.stroke_color)
|
218
217
|
.style("stroke-width", nmapping.stroke_width)
|
219
|
-
;
|
218
|
+
;
|
220
219
|
}
|
221
220
|
var node = this.graph_layer.selectAll("circle.node")
|
222
221
|
.data(ndata, function(d) {
|
@@ -234,8 +233,8 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
234
233
|
// ;
|
235
234
|
var en = node.enter().append("svg:circle");
|
236
235
|
en.attr("class", "node")
|
237
|
-
.attr("cx", function(d) { return x(nmapping.x(d)) })
|
238
|
-
.attr("cy", function(d) { return y(nmapping.y(d)) })
|
236
|
+
.attr("cx", function(d) { return x(nmapping.x(d)); })
|
237
|
+
.attr("cy", function(d) { return y(nmapping.y(d)); })
|
239
238
|
.attr("r", nmapping.radius)
|
240
239
|
.style("fill", nmapping.fill_color)
|
241
240
|
.style("stroke", nmapping.stroke_color)
|
@@ -246,17 +245,17 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
246
245
|
.delay(0)
|
247
246
|
;
|
248
247
|
this._set_node_interaction_mode(node);
|
249
|
-
|
248
|
+
|
250
249
|
function label_f(sel) {
|
251
250
|
sel.attr("class", "node_label")
|
252
251
|
.attr('dy', '0.4em')
|
253
|
-
.attr("x", function(d) { return x(nmapping.x(d)) })
|
254
|
-
.attr("y", function(d) { return y(nmapping.y(d)) })
|
252
|
+
.attr("x", function(d) { return x(nmapping.x(d)); })
|
253
|
+
.attr("y", function(d) { return y(nmapping.y(d)); })
|
255
254
|
.attr('text-anchor', 'middle')
|
256
255
|
.style("fill", nmapping.label_color)
|
257
|
-
.style("font-size", nmapping.label_size)
|
256
|
+
.style("font-size", nmapping.label_size)
|
258
257
|
.text(function(d) { return nmapping.label_text(d); });
|
259
|
-
}
|
258
|
+
}
|
260
259
|
var label = this.graph_layer.selectAll("text.node_label")
|
261
260
|
.data(ndata, function(d) {
|
262
261
|
return nmapping.key(d);
|
@@ -265,7 +264,7 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
265
264
|
label.enter().append("svg:text").call(label_f);
|
266
265
|
|
267
266
|
},
|
268
|
-
|
267
|
+
|
269
268
|
_set_link_interaction_mode: function(le) {
|
270
269
|
var self = this;
|
271
270
|
var o = this.opts;
|
@@ -276,9 +275,9 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
276
275
|
})
|
277
276
|
.on("mouseout", function(d) {
|
278
277
|
self._on_link_selected(d);
|
279
|
-
})
|
278
|
+
})
|
280
279
|
;
|
281
|
-
} else if (o.interaction_mode == 'click') {
|
280
|
+
} else if (o.interaction_mode == 'click') {
|
282
281
|
le.on("click", function(d) {
|
283
282
|
self._on_link_selected(d);
|
284
283
|
})
|
@@ -286,33 +285,33 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
286
285
|
;
|
287
286
|
}
|
288
287
|
},
|
289
|
-
|
288
|
+
|
290
289
|
_on_link_selected: function(d) {
|
291
290
|
var key_f = this.mapping.links.key;
|
292
|
-
var id = key_f(d);
|
291
|
+
var id = key_f(d);
|
293
292
|
var msg = {id: id, type: 'link', source: this, data_source: this.data_source.links};
|
294
293
|
|
295
294
|
if (this.selected_link == id) {
|
296
295
|
// if same link is clicked twice, unselect it
|
297
|
-
this._render_selected_link(null);
|
296
|
+
this._render_selected_link(null);
|
298
297
|
this._render_selected_node(null);
|
299
298
|
} else {
|
300
|
-
this._render_selected_link(id);
|
299
|
+
this._render_selected_link(id);
|
301
300
|
this._render_selected_node('_NONE_');
|
302
301
|
this._report_selected(id, 'links', d);
|
303
302
|
}
|
304
303
|
},
|
305
|
-
|
304
|
+
|
306
305
|
// Make all but 'selected_id' link semi-transparent. If 'selected_id' is null
|
307
306
|
// revert selection.
|
308
307
|
//
|
309
308
|
_render_selected_link: function(selected_id) {
|
310
309
|
if (selected_id == null || selected_id == '_NONE_') {
|
311
310
|
if (this.selected_link) {
|
312
|
-
this._report_deselected(this.selected_link, 'links');
|
311
|
+
this._report_deselected(this.selected_link, 'links');
|
313
312
|
this.selected_link = null;
|
314
313
|
}
|
315
|
-
} else {
|
314
|
+
} else {
|
316
315
|
this.selected_link = selected_id;
|
317
316
|
}
|
318
317
|
|
@@ -339,57 +338,57 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
339
338
|
.style("opacity", 1.0)
|
340
339
|
.delay(0)
|
341
340
|
.duration(300);
|
342
|
-
|
341
|
+
|
343
342
|
},
|
344
343
|
|
345
344
|
_set_node_interaction_mode: function(en) {
|
346
345
|
var self = this;
|
347
346
|
var o = this.opts;
|
348
|
-
|
349
|
-
var msg_frag = {type: 'node', data_source: this.data_source.nodes}
|
347
|
+
|
348
|
+
var msg_frag = {type: 'node', data_source: this.data_source.nodes};
|
350
349
|
if (o.interaction_mode == 'hover') {
|
351
350
|
en.on("mouseover", function(d) {
|
352
351
|
self._on_node_selected(d);
|
353
352
|
})
|
354
353
|
.on("mouseout", function(d) {
|
355
354
|
self._on_node_selected(d);
|
356
|
-
})
|
355
|
+
})
|
357
356
|
;
|
358
|
-
} else if (o.interaction_mode == 'click') {
|
357
|
+
} else if (o.interaction_mode == 'click') {
|
359
358
|
en.on("click", function(d) {
|
360
359
|
self._on_node_selected(d);
|
361
360
|
})
|
362
|
-
.style('cursor', 'hand')
|
361
|
+
.style('cursor', 'hand');
|
363
362
|
}
|
364
|
-
|
363
|
+
|
365
364
|
},
|
366
|
-
|
365
|
+
|
367
366
|
_on_node_selected: function(d) {
|
368
367
|
var key_f = this.mapping.nodes.key;
|
369
|
-
var id = key_f(d);
|
368
|
+
var id = key_f(d);
|
370
369
|
//var msg = {id: id, type: 'node', source: this, data_source: this.data_source.nodes};
|
371
370
|
|
372
371
|
if (this.selected_node == id) {
|
373
372
|
// if same link is clicked twice, unselect it
|
374
|
-
this._render_selected_link(null);
|
373
|
+
this._render_selected_link(null);
|
375
374
|
this._render_selected_node(null);
|
376
375
|
} else {
|
377
|
-
this._render_selected_link('_NONE_');
|
376
|
+
this._render_selected_link('_NONE_');
|
378
377
|
this._render_selected_node(id);
|
379
378
|
this._report_selected(id, 'nodes', d);
|
380
379
|
}
|
381
380
|
},
|
382
|
-
|
381
|
+
|
383
382
|
// Make all but 'selected_id' node semi-transparent. If 'selected_id' is null
|
384
383
|
// revert selection.
|
385
384
|
//
|
386
385
|
_render_selected_node: function(selected_id) {
|
387
386
|
if (selected_id == null || selected_id == '_NONE_') {
|
388
387
|
if (this.selected_node) {
|
389
|
-
this._report_deselected(this.selected_node, 'nodes');
|
388
|
+
this._report_deselected(this.selected_node, 'nodes');
|
390
389
|
this.selected_node = null;
|
391
390
|
}
|
392
|
-
} else {
|
391
|
+
} else {
|
393
392
|
this.selected_node = selected_id;
|
394
393
|
}
|
395
394
|
var key_f = this.mapping.nodes.key;
|
@@ -415,25 +414,27 @@ L.provide('OML.network2', ["graph/js/abstract_chart", "#OML.abstract_chart"], fu
|
|
415
414
|
.style("opacity", 1.0)
|
416
415
|
.delay(0)
|
417
416
|
.duration(300);
|
418
|
-
|
417
|
+
|
419
418
|
},
|
420
|
-
|
419
|
+
|
421
420
|
_report_selected: function(selected_id, type, datum) {
|
422
421
|
var ds = this.data_source[type];
|
423
422
|
var msg = {id: selected_id, type: type, source: this, data_source: ds, datum: datum};
|
424
|
-
OHUB.trigger("graph.selected", msg);
|
425
|
-
OHUB.trigger("graph." + ds.name + ".selected", msg);
|
426
|
-
},
|
423
|
+
OHUB.trigger("graph.selected", msg);
|
424
|
+
OHUB.trigger("graph." + ds.name + ".selected", msg);
|
425
|
+
},
|
427
426
|
|
428
427
|
_report_deselected: function(selected_id, type, datum) {
|
429
428
|
var ds = this.data_source[type];
|
430
429
|
var msg = {id: selected_id, type: type, source: this, data_source: ds, datum: datum};
|
431
|
-
OHUB.trigger("graph.deselected", msg);
|
432
|
-
OHUB.trigger("graph." + ds.name + ".deselected", msg);
|
433
|
-
}
|
434
|
-
|
435
|
-
})
|
436
|
-
|
430
|
+
OHUB.trigger("graph.deselected", msg);
|
431
|
+
OHUB.trigger("graph." + ds.name + ".deselected", msg);
|
432
|
+
}
|
433
|
+
|
434
|
+
});
|
435
|
+
|
436
|
+
return network2;
|
437
|
+
});
|
437
438
|
|
438
439
|
/*
|
439
440
|
Local Variables:
|
@@ -1,71 +1,73 @@
|
|
1
|
-
|
1
|
+
define(["graph/abstract_nv_chart"], function (abstract_nv_chart) {
|
2
2
|
|
3
|
-
|
3
|
+
var pie_chart2 = abstract_nv_chart.extend({
|
4
4
|
decl_properties: [
|
5
|
-
['label', 'key', {property: 'label'}],
|
5
|
+
['label', 'key', {property: 'label'}],
|
6
6
|
['value', 'key', {property: 'value'}],
|
7
7
|
['color', 'color', 'category10()'],
|
8
|
-
|
8
|
+
|
9
9
|
],
|
10
|
-
|
10
|
+
|
11
11
|
defaults: function() {
|
12
12
|
return this.deep_defaults({
|
13
13
|
tooltips: true,
|
14
14
|
show_labels: true,
|
15
15
|
donut: false,
|
16
|
-
label_threshold: 0.02, //if slice percentage is under this, don't show label
|
16
|
+
label_threshold: 0.02, //if slice percentage is under this, don't show label
|
17
17
|
show_legend: true,
|
18
|
-
|
18
|
+
|
19
19
|
margin: {
|
20
|
-
top: 20, right: 0, bottom: 100, left: 50
|
21
|
-
}
|
22
|
-
},
|
20
|
+
top: 20, right: 0, bottom: 100, left: 50
|
21
|
+
}
|
22
|
+
}, pie_chart2.__super__.defaults.call(this));
|
23
23
|
},
|
24
24
|
|
25
25
|
_create_model: function() {
|
26
|
-
return nv.models.pieChart();
|
26
|
+
return nv.models.pieChart();
|
27
27
|
},
|
28
|
-
|
28
|
+
|
29
29
|
_configure_mapping: function(m, chart) {
|
30
30
|
var label_f = m.label;
|
31
31
|
var value_f = m.value;
|
32
32
|
chart.x(function(d) {
|
33
|
-
var v = label_f(d);
|
33
|
+
var v = label_f(d);
|
34
34
|
return v;
|
35
|
-
})
|
35
|
+
});
|
36
36
|
chart.y(function(d) {
|
37
37
|
var v = value_f(d);
|
38
38
|
return v;
|
39
|
-
})
|
39
|
+
});
|
40
40
|
chart.color(function(d, i) {
|
41
41
|
// TODO: This is most likely broken. The color mapping
|
42
42
|
// function should map from an element of 'd', not 'i'
|
43
43
|
var v = m.color(i);
|
44
44
|
return v;
|
45
|
-
})
|
45
|
+
});
|
46
46
|
},
|
47
|
-
|
47
|
+
|
48
48
|
_configure_options: function(opts, chart) {
|
49
|
-
|
49
|
+
pie_chart2.__super__._configure_options.call(this, opts, chart);
|
50
50
|
chart
|
51
51
|
.tooltips(opts.tooltips)
|
52
52
|
.showLabels(opts.show_labels)
|
53
53
|
.donut(opts.donut)
|
54
54
|
.labelThreshold(opts.label_threshold)
|
55
|
-
.showLegend(opts.show_legend)
|
55
|
+
.showLegend(opts.show_legend)
|
56
56
|
.margin(opts.margin)
|
57
57
|
;
|
58
58
|
},
|
59
|
-
|
59
|
+
|
60
60
|
_datum: function(data, chart) {
|
61
61
|
return [{
|
62
62
|
key: "???",
|
63
63
|
values: data
|
64
64
|
}];
|
65
65
|
}
|
66
|
-
|
67
|
-
})
|
68
|
-
|
66
|
+
|
67
|
+
});
|
68
|
+
|
69
|
+
return pie_chart2;
|
70
|
+
});
|
69
71
|
|
70
72
|
/*
|
71
73
|
Local Variables:
|