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,16 +1,12 @@
|
|
1
|
-
// L.provide('OML.discrete_bar_chart', ["graph/abstract_chart", "#OML.abstract_chart", "graph/axis", "#OML.axis", "graph.css",
|
2
|
-
// ["/resource/vendor/d3/d3.js",
|
3
|
-
// "/resource/vendor/nv_d3/js/nv.d3.js",
|
4
|
-
// "/resource/vendor/nv_d3/css/nv.d3.css"
|
5
|
-
// ]], function () {
|
6
|
-
L.provide('OML.discrete_bar_chart', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_chart"], function () {
|
7
1
|
|
8
|
-
|
2
|
+
define(["graph/abstract_nv_chart"], function (abstract_nv_chart) {
|
3
|
+
|
4
|
+
var discrete_bar_chart = abstract_nv_chart.extend({
|
9
5
|
decl_properties: [
|
10
|
-
['label', 'key', {property: 'label'}],
|
11
|
-
['value', 'key', {property: 'value'}],
|
6
|
+
['label', 'key', {property: 'label'}],
|
7
|
+
['value', 'key', {property: 'value'}],
|
12
8
|
],
|
13
|
-
|
9
|
+
|
14
10
|
defaults: function() {
|
15
11
|
return this.deep_defaults({
|
16
12
|
rotate_labels: -45,
|
@@ -18,61 +14,62 @@ L.provide('OML.discrete_bar_chart', ["graph/js/abstract_nv_chart", "#OML.abstrac
|
|
18
14
|
//.staggerLabels(historicalBarChart[0].values.length > 8)
|
19
15
|
tooltips: true,
|
20
16
|
show_values: true,
|
21
|
-
|
22
17
|
margin: {
|
23
|
-
top: 20, right: 0, bottom: 50, left: 80
|
24
|
-
}
|
25
|
-
},
|
18
|
+
top: 20, right: 0, bottom: 50, left: 80
|
19
|
+
}
|
20
|
+
}, discrete_bar_chart.__super__.defaults.call(this));
|
26
21
|
},
|
27
22
|
|
28
23
|
_create_model: function() {
|
29
|
-
return nv.models.discreteBarChart();
|
24
|
+
return nv.models.discreteBarChart();
|
30
25
|
},
|
31
|
-
|
26
|
+
|
32
27
|
_configure_mapping: function(m, chart) {
|
33
28
|
var label_f = m.label;
|
34
29
|
var value_f = m.value;
|
35
30
|
chart.x(function(d) {
|
36
|
-
var v = label_f(d);
|
31
|
+
var v = label_f(d);
|
37
32
|
return v;
|
38
|
-
})
|
33
|
+
});
|
39
34
|
chart.y(function(d) {
|
40
35
|
var v = value_f(d);
|
41
36
|
return v;
|
42
|
-
})
|
37
|
+
});
|
43
38
|
},
|
44
|
-
|
39
|
+
|
45
40
|
_configure_options: function(opts, chart) {
|
46
|
-
|
41
|
+
discrete_bar_chart.__super__._configure_options.call(this, opts, chart);
|
47
42
|
chart
|
48
|
-
|
43
|
+
//.rotateLabels(opts.rotate_labels)
|
49
44
|
.staggerLabels(opts.stagger_labels)
|
50
45
|
.tooltips(opts.tooltips)
|
51
46
|
.showValues(opts.show_values)
|
52
47
|
.margin(opts.margin)
|
53
48
|
;
|
54
|
-
this._configure_all_axis(opts, chart)
|
49
|
+
this._configure_all_axis(opts, chart);
|
55
50
|
},
|
56
|
-
|
51
|
+
|
57
52
|
_configure_all_axis: function(opts, chart) {
|
58
53
|
var oaxis = opts.axis || {};
|
59
54
|
var a_defaults = this.axis_defaults;
|
60
|
-
|
55
|
+
|
61
56
|
// var xao = _.defaults(oaxis.x || {}, a_defaults);
|
62
57
|
// this._configure_axis('x', chart.xAxis, xao);
|
63
58
|
var yao = _.defaults(oaxis.y || {}, a_defaults);
|
64
59
|
this._configure_axis('y', chart.yAxis, yao);
|
65
60
|
},
|
66
|
-
|
61
|
+
|
67
62
|
_datum: function(data, chart) {
|
68
63
|
return [{
|
69
64
|
key: "???",
|
70
65
|
values: data
|
71
66
|
}];
|
72
|
-
}
|
73
|
-
|
74
|
-
})
|
75
|
-
|
67
|
+
}
|
68
|
+
|
69
|
+
});
|
70
|
+
|
71
|
+
return discrete_bar_chart;
|
72
|
+
});
|
76
73
|
|
77
74
|
/*
|
78
75
|
Local Variables:
|
@@ -1,84 +1,72 @@
|
|
1
|
-
|
1
|
+
define(["graph/abstract_nv_chart"], function (abstract_nv_chart) {
|
2
2
|
|
3
|
-
|
3
|
+
var histogram2 = abstract_nv_chart.extend({
|
4
4
|
decl_properties: [
|
5
|
-
['value', 'key', {property: 'value'}],
|
6
|
-
['group_by', 'key', {property: 'id', optional: true}],
|
5
|
+
['value', 'key', {property: 'value'}],
|
6
|
+
['group_by', 'key', {property: 'id', optional: true}],
|
7
7
|
['fill_color', 'color', 'category10()'],
|
8
8
|
],
|
9
|
-
|
9
|
+
|
10
10
|
defaults: function() {
|
11
11
|
return this.deep_defaults({
|
12
|
-
bins: null, // number of bins to use. The default bin function will
|
13
|
-
// divide the values into uniform bins using Sturges' formula.
|
14
|
-
rotate_labels: -45,
|
12
|
+
bins: null, // number of bins to use. The default bin function will
|
13
|
+
// divide the values into uniform bins using Sturges' formula.
|
14
|
+
//rotate_labels: -45,
|
15
|
+
rotate_labels: 0,
|
15
16
|
tooltips: true,
|
16
17
|
show_legend: true,
|
17
|
-
show_controls: true,
|
18
|
+
show_controls: true,
|
18
19
|
// reduceXTicks
|
19
20
|
// showControls
|
20
|
-
// stacked',
|
21
|
+
// stacked',
|
21
22
|
// delay
|
22
|
-
|
23
|
+
|
23
24
|
margin: {
|
24
|
-
top: 20, right: 0, bottom: 50, left: 80
|
25
|
-
}
|
26
|
-
},
|
25
|
+
top: 20, right: 0, bottom: 50, left: 80
|
26
|
+
}
|
27
|
+
}, histogram2.__super__.defaults.call(this));
|
27
28
|
},
|
28
29
|
|
29
30
|
_create_model: function() {
|
30
|
-
return nv.models.multiBarChart();
|
31
|
+
return nv.models.multiBarChart();
|
31
32
|
},
|
32
|
-
|
33
|
-
// _configure_mapping: function(m, chart) {
|
34
|
-
// // var x_index = m.x_axis;
|
35
|
-
// // var y_index = m.y_axis;
|
36
|
-
// // chart.x(function(d) {
|
37
|
-
// // var v = x_index(d);
|
38
|
-
// // return v;
|
39
|
-
// // })
|
40
|
-
// // chart.y(function(d) {
|
41
|
-
// // var v = y_index(d);
|
42
|
-
// // return v;
|
43
|
-
// // })
|
44
|
-
// },
|
45
|
-
|
33
|
+
|
46
34
|
_configure_options: function(opts, chart) {
|
47
|
-
|
35
|
+
histogram2.__super__._configure_options.call(this, opts, chart);
|
48
36
|
chart
|
49
37
|
.rotateLabels(opts.rotate_labels)
|
50
38
|
.tooltips(opts.tooltips)
|
51
39
|
.showLegend(opts.show_legend)
|
52
|
-
.showControls(opts.show_control)
|
40
|
+
.showControls(opts.show_control)
|
53
41
|
.margin(opts.margin)
|
54
42
|
;
|
55
|
-
this._configure_xy_axis(opts, chart)
|
43
|
+
this._configure_xy_axis(opts, chart);
|
56
44
|
},
|
57
|
-
|
45
|
+
|
58
46
|
_datum: function(data, chart) {
|
59
47
|
var o = this.opts;
|
60
48
|
var m = this.mapping;
|
61
49
|
|
62
|
-
// We first calculate a histogram across all data rows to establish
|
50
|
+
// We first calculate a histogram across all data rows to establish
|
63
51
|
// the bins. We then fix the bins, separate the data accoording to
|
64
52
|
// the 'group-by' property and then calculate individual histograms
|
65
53
|
// for each group with fixed bins.
|
66
54
|
//
|
67
|
-
var hdata;
|
55
|
+
var hdata;
|
68
56
|
var histogram = d3.layout.histogram();
|
69
57
|
histogram.value(m.value);
|
70
58
|
var bins = o.bins ? histogram.bins(o.bins) : histogram.bins();
|
71
59
|
// To calculate density, we would need to calibrate that across
|
72
60
|
// all groups.
|
73
|
-
|
61
|
+
if (o.density) histogram.frequency(false);
|
74
62
|
hdata = histogram(data);
|
75
|
-
|
63
|
+
|
76
64
|
var group_by = m.group_by;
|
77
65
|
var datum;
|
78
66
|
if (group_by != null) {
|
79
67
|
var bins = hdata.map(function(b) {
|
80
68
|
return b.x + b.dx;
|
81
|
-
})
|
69
|
+
});
|
82
70
|
bins.splice(0, 0, hdata[0].x);
|
83
71
|
histogram.bins(bins);
|
84
72
|
var groups = this.group_by(data, group_by);
|
@@ -86,10 +74,10 @@ L.provide('OML.histogram2', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_cha
|
|
86
74
|
return {
|
87
75
|
key: g.length > 0 ? group_by(g[0]) : '???',
|
88
76
|
values: histogram(g).map(function(b) {
|
89
|
-
return {x: (b.x + 0.5 * b.dx), y: b.y}
|
77
|
+
return {x: (b.x + 0.5 * b.dx), y: b.y};
|
90
78
|
})
|
91
|
-
}
|
92
|
-
})
|
79
|
+
};
|
80
|
+
});
|
93
81
|
} else {
|
94
82
|
datum = [{
|
95
83
|
key: '???',
|
@@ -98,22 +86,24 @@ L.provide('OML.histogram2', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_cha
|
|
98
86
|
})
|
99
87
|
}];
|
100
88
|
};
|
101
|
-
|
89
|
+
|
102
90
|
if (m.fill_color) {
|
103
91
|
datum = datum.map(function(d) {
|
104
92
|
d.color = m.fill_color(d.key);
|
105
93
|
return d;
|
106
|
-
})
|
94
|
+
});
|
107
95
|
}
|
108
|
-
|
96
|
+
|
109
97
|
if (o.show_legend) chart.showLegend(datum.length > 1);
|
110
98
|
if (o.show_controls) chart.showControls(datum.length > 1);
|
111
99
|
|
112
100
|
return datum;
|
113
101
|
},
|
114
|
-
|
115
|
-
})
|
116
|
-
|
102
|
+
|
103
|
+
});
|
104
|
+
|
105
|
+
return histogram2;
|
106
|
+
});
|
117
107
|
|
118
108
|
/*
|
119
109
|
Local Variables:
|
@@ -1,42 +1,48 @@
|
|
1
|
-
// L.provide('OML.line_chart3', ["graph/abstract_chart", "#OML.abstract_chart", "graph/axis", "#OML.axis", "graph.css",
|
2
|
-
// ["/resource/vendor/d3/d3.js",
|
3
|
-
// "/resource/vendor/nv_d3/js/nv.d3.js",
|
4
|
-
// "/resource/vendor/nv_d3/js/models/line.js",
|
5
|
-
// "/resource/vendor/nv_d3/js/models/lineChart.js",
|
6
|
-
// "/resource/vendor/nv_d3/css/nv.d3.css"
|
7
|
-
// ]], function () {
|
8
|
-
L.provide('OML.line_chart3', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_chart"], function () {
|
9
1
|
|
10
|
-
|
2
|
+
require.config({
|
3
|
+
shim: {
|
4
|
+
"vendor/nv_d3/js/nv.d3": ["vendor/d3/d3", "css!vendor/nv_d3/css/nv.d3"],
|
5
|
+
"vendor/nv_d3/js/models/line": ["vendor/nv_d3/js/nv.d3"],
|
6
|
+
"vendor/nv_d3/js/models/lineChart": ["vendor/nv_d3/js/models/line"],
|
7
|
+
}
|
8
|
+
});
|
9
|
+
|
10
|
+
define(["graph/abstract_nv_chart",
|
11
|
+
"graph/abstract_chart", "graph/axis",
|
12
|
+
"css!graph_css/graph",
|
13
|
+
"vendor/nv_d3/js/models/lineChart"
|
14
|
+
], function (abstract_nv_chart) {
|
15
|
+
|
16
|
+
var line_chart3 = abstract_nv_chart.extend({
|
11
17
|
decl_properties: [
|
12
|
-
['x_axis', 'key', {property: 'x'}],
|
13
|
-
['y_axis', 'key', {property: 'y'}],
|
14
|
-
['group_by', 'key', {property: 'id', optional: true}],
|
15
|
-
['stroke_width', 'int', 2],
|
18
|
+
['x_axis', 'key', {property: 'x'}],
|
19
|
+
['y_axis', 'key', {property: 'y'}],
|
20
|
+
['group_by', 'key', {property: 'id', optional: true}],
|
21
|
+
['stroke_width', 'int', 2],
|
16
22
|
['stroke_color', 'color', 'category10()'],
|
17
23
|
['stroke_fill', 'color', 'blue']
|
18
24
|
],
|
19
|
-
|
20
|
-
|
25
|
+
|
26
|
+
|
21
27
|
_create_model: function() {
|
22
28
|
return nv.models.lineChart();
|
23
29
|
},
|
24
|
-
|
30
|
+
|
25
31
|
_configure_mapping: function(m, chart) {
|
26
32
|
var x_index = m.x_axis;
|
27
33
|
var y_index = m.y_axis;
|
28
34
|
chart.x(function(d) {
|
29
|
-
var v = x_index(d);
|
35
|
+
var v = x_index(d);
|
30
36
|
return v;
|
31
|
-
})
|
37
|
+
});
|
32
38
|
chart.y(function(d) {
|
33
39
|
var v = y_index(d);
|
34
40
|
return v;
|
35
|
-
})
|
41
|
+
});
|
36
42
|
},
|
37
|
-
|
43
|
+
|
38
44
|
_configure_options: function(opts, chart) {
|
39
|
-
|
45
|
+
line_chart3.__super__._configure_options.call(this, opts, chart);
|
40
46
|
// chart
|
41
47
|
// .rotateLabels(opts.rotate_labels)
|
42
48
|
// .staggerLabels(opts.stagger_labels)
|
@@ -44,16 +50,16 @@ L.provide('OML.line_chart3', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_ch
|
|
44
50
|
// .showValues(opts.show_values)
|
45
51
|
// .margin(opts.margin)
|
46
52
|
// ;
|
47
|
-
|
53
|
+
|
48
54
|
this.opts.transition_duration = 0; // force no smooth transition
|
49
55
|
this._configure_xy_axis(opts, chart)
|
50
56
|
},
|
51
|
-
|
57
|
+
|
52
58
|
_datum: function(data, chart) {
|
53
59
|
var self = this;
|
54
60
|
var m = this.mapping;
|
55
61
|
var o = this.opts;
|
56
|
-
|
62
|
+
|
57
63
|
var group_by = m.group_by;
|
58
64
|
var data;
|
59
65
|
if (group_by != null) {
|
@@ -62,13 +68,13 @@ L.provide('OML.line_chart3', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_ch
|
|
62
68
|
data = [data];
|
63
69
|
};
|
64
70
|
chart.showLegend(data.length > 1);
|
65
|
-
|
71
|
+
|
66
72
|
return data.map(function(rows, i) {
|
67
73
|
var name = m.group_by != null ? m.group_by(rows[0]) : 'unknown';
|
68
74
|
var line = {
|
69
75
|
values: rows,
|
70
76
|
key: name,
|
71
|
-
}
|
77
|
+
};
|
72
78
|
if (o.area) line.area = o.area;
|
73
79
|
if (m.stroke_color) {
|
74
80
|
line.color = m.stroke_color(name);
|
@@ -83,10 +89,10 @@ L.provide('OML.line_chart3', ["graph/js/abstract_nv_chart", "#OML.abstract_nv_ch
|
|
83
89
|
return line;
|
84
90
|
});
|
85
91
|
},
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
})
|
92
|
+
});
|
93
|
+
|
94
|
+
return line_chart3;
|
95
|
+
});
|
90
96
|
|
91
97
|
/*
|
92
98
|
Local Variables:
|
@@ -1,30 +1,31 @@
|
|
1
|
-
|
1
|
+
define(["graph/line_chart3"], function (line_chart3) {
|
2
|
+
|
3
|
+
return line_chart3.extend({
|
2
4
|
|
3
|
-
OML.line_chart_with_focus = OML.line_chart3.extend({
|
4
|
-
|
5
5
|
_create_model: function() {
|
6
6
|
return nv.models.lineWithFocusChart();
|
7
7
|
},
|
8
|
-
|
8
|
+
|
9
9
|
_configure_xy_axis: function(opts, chart) {
|
10
10
|
var oaxis = opts.axis || {};
|
11
11
|
var a_defaults = this.axis_defaults;
|
12
|
-
|
12
|
+
|
13
13
|
var xao = _.defaults(oaxis.x || {}, a_defaults);
|
14
14
|
xao['legend'] = null;
|
15
15
|
this._configure_axis('x', chart.xAxis, xao);
|
16
16
|
var xao2 = _.defaults(oaxis.x2 || {}, a_defaults);
|
17
17
|
this._configure_axis('x2', chart.x2Axis, xao2);
|
18
|
-
|
18
|
+
|
19
19
|
var yao = _.defaults(oaxis.y || {}, a_defaults);
|
20
20
|
this._configure_axis('y', chart.yAxis, yao);
|
21
21
|
var yao2 = _.defaults(oaxis.y2 || {}, a_defaults);
|
22
22
|
yao2['legend'] = null;
|
23
23
|
this._configure_axis('y2', chart.y2Axis, yao2);
|
24
24
|
},
|
25
|
-
|
26
|
-
})
|
27
|
-
|
25
|
+
|
26
|
+
});
|
27
|
+
|
28
|
+
});
|
28
29
|
|
29
30
|
/*
|
30
31
|
Local Variables:
|
@@ -1,61 +1,62 @@
|
|
1
|
-
|
1
|
+
define(["graph/abstract_nv_chart"], function (abstract_nv_chart) {
|
2
|
+
|
3
|
+
var multi_barchart = abstract_nv_chart.extend({
|
2
4
|
|
3
|
-
OML.multi_barchart = OML.abstract_nv_chart.extend({
|
4
5
|
decl_properties: [
|
5
|
-
['label', 'key', {property: 'label'}],
|
6
|
-
['value', 'key', {property: 'value'}],
|
7
|
-
['group_by', 'key', {property: 'id', optional: true}],
|
6
|
+
['label', 'key', {property: 'label'}],
|
7
|
+
['value', 'key', {property: 'value'}],
|
8
|
+
['group_by', 'key', {property: 'id', optional: true}],
|
8
9
|
['fill_color', 'color', 'category10()'],
|
9
10
|
],
|
10
|
-
|
11
|
+
|
11
12
|
defaults: function() {
|
12
13
|
return this.deep_defaults({
|
13
|
-
bins: null, // number of bins to use. The default bin function will
|
14
|
-
// divide the values into uniform bins using Sturges' formula.
|
14
|
+
bins: null, // number of bins to use. The default bin function will
|
15
|
+
// divide the values into uniform bins using Sturges' formula.
|
15
16
|
rotate_labels: -45,
|
16
17
|
tooltips: true,
|
17
18
|
show_legend: true,
|
18
|
-
show_controls: true,
|
19
|
+
show_controls: true,
|
19
20
|
// reduceXTicks
|
20
21
|
// showControls
|
21
|
-
// stacked',
|
22
|
+
// stacked',
|
22
23
|
// delay
|
23
|
-
|
24
|
+
|
24
25
|
margin: {
|
25
|
-
top: 20, right: 0, bottom: 50, left: 80
|
26
|
-
}
|
27
|
-
},
|
26
|
+
top: 20, right: 0, bottom: 50, left: 80
|
27
|
+
}
|
28
|
+
}, multi_barchart.__super__.defaults.call(this));
|
28
29
|
},
|
29
30
|
|
30
31
|
_create_model: function() {
|
31
|
-
return nv.models.multiBarChart();
|
32
|
+
return nv.models.multiBarChart();
|
32
33
|
},
|
33
|
-
|
34
|
+
|
34
35
|
_configure_mapping: function(m, chart) {
|
35
36
|
var label_f = m.label;
|
36
37
|
var value_f = m.value;
|
37
38
|
chart.x(function(d) {
|
38
|
-
var v = label_f(d);
|
39
|
+
var v = label_f(d);
|
39
40
|
return v;
|
40
|
-
})
|
41
|
+
});
|
41
42
|
chart.y(function(d) {
|
42
43
|
var v = value_f(d);
|
43
44
|
return v;
|
44
|
-
})
|
45
|
+
});
|
45
46
|
},
|
46
|
-
|
47
|
+
|
47
48
|
_configure_options: function(opts, chart) {
|
48
|
-
|
49
|
+
multi_barchart.__super__._configure_options.call(this, opts, chart);
|
49
50
|
chart
|
50
51
|
.rotateLabels(opts.rotate_labels)
|
51
52
|
.tooltips(opts.tooltips)
|
52
53
|
.showLegend(opts.show_legend)
|
53
|
-
.showControls(opts.show_control)
|
54
|
+
.showControls(opts.show_control)
|
54
55
|
.margin(opts.margin)
|
55
56
|
;
|
56
|
-
this._configure_xy_axis(opts, chart)
|
57
|
+
this._configure_xy_axis(opts, chart);
|
57
58
|
},
|
58
|
-
|
59
|
+
|
59
60
|
_datum: function(data, chart) {
|
60
61
|
var o = this.opts;
|
61
62
|
var m = this.mapping;
|
@@ -67,23 +68,25 @@ L.provide('OML.multi_barchart', ["graph/js/abstract_nv_chart", "#OML.abstract_nv
|
|
67
68
|
return {
|
68
69
|
key: group_by(gdata[0]),
|
69
70
|
values: gdata
|
70
|
-
}
|
71
|
-
})
|
71
|
+
};
|
72
|
+
});
|
72
73
|
} else {
|
73
74
|
datum = [{
|
74
75
|
key: '???',
|
75
76
|
values: data
|
76
77
|
}];
|
77
78
|
}
|
78
|
-
|
79
|
+
|
79
80
|
if (o.show_legend) chart.showLegend(datum.length > 1);
|
80
81
|
if (o.show_controls) chart.showControls(datum.length > 1);
|
81
82
|
|
82
83
|
return datum;
|
83
84
|
},
|
84
|
-
|
85
|
-
})
|
86
|
-
|
85
|
+
|
86
|
+
});
|
87
|
+
|
88
|
+
return multi_barchart;
|
89
|
+
});
|
87
90
|
|
88
91
|
/*
|
89
92
|
Local Variables:
|