columbus3 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +62 -0
- data/bower_components/flot/.bower.json +19 -0
- data/bower_components/flot/.gitignore +3 -0
- data/bower_components/flot/.travis.yml +3 -0
- data/bower_components/flot/API.md +1498 -0
- data/bower_components/flot/CONTRIBUTING.md +98 -0
- data/bower_components/flot/FAQ.md +75 -0
- data/bower_components/flot/LICENSE.txt +22 -0
- data/bower_components/flot/Makefile +12 -0
- data/bower_components/flot/NEWS.md +1026 -0
- data/bower_components/flot/PLUGINS.md +143 -0
- data/bower_components/flot/README.md +110 -0
- data/bower_components/flot/component.json +8 -0
- data/bower_components/flot/examples/ajax/data-eu-gdp-growth-1.json +4 -0
- data/bower_components/flot/examples/ajax/data-eu-gdp-growth-2.json +4 -0
- data/bower_components/flot/examples/ajax/data-eu-gdp-growth-3.json +4 -0
- data/bower_components/flot/examples/ajax/data-eu-gdp-growth-4.json +4 -0
- data/bower_components/flot/examples/ajax/data-eu-gdp-growth-5.json +4 -0
- data/bower_components/flot/examples/ajax/data-eu-gdp-growth.json +4 -0
- data/bower_components/flot/examples/ajax/data-japan-gdp-growth.json +4 -0
- data/bower_components/flot/examples/ajax/data-usa-gdp-growth.json +4 -0
- data/bower_components/flot/examples/ajax/index.html +173 -0
- data/bower_components/flot/examples/annotating/index.html +87 -0
- data/bower_components/flot/examples/axes-interacting/index.html +97 -0
- data/bower_components/flot/examples/axes-multiple/index.html +77 -0
- data/bower_components/flot/examples/axes-time-zones/date.js +893 -0
- data/bower_components/flot/examples/axes-time-zones/index.html +114 -0
- data/bower_components/flot/examples/axes-time-zones/tz/africa +1181 -0
- data/bower_components/flot/examples/axes-time-zones/tz/antarctica +413 -0
- data/bower_components/flot/examples/axes-time-zones/tz/asia +2717 -0
- data/bower_components/flot/examples/axes-time-zones/tz/australasia +1719 -0
- data/bower_components/flot/examples/axes-time-zones/tz/backward +117 -0
- data/bower_components/flot/examples/axes-time-zones/tz/etcetera +81 -0
- data/bower_components/flot/examples/axes-time-zones/tz/europe +2856 -0
- data/bower_components/flot/examples/axes-time-zones/tz/factory +10 -0
- data/bower_components/flot/examples/axes-time-zones/tz/iso3166.tab +276 -0
- data/bower_components/flot/examples/axes-time-zones/tz/leapseconds +100 -0
- data/bower_components/flot/examples/axes-time-zones/tz/northamerica +3235 -0
- data/bower_components/flot/examples/axes-time-zones/tz/pacificnew +28 -0
- data/bower_components/flot/examples/axes-time-zones/tz/solar87 +390 -0
- data/bower_components/flot/examples/axes-time-zones/tz/solar88 +390 -0
- data/bower_components/flot/examples/axes-time-zones/tz/solar89 +395 -0
- data/bower_components/flot/examples/axes-time-zones/tz/southamerica +1711 -0
- data/bower_components/flot/examples/axes-time-zones/tz/systemv +38 -0
- data/bower_components/flot/examples/axes-time-zones/tz/yearistype.sh +38 -0
- data/bower_components/flot/examples/axes-time-zones/tz/zone.tab +441 -0
- data/bower_components/flot/examples/axes-time/index.html +137 -0
- data/bower_components/flot/examples/background.png +0 -0
- data/bower_components/flot/examples/basic-options/index.html +91 -0
- data/bower_components/flot/examples/basic-usage/index.html +57 -0
- data/bower_components/flot/examples/canvas/index.html +75 -0
- data/bower_components/flot/examples/categories/index.html +64 -0
- data/bower_components/flot/examples/examples.css +97 -0
- data/bower_components/flot/examples/image/hs-2004-27-a-large-web.jpg +0 -0
- data/bower_components/flot/examples/image/index.html +69 -0
- data/bower_components/flot/examples/index.html +80 -0
- data/bower_components/flot/examples/interacting/index.html +118 -0
- data/bower_components/flot/examples/navigate/arrow-down.gif +0 -0
- data/bower_components/flot/examples/navigate/arrow-left.gif +0 -0
- data/bower_components/flot/examples/navigate/arrow-right.gif +0 -0
- data/bower_components/flot/examples/navigate/arrow-up.gif +0 -0
- data/bower_components/flot/examples/navigate/index.html +153 -0
- data/bower_components/flot/examples/percentiles/index.html +79 -0
- data/bower_components/flot/examples/realtime/index.html +122 -0
- data/bower_components/flot/examples/resize/index.html +76 -0
- data/bower_components/flot/examples/selection/index.html +152 -0
- data/bower_components/flot/examples/series-errorbars/index.html +150 -0
- data/bower_components/flot/examples/series-pie/index.html +818 -0
- data/bower_components/flot/examples/series-toggle/index.html +121 -0
- data/bower_components/flot/examples/series-types/index.html +90 -0
- data/bower_components/flot/examples/shared/jquery-ui/jquery-ui.min.css +6 -0
- data/bower_components/flot/examples/stacking/index.html +107 -0
- data/bower_components/flot/examples/symbols/index.html +76 -0
- data/bower_components/flot/examples/threshold/index.html +76 -0
- data/bower_components/flot/examples/tracking/index.html +135 -0
- data/bower_components/flot/examples/visitors/index.html +147 -0
- data/bower_components/flot/examples/zooming/index.html +144 -0
- data/bower_components/flot/excanvas.js +1428 -0
- data/bower_components/flot/excanvas.min.js +1 -0
- data/bower_components/flot/flot.jquery.json +27 -0
- data/bower_components/flot/jquery.colorhelpers.js +180 -0
- data/bower_components/flot/jquery.flot.canvas.js +345 -0
- data/bower_components/flot/jquery.flot.categories.js +190 -0
- data/bower_components/flot/jquery.flot.crosshair.js +176 -0
- data/bower_components/flot/jquery.flot.errorbars.js +353 -0
- data/bower_components/flot/jquery.flot.fillbetween.js +226 -0
- data/bower_components/flot/jquery.flot.image.js +241 -0
- data/bower_components/flot/jquery.flot.js +3168 -0
- data/bower_components/flot/jquery.flot.navigate.js +346 -0
- data/bower_components/flot/jquery.flot.pie.js +820 -0
- data/bower_components/flot/jquery.flot.resize.js +59 -0
- data/bower_components/flot/jquery.flot.selection.js +360 -0
- data/bower_components/flot/jquery.flot.stack.js +188 -0
- data/bower_components/flot/jquery.flot.symbol.js +71 -0
- data/bower_components/flot/jquery.flot.threshold.js +142 -0
- data/bower_components/flot/jquery.flot.time.js +432 -0
- data/bower_components/flot/jquery.js +9472 -0
- data/bower_components/flot/package.json +11 -0
- data/bower_components/jquery/.bower.json +38 -0
- data/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/bower_components/jquery/bower.json +28 -0
- data/bower_components/jquery/dist/jquery.js +9210 -0
- data/bower_components/jquery/dist/jquery.min.js +5 -0
- data/bower_components/jquery/dist/jquery.min.map +1 -0
- data/bower_components/jquery/src/ajax.js +786 -0
- data/bower_components/jquery/src/ajax/jsonp.js +89 -0
- data/bower_components/jquery/src/ajax/load.js +75 -0
- data/bower_components/jquery/src/ajax/parseJSON.js +13 -0
- data/bower_components/jquery/src/ajax/parseXML.js +28 -0
- data/bower_components/jquery/src/ajax/script.js +64 -0
- data/bower_components/jquery/src/ajax/var/nonce.js +5 -0
- data/bower_components/jquery/src/ajax/var/rquery.js +3 -0
- data/bower_components/jquery/src/ajax/xhr.js +136 -0
- data/bower_components/jquery/src/attributes.js +11 -0
- data/bower_components/jquery/src/attributes/attr.js +141 -0
- data/bower_components/jquery/src/attributes/classes.js +158 -0
- data/bower_components/jquery/src/attributes/prop.js +94 -0
- data/bower_components/jquery/src/attributes/support.js +35 -0
- data/bower_components/jquery/src/attributes/val.js +161 -0
- data/bower_components/jquery/src/callbacks.js +205 -0
- data/bower_components/jquery/src/core.js +502 -0
- data/bower_components/jquery/src/core/access.js +60 -0
- data/bower_components/jquery/src/core/init.js +123 -0
- data/bower_components/jquery/src/core/parseHTML.js +39 -0
- data/bower_components/jquery/src/core/ready.js +97 -0
- data/bower_components/jquery/src/core/var/rsingleTag.js +4 -0
- data/bower_components/jquery/src/css.js +450 -0
- data/bower_components/jquery/src/css/addGetHookIf.js +22 -0
- data/bower_components/jquery/src/css/curCSS.js +57 -0
- data/bower_components/jquery/src/css/defaultDisplay.js +70 -0
- data/bower_components/jquery/src/css/hiddenVisibleSelectors.js +15 -0
- data/bower_components/jquery/src/css/support.js +96 -0
- data/bower_components/jquery/src/css/swap.js +28 -0
- data/bower_components/jquery/src/css/var/cssExpand.js +3 -0
- data/bower_components/jquery/src/css/var/getStyles.js +12 -0
- data/bower_components/jquery/src/css/var/isHidden.js +13 -0
- data/bower_components/jquery/src/css/var/rmargin.js +3 -0
- data/bower_components/jquery/src/css/var/rnumnonpx.js +5 -0
- data/bower_components/jquery/src/data.js +178 -0
- data/bower_components/jquery/src/data/Data.js +181 -0
- data/bower_components/jquery/src/data/accepts.js +20 -0
- data/bower_components/jquery/src/data/var/data_priv.js +5 -0
- data/bower_components/jquery/src/data/var/data_user.js +5 -0
- data/bower_components/jquery/src/deferred.js +149 -0
- data/bower_components/jquery/src/deprecated.js +13 -0
- data/bower_components/jquery/src/dimensions.js +50 -0
- data/bower_components/jquery/src/effects.js +648 -0
- data/bower_components/jquery/src/effects/Tween.js +114 -0
- data/bower_components/jquery/src/effects/animatedSelector.js +13 -0
- data/bower_components/jquery/src/event.js +868 -0
- data/bower_components/jquery/src/event/ajax.js +13 -0
- data/bower_components/jquery/src/event/alias.js +39 -0
- data/bower_components/jquery/src/event/support.js +9 -0
- data/bower_components/jquery/src/exports/amd.js +24 -0
- data/bower_components/jquery/src/exports/global.js +32 -0
- data/bower_components/jquery/src/intro.js +44 -0
- data/bower_components/jquery/src/jquery.js +37 -0
- data/bower_components/jquery/src/manipulation.js +580 -0
- data/bower_components/jquery/src/manipulation/_evalUrl.js +18 -0
- data/bower_components/jquery/src/manipulation/support.js +32 -0
- data/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/bower_components/jquery/src/offset.js +207 -0
- data/bower_components/jquery/src/outro.js +1 -0
- data/bower_components/jquery/src/queue.js +142 -0
- data/bower_components/jquery/src/queue/delay.js +22 -0
- data/bower_components/jquery/src/selector-native.js +172 -0
- data/bower_components/jquery/src/selector-sizzle.js +14 -0
- data/bower_components/jquery/src/selector.js +1 -0
- data/bower_components/jquery/src/serialize.js +111 -0
- data/bower_components/jquery/src/sizzle/dist/sizzle.js +2067 -0
- data/bower_components/jquery/src/sizzle/dist/sizzle.min.js +3 -0
- data/bower_components/jquery/src/sizzle/dist/sizzle.min.map +1 -0
- data/bower_components/jquery/src/traversing.js +199 -0
- data/bower_components/jquery/src/traversing/findFilter.js +100 -0
- data/bower_components/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/bower_components/jquery/src/var/arr.js +3 -0
- data/bower_components/jquery/src/var/class2type.js +4 -0
- data/bower_components/jquery/src/var/concat.js +5 -0
- data/bower_components/jquery/src/var/hasOwn.js +5 -0
- data/bower_components/jquery/src/var/indexOf.js +5 -0
- data/bower_components/jquery/src/var/pnum.js +3 -0
- data/bower_components/jquery/src/var/push.js +5 -0
- data/bower_components/jquery/src/var/rnotwhite.js +3 -0
- data/bower_components/jquery/src/var/slice.js +5 -0
- data/bower_components/jquery/src/var/strundefined.js +3 -0
- data/bower_components/jquery/src/var/support.js +4 -0
- data/bower_components/jquery/src/var/toString.js +5 -0
- data/bower_components/jquery/src/wrap.js +79 -0
- data/columbus3.gemspec +1 -1
- data/exe/columbus3 +72 -7
- data/lib/columbus3.rb +2 -1
- data/lib/columbus3/metadata/sidecar.rb +10 -1
- data/lib/columbus3/renderer/flot_renderer.rb +66 -0
- data/lib/columbus3/renderer/{renderer.rb → leaflet_renderer.rb} +0 -0
- data/lib/columbus3/version.rb +1 -1
- data/lib/html/flot.html.erb +106 -0
- metadata +194 -5
- data/README.md +0 -41
@@ -0,0 +1,59 @@
|
|
1
|
+
/* Flot plugin for automatically redrawing plots as the placeholder resizes.
|
2
|
+
|
3
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
4
|
+
Licensed under the MIT license.
|
5
|
+
|
6
|
+
It works by listening for changes on the placeholder div (through the jQuery
|
7
|
+
resize event plugin) - if the size changes, it will redraw the plot.
|
8
|
+
|
9
|
+
There are no options. If you need to disable the plugin for some plots, you
|
10
|
+
can just fix the size of their placeholders.
|
11
|
+
|
12
|
+
*/
|
13
|
+
|
14
|
+
/* Inline dependency:
|
15
|
+
* jQuery resize event - v1.1 - 3/14/2010
|
16
|
+
* http://benalman.com/projects/jquery-resize-plugin/
|
17
|
+
*
|
18
|
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
19
|
+
* Dual licensed under the MIT and GPL licenses.
|
20
|
+
* http://benalman.com/about/license/
|
21
|
+
*/
|
22
|
+
(function($,e,t){"$:nomunge";var i=[],n=$.resize=$.extend($.resize,{}),a,r=false,s="setTimeout",u="resize",m=u+"-special-event",o="pendingDelay",l="activeDelay",f="throttleWindow";n[o]=200;n[l]=20;n[f]=true;$.event.special[u]={setup:function(){if(!n[f]&&this[s]){return false}var e=$(this);i.push(this);e.data(m,{w:e.width(),h:e.height()});if(i.length===1){a=t;h()}},teardown:function(){if(!n[f]&&this[s]){return false}var e=$(this);for(var t=i.length-1;t>=0;t--){if(i[t]==this){i.splice(t,1);break}}e.removeData(m);if(!i.length){if(r){cancelAnimationFrame(a)}else{clearTimeout(a)}a=null}},add:function(e){if(!n[f]&&this[s]){return false}var i;function a(e,n,a){var r=$(this),s=r.data(m)||{};s.w=n!==t?n:r.width();s.h=a!==t?a:r.height();i.apply(this,arguments)}if($.isFunction(e)){i=e;return a}else{i=e.handler;e.handler=a}}};function h(t){if(r===true){r=t||1}for(var s=i.length-1;s>=0;s--){var l=$(i[s]);if(l[0]==e||l.is(":visible")){var f=l.width(),c=l.height(),d=l.data(m);if(d&&(f!==d.w||c!==d.h)){l.trigger(u,[d.w=f,d.h=c]);r=t||true}}else{d=l.data(m);d.w=0;d.h=0}}if(a!==null){if(r&&(t==null||t-r<1e3)){a=e.requestAnimationFrame(h)}else{a=setTimeout(h,n[o]);r=false}}}if(!e.requestAnimationFrame){e.requestAnimationFrame=function(){return e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(t,i){return e.setTimeout(function(){t((new Date).getTime())},n[l])}}()}if(!e.cancelAnimationFrame){e.cancelAnimationFrame=function(){return e.webkitCancelRequestAnimationFrame||e.mozCancelRequestAnimationFrame||e.oCancelRequestAnimationFrame||e.msCancelRequestAnimationFrame||clearTimeout}()}})(jQuery,this);
|
23
|
+
|
24
|
+
(function ($) {
|
25
|
+
var options = { }; // no options
|
26
|
+
|
27
|
+
function init(plot) {
|
28
|
+
function onResize() {
|
29
|
+
var placeholder = plot.getPlaceholder();
|
30
|
+
|
31
|
+
// somebody might have hidden us and we can't plot
|
32
|
+
// when we don't have the dimensions
|
33
|
+
if (placeholder.width() == 0 || placeholder.height() == 0)
|
34
|
+
return;
|
35
|
+
|
36
|
+
plot.resize();
|
37
|
+
plot.setupGrid();
|
38
|
+
plot.draw();
|
39
|
+
}
|
40
|
+
|
41
|
+
function bindEvents(plot, eventHolder) {
|
42
|
+
plot.getPlaceholder().resize(onResize);
|
43
|
+
}
|
44
|
+
|
45
|
+
function shutdown(plot, eventHolder) {
|
46
|
+
plot.getPlaceholder().unbind("resize", onResize);
|
47
|
+
}
|
48
|
+
|
49
|
+
plot.hooks.bindEvents.push(bindEvents);
|
50
|
+
plot.hooks.shutdown.push(shutdown);
|
51
|
+
}
|
52
|
+
|
53
|
+
$.plot.plugins.push({
|
54
|
+
init: init,
|
55
|
+
options: options,
|
56
|
+
name: 'resize',
|
57
|
+
version: '1.0'
|
58
|
+
});
|
59
|
+
})(jQuery);
|
@@ -0,0 +1,360 @@
|
|
1
|
+
/* Flot plugin for selecting regions of a plot.
|
2
|
+
|
3
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
4
|
+
Licensed under the MIT license.
|
5
|
+
|
6
|
+
The plugin supports these options:
|
7
|
+
|
8
|
+
selection: {
|
9
|
+
mode: null or "x" or "y" or "xy",
|
10
|
+
color: color,
|
11
|
+
shape: "round" or "miter" or "bevel",
|
12
|
+
minSize: number of pixels
|
13
|
+
}
|
14
|
+
|
15
|
+
Selection support is enabled by setting the mode to one of "x", "y" or "xy".
|
16
|
+
In "x" mode, the user will only be able to specify the x range, similarly for
|
17
|
+
"y" mode. For "xy", the selection becomes a rectangle where both ranges can be
|
18
|
+
specified. "color" is color of the selection (if you need to change the color
|
19
|
+
later on, you can get to it with plot.getOptions().selection.color). "shape"
|
20
|
+
is the shape of the corners of the selection.
|
21
|
+
|
22
|
+
"minSize" is the minimum size a selection can be in pixels. This value can
|
23
|
+
be customized to determine the smallest size a selection can be and still
|
24
|
+
have the selection rectangle be displayed. When customizing this value, the
|
25
|
+
fact that it refers to pixels, not axis units must be taken into account.
|
26
|
+
Thus, for example, if there is a bar graph in time mode with BarWidth set to 1
|
27
|
+
minute, setting "minSize" to 1 will not make the minimum selection size 1
|
28
|
+
minute, but rather 1 pixel. Note also that setting "minSize" to 0 will prevent
|
29
|
+
"plotunselected" events from being fired when the user clicks the mouse without
|
30
|
+
dragging.
|
31
|
+
|
32
|
+
When selection support is enabled, a "plotselected" event will be emitted on
|
33
|
+
the DOM element you passed into the plot function. The event handler gets a
|
34
|
+
parameter with the ranges selected on the axes, like this:
|
35
|
+
|
36
|
+
placeholder.bind( "plotselected", function( event, ranges ) {
|
37
|
+
alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
|
38
|
+
// similar for yaxis - with multiple axes, the extra ones are in
|
39
|
+
// x2axis, x3axis, ...
|
40
|
+
});
|
41
|
+
|
42
|
+
The "plotselected" event is only fired when the user has finished making the
|
43
|
+
selection. A "plotselecting" event is fired during the process with the same
|
44
|
+
parameters as the "plotselected" event, in case you want to know what's
|
45
|
+
happening while it's happening,
|
46
|
+
|
47
|
+
A "plotunselected" event with no arguments is emitted when the user clicks the
|
48
|
+
mouse to remove the selection. As stated above, setting "minSize" to 0 will
|
49
|
+
destroy this behavior.
|
50
|
+
|
51
|
+
The plugin allso adds the following methods to the plot object:
|
52
|
+
|
53
|
+
- setSelection( ranges, preventEvent )
|
54
|
+
|
55
|
+
Set the selection rectangle. The passed in ranges is on the same form as
|
56
|
+
returned in the "plotselected" event. If the selection mode is "x", you
|
57
|
+
should put in either an xaxis range, if the mode is "y" you need to put in
|
58
|
+
an yaxis range and both xaxis and yaxis if the selection mode is "xy", like
|
59
|
+
this:
|
60
|
+
|
61
|
+
setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
|
62
|
+
|
63
|
+
setSelection will trigger the "plotselected" event when called. If you don't
|
64
|
+
want that to happen, e.g. if you're inside a "plotselected" handler, pass
|
65
|
+
true as the second parameter. If you are using multiple axes, you can
|
66
|
+
specify the ranges on any of those, e.g. as x2axis/x3axis/... instead of
|
67
|
+
xaxis, the plugin picks the first one it sees.
|
68
|
+
|
69
|
+
- clearSelection( preventEvent )
|
70
|
+
|
71
|
+
Clear the selection rectangle. Pass in true to avoid getting a
|
72
|
+
"plotunselected" event.
|
73
|
+
|
74
|
+
- getSelection()
|
75
|
+
|
76
|
+
Returns the current selection in the same format as the "plotselected"
|
77
|
+
event. If there's currently no selection, the function returns null.
|
78
|
+
|
79
|
+
*/
|
80
|
+
|
81
|
+
(function ($) {
|
82
|
+
function init(plot) {
|
83
|
+
var selection = {
|
84
|
+
first: { x: -1, y: -1}, second: { x: -1, y: -1},
|
85
|
+
show: false,
|
86
|
+
active: false
|
87
|
+
};
|
88
|
+
|
89
|
+
// FIXME: The drag handling implemented here should be
|
90
|
+
// abstracted out, there's some similar code from a library in
|
91
|
+
// the navigation plugin, this should be massaged a bit to fit
|
92
|
+
// the Flot cases here better and reused. Doing this would
|
93
|
+
// make this plugin much slimmer.
|
94
|
+
var savedhandlers = {};
|
95
|
+
|
96
|
+
var mouseUpHandler = null;
|
97
|
+
|
98
|
+
function onMouseMove(e) {
|
99
|
+
if (selection.active) {
|
100
|
+
updateSelection(e);
|
101
|
+
|
102
|
+
plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
function onMouseDown(e) {
|
107
|
+
if (e.which != 1) // only accept left-click
|
108
|
+
return;
|
109
|
+
|
110
|
+
// cancel out any text selections
|
111
|
+
document.body.focus();
|
112
|
+
|
113
|
+
// prevent text selection and drag in old-school browsers
|
114
|
+
if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
|
115
|
+
savedhandlers.onselectstart = document.onselectstart;
|
116
|
+
document.onselectstart = function () { return false; };
|
117
|
+
}
|
118
|
+
if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
|
119
|
+
savedhandlers.ondrag = document.ondrag;
|
120
|
+
document.ondrag = function () { return false; };
|
121
|
+
}
|
122
|
+
|
123
|
+
setSelectionPos(selection.first, e);
|
124
|
+
|
125
|
+
selection.active = true;
|
126
|
+
|
127
|
+
// this is a bit silly, but we have to use a closure to be
|
128
|
+
// able to whack the same handler again
|
129
|
+
mouseUpHandler = function (e) { onMouseUp(e); };
|
130
|
+
|
131
|
+
$(document).one("mouseup", mouseUpHandler);
|
132
|
+
}
|
133
|
+
|
134
|
+
function onMouseUp(e) {
|
135
|
+
mouseUpHandler = null;
|
136
|
+
|
137
|
+
// revert drag stuff for old-school browsers
|
138
|
+
if (document.onselectstart !== undefined)
|
139
|
+
document.onselectstart = savedhandlers.onselectstart;
|
140
|
+
if (document.ondrag !== undefined)
|
141
|
+
document.ondrag = savedhandlers.ondrag;
|
142
|
+
|
143
|
+
// no more dragging
|
144
|
+
selection.active = false;
|
145
|
+
updateSelection(e);
|
146
|
+
|
147
|
+
if (selectionIsSane())
|
148
|
+
triggerSelectedEvent();
|
149
|
+
else {
|
150
|
+
// this counts as a clear
|
151
|
+
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
152
|
+
plot.getPlaceholder().trigger("plotselecting", [ null ]);
|
153
|
+
}
|
154
|
+
|
155
|
+
return false;
|
156
|
+
}
|
157
|
+
|
158
|
+
function getSelection() {
|
159
|
+
if (!selectionIsSane())
|
160
|
+
return null;
|
161
|
+
|
162
|
+
if (!selection.show) return null;
|
163
|
+
|
164
|
+
var r = {}, c1 = selection.first, c2 = selection.second;
|
165
|
+
$.each(plot.getAxes(), function (name, axis) {
|
166
|
+
if (axis.used) {
|
167
|
+
var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
|
168
|
+
r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
|
169
|
+
}
|
170
|
+
});
|
171
|
+
return r;
|
172
|
+
}
|
173
|
+
|
174
|
+
function triggerSelectedEvent() {
|
175
|
+
var r = getSelection();
|
176
|
+
|
177
|
+
plot.getPlaceholder().trigger("plotselected", [ r ]);
|
178
|
+
|
179
|
+
// backwards-compat stuff, to be removed in future
|
180
|
+
if (r.xaxis && r.yaxis)
|
181
|
+
plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
|
182
|
+
}
|
183
|
+
|
184
|
+
function clamp(min, value, max) {
|
185
|
+
return value < min ? min: (value > max ? max: value);
|
186
|
+
}
|
187
|
+
|
188
|
+
function setSelectionPos(pos, e) {
|
189
|
+
var o = plot.getOptions();
|
190
|
+
var offset = plot.getPlaceholder().offset();
|
191
|
+
var plotOffset = plot.getPlotOffset();
|
192
|
+
pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
|
193
|
+
pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
|
194
|
+
|
195
|
+
if (o.selection.mode == "y")
|
196
|
+
pos.x = pos == selection.first ? 0 : plot.width();
|
197
|
+
|
198
|
+
if (o.selection.mode == "x")
|
199
|
+
pos.y = pos == selection.first ? 0 : plot.height();
|
200
|
+
}
|
201
|
+
|
202
|
+
function updateSelection(pos) {
|
203
|
+
if (pos.pageX == null)
|
204
|
+
return;
|
205
|
+
|
206
|
+
setSelectionPos(selection.second, pos);
|
207
|
+
if (selectionIsSane()) {
|
208
|
+
selection.show = true;
|
209
|
+
plot.triggerRedrawOverlay();
|
210
|
+
}
|
211
|
+
else
|
212
|
+
clearSelection(true);
|
213
|
+
}
|
214
|
+
|
215
|
+
function clearSelection(preventEvent) {
|
216
|
+
if (selection.show) {
|
217
|
+
selection.show = false;
|
218
|
+
plot.triggerRedrawOverlay();
|
219
|
+
if (!preventEvent)
|
220
|
+
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
// function taken from markings support in Flot
|
225
|
+
function extractRange(ranges, coord) {
|
226
|
+
var axis, from, to, key, axes = plot.getAxes();
|
227
|
+
|
228
|
+
for (var k in axes) {
|
229
|
+
axis = axes[k];
|
230
|
+
if (axis.direction == coord) {
|
231
|
+
key = coord + axis.n + "axis";
|
232
|
+
if (!ranges[key] && axis.n == 1)
|
233
|
+
key = coord + "axis"; // support x1axis as xaxis
|
234
|
+
if (ranges[key]) {
|
235
|
+
from = ranges[key].from;
|
236
|
+
to = ranges[key].to;
|
237
|
+
break;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
// backwards-compat stuff - to be removed in future
|
243
|
+
if (!ranges[key]) {
|
244
|
+
axis = coord == "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
|
245
|
+
from = ranges[coord + "1"];
|
246
|
+
to = ranges[coord + "2"];
|
247
|
+
}
|
248
|
+
|
249
|
+
// auto-reverse as an added bonus
|
250
|
+
if (from != null && to != null && from > to) {
|
251
|
+
var tmp = from;
|
252
|
+
from = to;
|
253
|
+
to = tmp;
|
254
|
+
}
|
255
|
+
|
256
|
+
return { from: from, to: to, axis: axis };
|
257
|
+
}
|
258
|
+
|
259
|
+
function setSelection(ranges, preventEvent) {
|
260
|
+
var axis, range, o = plot.getOptions();
|
261
|
+
|
262
|
+
if (o.selection.mode == "y") {
|
263
|
+
selection.first.x = 0;
|
264
|
+
selection.second.x = plot.width();
|
265
|
+
}
|
266
|
+
else {
|
267
|
+
range = extractRange(ranges, "x");
|
268
|
+
|
269
|
+
selection.first.x = range.axis.p2c(range.from);
|
270
|
+
selection.second.x = range.axis.p2c(range.to);
|
271
|
+
}
|
272
|
+
|
273
|
+
if (o.selection.mode == "x") {
|
274
|
+
selection.first.y = 0;
|
275
|
+
selection.second.y = plot.height();
|
276
|
+
}
|
277
|
+
else {
|
278
|
+
range = extractRange(ranges, "y");
|
279
|
+
|
280
|
+
selection.first.y = range.axis.p2c(range.from);
|
281
|
+
selection.second.y = range.axis.p2c(range.to);
|
282
|
+
}
|
283
|
+
|
284
|
+
selection.show = true;
|
285
|
+
plot.triggerRedrawOverlay();
|
286
|
+
if (!preventEvent && selectionIsSane())
|
287
|
+
triggerSelectedEvent();
|
288
|
+
}
|
289
|
+
|
290
|
+
function selectionIsSane() {
|
291
|
+
var minSize = plot.getOptions().selection.minSize;
|
292
|
+
return Math.abs(selection.second.x - selection.first.x) >= minSize &&
|
293
|
+
Math.abs(selection.second.y - selection.first.y) >= minSize;
|
294
|
+
}
|
295
|
+
|
296
|
+
plot.clearSelection = clearSelection;
|
297
|
+
plot.setSelection = setSelection;
|
298
|
+
plot.getSelection = getSelection;
|
299
|
+
|
300
|
+
plot.hooks.bindEvents.push(function(plot, eventHolder) {
|
301
|
+
var o = plot.getOptions();
|
302
|
+
if (o.selection.mode != null) {
|
303
|
+
eventHolder.mousemove(onMouseMove);
|
304
|
+
eventHolder.mousedown(onMouseDown);
|
305
|
+
}
|
306
|
+
});
|
307
|
+
|
308
|
+
|
309
|
+
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
310
|
+
// draw selection
|
311
|
+
if (selection.show && selectionIsSane()) {
|
312
|
+
var plotOffset = plot.getPlotOffset();
|
313
|
+
var o = plot.getOptions();
|
314
|
+
|
315
|
+
ctx.save();
|
316
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
317
|
+
|
318
|
+
var c = $.color.parse(o.selection.color);
|
319
|
+
|
320
|
+
ctx.strokeStyle = c.scale('a', 0.8).toString();
|
321
|
+
ctx.lineWidth = 1;
|
322
|
+
ctx.lineJoin = o.selection.shape;
|
323
|
+
ctx.fillStyle = c.scale('a', 0.4).toString();
|
324
|
+
|
325
|
+
var x = Math.min(selection.first.x, selection.second.x) + 0.5,
|
326
|
+
y = Math.min(selection.first.y, selection.second.y) + 0.5,
|
327
|
+
w = Math.abs(selection.second.x - selection.first.x) - 1,
|
328
|
+
h = Math.abs(selection.second.y - selection.first.y) - 1;
|
329
|
+
|
330
|
+
ctx.fillRect(x, y, w, h);
|
331
|
+
ctx.strokeRect(x, y, w, h);
|
332
|
+
|
333
|
+
ctx.restore();
|
334
|
+
}
|
335
|
+
});
|
336
|
+
|
337
|
+
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
338
|
+
eventHolder.unbind("mousemove", onMouseMove);
|
339
|
+
eventHolder.unbind("mousedown", onMouseDown);
|
340
|
+
|
341
|
+
if (mouseUpHandler)
|
342
|
+
$(document).unbind("mouseup", mouseUpHandler);
|
343
|
+
});
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
$.plot.plugins.push({
|
348
|
+
init: init,
|
349
|
+
options: {
|
350
|
+
selection: {
|
351
|
+
mode: null, // one of null, "x", "y" or "xy"
|
352
|
+
color: "#e8cfac",
|
353
|
+
shape: "round", // one of "round", "miter", or "bevel"
|
354
|
+
minSize: 5 // minimum number of pixels
|
355
|
+
}
|
356
|
+
},
|
357
|
+
name: 'selection',
|
358
|
+
version: '1.1'
|
359
|
+
});
|
360
|
+
})(jQuery);
|
@@ -0,0 +1,188 @@
|
|
1
|
+
/* Flot plugin for stacking data sets rather than overlyaing them.
|
2
|
+
|
3
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
4
|
+
Licensed under the MIT license.
|
5
|
+
|
6
|
+
The plugin assumes the data is sorted on x (or y if stacking horizontally).
|
7
|
+
For line charts, it is assumed that if a line has an undefined gap (from a
|
8
|
+
null point), then the line above it should have the same gap - insert zeros
|
9
|
+
instead of "null" if you want another behaviour. This also holds for the start
|
10
|
+
and end of the chart. Note that stacking a mix of positive and negative values
|
11
|
+
in most instances doesn't make sense (so it looks weird).
|
12
|
+
|
13
|
+
Two or more series are stacked when their "stack" attribute is set to the same
|
14
|
+
key (which can be any number or string or just "true"). To specify the default
|
15
|
+
stack, you can set the stack option like this:
|
16
|
+
|
17
|
+
series: {
|
18
|
+
stack: null/false, true, or a key (number/string)
|
19
|
+
}
|
20
|
+
|
21
|
+
You can also specify it for a single series, like this:
|
22
|
+
|
23
|
+
$.plot( $("#placeholder"), [{
|
24
|
+
data: [ ... ],
|
25
|
+
stack: true
|
26
|
+
}])
|
27
|
+
|
28
|
+
The stacking order is determined by the order of the data series in the array
|
29
|
+
(later series end up on top of the previous).
|
30
|
+
|
31
|
+
Internally, the plugin modifies the datapoints in each series, adding an
|
32
|
+
offset to the y value. For line series, extra data points are inserted through
|
33
|
+
interpolation. If there's a second y value, it's also adjusted (e.g for bar
|
34
|
+
charts or filled areas).
|
35
|
+
|
36
|
+
*/
|
37
|
+
|
38
|
+
(function ($) {
|
39
|
+
var options = {
|
40
|
+
series: { stack: null } // or number/string
|
41
|
+
};
|
42
|
+
|
43
|
+
function init(plot) {
|
44
|
+
function findMatchingSeries(s, allseries) {
|
45
|
+
var res = null;
|
46
|
+
for (var i = 0; i < allseries.length; ++i) {
|
47
|
+
if (s == allseries[i])
|
48
|
+
break;
|
49
|
+
|
50
|
+
if (allseries[i].stack == s.stack)
|
51
|
+
res = allseries[i];
|
52
|
+
}
|
53
|
+
|
54
|
+
return res;
|
55
|
+
}
|
56
|
+
|
57
|
+
function stackData(plot, s, datapoints) {
|
58
|
+
if (s.stack == null || s.stack === false)
|
59
|
+
return;
|
60
|
+
|
61
|
+
var other = findMatchingSeries(s, plot.getData());
|
62
|
+
if (!other)
|
63
|
+
return;
|
64
|
+
|
65
|
+
var ps = datapoints.pointsize,
|
66
|
+
points = datapoints.points,
|
67
|
+
otherps = other.datapoints.pointsize,
|
68
|
+
otherpoints = other.datapoints.points,
|
69
|
+
newpoints = [],
|
70
|
+
px, py, intery, qx, qy, bottom,
|
71
|
+
withlines = s.lines.show,
|
72
|
+
horizontal = s.bars.horizontal,
|
73
|
+
withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
|
74
|
+
withsteps = withlines && s.lines.steps,
|
75
|
+
fromgap = true,
|
76
|
+
keyOffset = horizontal ? 1 : 0,
|
77
|
+
accumulateOffset = horizontal ? 0 : 1,
|
78
|
+
i = 0, j = 0, l, m;
|
79
|
+
|
80
|
+
while (true) {
|
81
|
+
if (i >= points.length)
|
82
|
+
break;
|
83
|
+
|
84
|
+
l = newpoints.length;
|
85
|
+
|
86
|
+
if (points[i] == null) {
|
87
|
+
// copy gaps
|
88
|
+
for (m = 0; m < ps; ++m)
|
89
|
+
newpoints.push(points[i + m]);
|
90
|
+
i += ps;
|
91
|
+
}
|
92
|
+
else if (j >= otherpoints.length) {
|
93
|
+
// for lines, we can't use the rest of the points
|
94
|
+
if (!withlines) {
|
95
|
+
for (m = 0; m < ps; ++m)
|
96
|
+
newpoints.push(points[i + m]);
|
97
|
+
}
|
98
|
+
i += ps;
|
99
|
+
}
|
100
|
+
else if (otherpoints[j] == null) {
|
101
|
+
// oops, got a gap
|
102
|
+
for (m = 0; m < ps; ++m)
|
103
|
+
newpoints.push(null);
|
104
|
+
fromgap = true;
|
105
|
+
j += otherps;
|
106
|
+
}
|
107
|
+
else {
|
108
|
+
// cases where we actually got two points
|
109
|
+
px = points[i + keyOffset];
|
110
|
+
py = points[i + accumulateOffset];
|
111
|
+
qx = otherpoints[j + keyOffset];
|
112
|
+
qy = otherpoints[j + accumulateOffset];
|
113
|
+
bottom = 0;
|
114
|
+
|
115
|
+
if (px == qx) {
|
116
|
+
for (m = 0; m < ps; ++m)
|
117
|
+
newpoints.push(points[i + m]);
|
118
|
+
|
119
|
+
newpoints[l + accumulateOffset] += qy;
|
120
|
+
bottom = qy;
|
121
|
+
|
122
|
+
i += ps;
|
123
|
+
j += otherps;
|
124
|
+
}
|
125
|
+
else if (px > qx) {
|
126
|
+
// we got past point below, might need to
|
127
|
+
// insert interpolated extra point
|
128
|
+
if (withlines && i > 0 && points[i - ps] != null) {
|
129
|
+
intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
|
130
|
+
newpoints.push(qx);
|
131
|
+
newpoints.push(intery + qy);
|
132
|
+
for (m = 2; m < ps; ++m)
|
133
|
+
newpoints.push(points[i + m]);
|
134
|
+
bottom = qy;
|
135
|
+
}
|
136
|
+
|
137
|
+
j += otherps;
|
138
|
+
}
|
139
|
+
else { // px < qx
|
140
|
+
if (fromgap && withlines) {
|
141
|
+
// if we come from a gap, we just skip this point
|
142
|
+
i += ps;
|
143
|
+
continue;
|
144
|
+
}
|
145
|
+
|
146
|
+
for (m = 0; m < ps; ++m)
|
147
|
+
newpoints.push(points[i + m]);
|
148
|
+
|
149
|
+
// we might be able to interpolate a point below,
|
150
|
+
// this can give us a better y
|
151
|
+
if (withlines && j > 0 && otherpoints[j - otherps] != null)
|
152
|
+
bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
|
153
|
+
|
154
|
+
newpoints[l + accumulateOffset] += bottom;
|
155
|
+
|
156
|
+
i += ps;
|
157
|
+
}
|
158
|
+
|
159
|
+
fromgap = false;
|
160
|
+
|
161
|
+
if (l != newpoints.length && withbottom)
|
162
|
+
newpoints[l + 2] += bottom;
|
163
|
+
}
|
164
|
+
|
165
|
+
// maintain the line steps invariant
|
166
|
+
if (withsteps && l != newpoints.length && l > 0
|
167
|
+
&& newpoints[l] != null
|
168
|
+
&& newpoints[l] != newpoints[l - ps]
|
169
|
+
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
|
170
|
+
for (m = 0; m < ps; ++m)
|
171
|
+
newpoints[l + ps + m] = newpoints[l + m];
|
172
|
+
newpoints[l + 1] = newpoints[l - ps + 1];
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
datapoints.points = newpoints;
|
177
|
+
}
|
178
|
+
|
179
|
+
plot.hooks.processDatapoints.push(stackData);
|
180
|
+
}
|
181
|
+
|
182
|
+
$.plot.plugins.push({
|
183
|
+
init: init,
|
184
|
+
options: options,
|
185
|
+
name: 'stack',
|
186
|
+
version: '1.2'
|
187
|
+
});
|
188
|
+
})(jQuery);
|