Commit 7043573a authored by David Schnur's avatar David Schnur

Merge branch 'master' into 0.9-work

Conflicts:
	NEWS.md
	component.json
	flot.jquery.json
	jquery.flot.canvas.js
	jquery.flot.fillbetween.js
	jquery.flot.pie.js
	jquery.flot.time.js
	package.json
	src/jquery.flot.js
	src/plugins/jquery.flot.crosshair.js
	src/plugins/jquery.flot.navigate.js
	src/plugins/jquery.flot.resize.js
parents f2b3b266 453b017c
Copyright (c) 2007-2013 IOLA and Ole Laursen Copyright (c) 2007-2014 IOLA and Ole Laursen
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
......
...@@ -10,6 +10,54 @@ ...@@ -10,6 +10,54 @@
by Jason Swank, issue #331, and Rene Pieter Kok, issue #344) by Jason Swank, issue #331, and Rene Pieter Kok, issue #344)
## Flot 0.8.3 ##
### Changes ###
- Updated example code to avoid encouraging unnecessary re-plots.
(patch by soenter, pull request #1221)
### Bug fixes ###
- Added a work-around to disable the allocation of extra space for first and
last axis ticks, allowing plots to span the full width of their container.
A proper solution for this bug will be implemented in the 0.9 release.
(reported by Josh Pigford and andig, issue #1212, pull request #1290)
- Fixed a regression introduced in 0.8.1, where the last tick label would
sometimes wrap rather than extending the plot's offset to create space.
(reported by Elite Gamer, issue #1283)
- Fixed a regression introduced in 0.8.2, where the resize plugin would use
unexpectedly high amounts of CPU even when idle.
(reported by tommie, issue #1277, pull request #1289)
- Fixed the selection example to work with jQuery 1.9.x and later.
(reported by EGLadona and dmfalke, issue #1250, pull request #1285)
- Added a detach shim to fix support for jQuery versions earlier than 1.4.x.
(reported by ngavard, issue #1240, pull request #1286)
- Fixed a rare 'Uncaught TypeError' when using the resize plugin in IE 7/8.
(reported by tleish, issue #1265, pull request #1289)
- Fixed zoom constraints to apply only in the direction of the zoom.
(patch by Neil Katin, issue #1204, pull request #1205)
- Markings lines are no longer blurry when drawn on pixel boundaries.
(reported by btccointicker and Rouillard, issue #1210)
- Don't discard original pie data-series values when combining slices.
(patch by Phil Tsarik, pull request #1238)
- Fixed broken auto-scale behavior when using deprecated [x|y]2axis options.
(reported by jorese, issue #1228, pull request #1284)
- Exposed the dateGenerator function on the plot object, as it used to be
before time-mode was moved into a separate plugin.
(patch by Paolo Valleri, pull request #1028)
## Flot 0.8.2 ## ## Flot 0.8.2 ##
### Changes ### ### Changes ###
......
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
maxWidth: 900, maxWidth: 900,
maxHeight: 500, maxHeight: 500,
minWidth: 450, minWidth: 450,
minHeight: 250, minHeight: 250
}); });
// Add the Flot version string to the footer // Add the Flot version string to the footer
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -13,6 +13,15 @@ ...@@ -13,6 +13,15 @@
$(function() { $(function() {
// Shim allowing us to get the state of the check-box on jQuery versions
// prior to 1.6, when prop was added. The reason we don't just use attr
// is because it doesn't work in jQuery versions 1.9.x and later.
// TODO: Remove this once Flot's minimum supported jQuery reaches 1.6.
if (typeof $.fn.prop != 'function') {
$.fn.prop = $.fn.attr;
}
var data = [{ var data = [{
label: "United States", label: "United States",
data: [[1990, 18.9], [1991, 18.7], [1992, 18.4], [1993, 19.3], [1994, 19.5], [1995, 19.3], [1996, 19.4], [1997, 20.2], [1998, 19.8], [1999, 19.9], [2000, 20.4], [2001, 20.1], [2002, 20.0], [2003, 19.8], [2004, 20.4]] data: [[1990, 18.9], [1991, 18.7], [1992, 18.4], [1993, 19.3], [1994, 19.5], [1995, 19.3], [1996, 19.4], [1997, 20.2], [1998, 19.8], [1999, 19.9], [2000, 20.4], [2001, 20.1], [2002, 20.0], [2003, 19.8], [2004, 20.4]]
...@@ -65,15 +74,17 @@ ...@@ -65,15 +74,17 @@
$("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1)); $("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1));
var zoom = $("#zoom").attr("checked"); var zoom = $("#zoom").prop("checked");
if (zoom) { if (zoom) {
plot = $.plot(placeholder, data, $.extend(true, {}, options, { $.each(plot.getXAxes(), function(_, axis) {
xaxis: { var opts = axis.options;
min: ranges.xaxis.from, opts.min = ranges.xaxis.from;
max: ranges.xaxis.to opts.max = ranges.xaxis.to;
} });
})); plot.setupGrid();
plot.draw();
plot.clearSelection();
} }
}); });
...@@ -135,7 +146,7 @@ ...@@ -135,7 +146,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -812,7 +812,7 @@ ...@@ -812,7 +812,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -93,13 +93,14 @@ ...@@ -93,13 +93,14 @@
$("#placeholder").bind("plotselected", function (event, ranges) { $("#placeholder").bind("plotselected", function (event, ranges) {
// do the zooming // do the zooming
$.each(plot.getXAxes(), function(_, axis) {
plot = $.plot("#placeholder", [d], $.extend(true, {}, options, { var opts = axis.options;
xaxis: { opts.min = ranges.xaxis.from;
min: ranges.xaxis.from, opts.max = ranges.xaxis.to;
max: ranges.xaxis.to });
} plot.setupGrid();
})); plot.draw();
plot.clearSelection();
// don't fire event on the overview to prevent eternal loop // don't fire event on the overview to prevent eternal loop
...@@ -140,7 +141,7 @@ ...@@ -140,7 +141,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
</div> </div>
<div id="footer"> <div id="footer">
Copyright &copy; 2007 - 2013 IOLA and Ole Laursen Copyright &copy; 2007 - 2014 IOLA and Ole Laursen
</div> </div>
</body> </body>
......
...@@ -24,4 +24,4 @@ ...@@ -24,4 +24,4 @@
"email": "dnschnur@gmail.com", "email": "dnschnur@gmail.com",
"url": "http://github.com/dnschnur" "url": "http://github.com/dnschnur"
}] }]
} }
\ No newline at end of file
...@@ -49,28 +49,31 @@ ...@@ -49,28 +49,31 @@
(function($,window,undefined){ (function($,window,undefined){
'$:nomunge'; // Used by YUI compressor. '$:nomunge'; // Used by YUI compressor.
// A jQuery object containing all non-window elements to which the resize // Array containing all non-window elements to which the resize
// event is bound. // event is bound.
var elems = $([]), var elems = [],
// Extend $.resize if it already exists, otherwise create it. // Extend $.resize if it already exists, otherwise create it.
jq_resize = $.resize = $.extend( $.resize, {} ), jq_resize = $.resize = $.extend( $.resize, {} ),
timeout_id, timeout_id,
active = false,
// Reused strings. // Reused strings.
str_setTimeout = 'setTimeout', str_setTimeout = 'setTimeout',
str_resize = 'resize', str_resize = 'resize',
str_data = str_resize + '-special-event', str_data = str_resize + '-special-event',
str_delay = 'delay', str_pendingDelay = 'pendingDelay',
str_activeDelay = 'activeDelay',
str_throttle = 'throttleWindow'; str_throttle = 'throttleWindow';
// Property: jQuery.resize.delay // Property: jQuery.resize.delay
// //
// The numeric interval (in milliseconds) at which the resize event polling // The numeric interval (in milliseconds) at which the resize event polling
// loop executes. Defaults to 250. // loop executes. Defaults to 200.
jq_resize[ str_delay ] = 250; jq_resize[ str_pendingDelay ] = 200;
jq_resize[ str_activeDelay ] = 20;
// Property: jQuery.resize.throttleWindow // Property: jQuery.resize.throttleWindow
// //
...@@ -139,13 +142,17 @@ ...@@ -139,13 +142,17 @@
var elem = $(this); var elem = $(this);
// Add this element to the list of internal elements to monitor. // Add this element to the list of internal elements to monitor.
elems = elems.add( elem ); elems.push( this );
// Initialize data store on the element. // Initialize data store on the element.
$.data( this, str_data, { w: elem.width(), h: elem.height() } ); elem.data( str_data, { w: elem.width(), h: elem.height() } );
// If this is the first element added, start the polling loop. // If this is the first element added, start the polling loop.
if ( elems.length === 1 ) { if ( elems.length === 1 ) {
//set the timeout_id to undefined.
timeout_id = undefined;
//start the loop
loopy(); loopy();
} }
}, },
...@@ -161,14 +168,26 @@ ...@@ -161,14 +168,26 @@
var elem = $(this); var elem = $(this);
// Remove this element from the list of internal elements to monitor. // Remove this element from the list of internal elements to monitor.
elems = elems.not( elem ); for (var i = elems.length - 1; i >= 0; i--) {
if(elems[i] == this){
elems.splice(i, 1);
break;
}
};
// Remove any data stored on the element. // Remove any data stored on the element.
elem.removeData( str_data ); elem.removeData( str_data );
// If this is the last element removed, stop the polling loop. // If this is the last element removed, stop the polling loop.
if ( !elems.length ) { if ( !elems.length ) {
clearTimeout( timeout_id ); if (active) {
cancelAnimationFrame( timeout_id );
} else {
clearTimeout( timeout_id );
}
//set the timeout_id to null, to make sure the loop is stopped
timeout_id = null;
} }
}, },
...@@ -190,7 +209,7 @@ ...@@ -190,7 +209,7 @@
function new_handler( e, w, h ) { function new_handler( e, w, h ) {
var elem = $(this), var elem = $(this),
data = $.data( this, str_data ); data = elem.data( str_data ) || {};
// If called from the polling loop, w and h will be passed in as // If called from the polling loop, w and h will be passed in as
// arguments. If called manually, via .trigger( 'resize' ) or .resize(), // arguments. If called manually, via .trigger( 'resize' ) or .resize(),
...@@ -216,31 +235,79 @@ ...@@ -216,31 +235,79 @@
}; };
function loopy() { function loopy(timestamp) {
// If this is the first call since switching to active polling, then save
// Start the polling loop, asynchronously. // its timestamp; we need it to determine when to switch back to passive
timeout_id = window[ str_setTimeout ](function(){ // polling. Note the || 1; this is just in case the first real timestamp
// is legitimately zero; in that case we still want a truthy value.
if (active === true) {
active = timestamp || 1;
}
// Iterate over all elements to which the 'resize' event is bound. // Iterate over all elements to which the 'resize' event is bound.
elems.each(function(){ for (var i = elems.length - 1; i >= 0; i--) {
var elem = $(this), var elem = $(elems[i]);
width = elem.width(), if (elem[0] == window || elem.is(':visible')) {
height = elem.height(),
data = $.data( this, str_data ); var width = elem.width(),
height = elem.height(),
// If element size has changed since the last time, update the element data = elem.data( str_data );
// data store and trigger the 'resize' event.
if ( width !== data.w || height !== data.h ) { // If element size has changed since the last time, update the element
elem.trigger( str_resize, [ data.w = width, data.h = height ] ); // data store and trigger the 'resize' event.
if ( data && ( width !== data.w || height !== data.h ) ) {
elem.trigger( str_resize, [ data.w = width, data.h = height ] );
active = timestamp || true;
}
} else {
// resetting stored width and height so that resize event is triggered next time
data = elem.data(str_data);
data.w = 0;
data.h = 0;
} }
};
});
// Poll gently until there is a change, then requestAnimationFrame until
// Loop. // a second passes without a resize event, at which point we switch back.
loopy(); if (timeout_id !== null) {
if (active && (timestamp == null || timestamp - active < 1000)) {
}, jq_resize[ str_delay ] ); timeout_id = window.requestAnimationFrame(loopy);
} else {
timeout_id = setTimeout(loopy, jq_resize[ str_pendingDelay ]);
active = false;
}
}
}; };
/**
* Provides requestAnimationFrame in a cross browser way.
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
*/
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = (function(){
return window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
return window.setTimeout(function() {
callback((new Date()).getTime());
}, jq_resize[ str_activeDelay ] );
};
})();
}
/**
* Provides cancelAnimationFrame in a cross browser way.
*/
if( !window.cancelAnimationFrame ){
window.cancelAnimationFrame = ( function() {
return window.webkitCancelRequestAnimationFrame ||
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
clearTimeout
})();
}
})(jQuery,this); })(jQuery,this);
/* Javascript plotting library for jQuery, version 0.9.0-alpha. /* Javascript plotting library for jQuery, version 0.9.0-alpha.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
*/ */
...@@ -1125,10 +1125,24 @@ Licensed under the MIT license. ...@@ -1125,10 +1125,24 @@ Licensed under the MIT license.
if (options.x2axis) { if (options.x2axis) {
options.xaxes[1] = $.extend(true, {}, options.xaxis, options.x2axis); options.xaxes[1] = $.extend(true, {}, options.xaxis, options.x2axis);
options.xaxes[1].position = "top"; options.xaxes[1].position = "top";
// Override the inherit to allow the axis to auto-scale
if (options.x2axis.min == null) {
options.xaxes[1].min = null;
}
if (options.x2axis.max == null) {
options.xaxes[1].max = null;
}
} }
if (options.y2axis) { if (options.y2axis) {
options.yaxes[1] = $.extend(true, {}, options.yaxis, options.y2axis); options.yaxes[1] = $.extend(true, {}, options.yaxis, options.y2axis);
options.yaxes[1].position = "right"; options.yaxes[1].position = "right";
// Override the inherit to allow the axis to auto-scale
if (options.y2axis.min == null) {
options.yaxes[1].min = null;
}
if (options.y2axis.max == null) {
options.yaxes[1].max = null;
}
} }
if (options.grid.coloredAreas) { if (options.grid.coloredAreas) {
options.grid.markings = options.grid.coloredAreas; options.grid.markings = options.grid.coloredAreas;
...@@ -1777,7 +1791,7 @@ Licensed under the MIT license. ...@@ -1777,7 +1791,7 @@ Licensed under the MIT license.
// Determine the axis's position in its direction and on its side // Determine the axis's position in its direction and on its side
$.each(isXAxis ? xaxes : yaxes, function(i, a) { $.each(isXAxis ? xaxes : yaxes, function(i, a) {
if (a && a.reserveSpace) { if (a && (a.show || a.reserveSpace)) {
if (a === axis) { if (a === axis) {
found = true; found = true;
} else if (a.options.position === axisPosition) { } else if (a.options.position === axisPosition) {
...@@ -1886,17 +1900,12 @@ Licensed under the MIT license. ...@@ -1886,17 +1900,12 @@ Licensed under the MIT license.
// jump as much around with replots // jump as much around with replots
$.each(allAxes(), function(_, axis) { $.each(allAxes(), function(_, axis) {
if (axis.reserveSpace && axis.ticks && axis.ticks.length) { if (axis.reserveSpace && axis.ticks && axis.ticks.length) {
var lastTick = axis.ticks[axis.ticks.length - 1];
if (axis.direction === "x") { if (axis.direction === "x") {
margins.left = Math.max(margins.left, axis.tickWidth / 2); margins.left = Math.max(margins.left, axis.tickWidth / 2);
if (lastTick.v <= axis.max) { margins.right = Math.max(margins.right, axis.tickWidth / 2);
margins.right = Math.max(margins.right, axis.tickWidth / 2);
}
} else { } else {
margins.bottom = Math.max(margins.bottom, axis.tickHeight / 2); margins.bottom = Math.max(margins.bottom, axis.tickHeight / 2);
if (lastTick.v <= axis.max) { margins.top = Math.max(margins.top, axis.tickHeight / 2);
margins.top = Math.max(margins.top, axis.tickHeight / 2);
}
} }
} }
}); });
...@@ -1931,26 +1940,20 @@ Licensed under the MIT license. ...@@ -1931,26 +1940,20 @@ Licensed under the MIT license.
} }
} }
// init axes
$.each(axes, function(_, axis) { $.each(axes, function(_, axis) {
axis.show = axis.options.show; var axisOpts = axis.options;
if (axis.show == null) { axis.show = axisOpts.show == null ? axis.used : axisOpts.show;
axis.reserveSpace = axisOpts.reserveSpace == null ? axis.show : axisOpts.reserveSpace;
// by default an axis is visible if it's got data
axis.show = axis.used;
}
axis.reserveSpace = axis.show || axis.options.reserveSpace;
setRange(axis); setRange(axis);
}); });
if (showGrid) { if (showGrid) {
var allocatedAxes = $.grep(axes, function(axis) { return axis.reserveSpace; }); var allocatedAxes = $.grep(axes, function(axis) {
return axis.show || axis.reserveSpace;
});
$.each(allocatedAxes, function(_, axis) { $.each(allocatedAxes, function(_, axis) {
// make the ticks // make the ticks
setupTickGeneration(axis); setupTickGeneration(axis);
setTicks(axis); setTicks(axis);
...@@ -2563,35 +2566,44 @@ Licensed under the MIT license. ...@@ -2563,35 +2566,44 @@ Licensed under the MIT license.
yrange.from = Math.max(yrange.from, yrange.axis.min); yrange.from = Math.max(yrange.from, yrange.axis.min);
yrange.to = Math.min(yrange.to, yrange.axis.max); yrange.to = Math.min(yrange.to, yrange.axis.max);
// then draw var xequal = xrange.from === xrange.to,
xrange.from = xrange.axis.p2c(xrange.from); yequal = yrange.from === yrange.to;
xrange.to = xrange.axis.p2c(xrange.to);
yrange.from = yrange.axis.p2c(yrange.from);
yrange.to = yrange.axis.p2c(yrange.to);
if (xrange.from !== xrange.to || xrange.from !== yrange.to) { if (xequal && yequal) {
if (xrange.from === xrange.to || yrange.from === yrange.to) { continue;
}
// draw line // then draw
ctx.beginPath(); xrange.from = Math.floor(xrange.axis.p2c(xrange.from));
ctx.strokeStyle = m.color || options.grid.markingsColor; xrange.to = Math.floor(xrange.axis.p2c(xrange.to));
ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth; yrange.from = Math.floor(yrange.axis.p2c(yrange.from));
ctx.moveTo(xrange.from, yrange.from); yrange.to = Math.floor(yrange.axis.p2c(yrange.to));
ctx.lineTo(xrange.to, yrange.to);
ctx.stroke(); if (xequal || yequal) {
var lineWidth = m.lineWidth || options.grid.markingsLineWidth,
subPixel = lineWidth % 2 ? 0.5 : 0;
ctx.beginPath();
ctx.strokeStyle = m.color || options.grid.markingsColor;
ctx.lineWidth = lineWidth;
if (xequal) {
ctx.moveTo(xrange.to + subPixel, yrange.from);
ctx.lineTo(xrange.to + subPixel, yrange.to);
} else { } else {
ctx.moveTo(xrange.from, yrange.to + subPixel);
// fill area ctx.lineTo(xrange.to, yrange.to + subPixel);
ctx.fillStyle = m.color || options.grid.markingsColor; }
ctx.stroke();
if (!m.rounded) { } else {
ctx.fillRect(xrange.from, yrange.to, ctx.fillStyle = m.color || options.grid.markingsColor;
xrange.to - xrange.from, if (m.rounded) {
yrange.from - yrange.to); roundRect(
} else { ctx, xrange.from, yrange.to, xrange.to - xrange.from,
roundRect(ctx, xrange.from, yrange.to, xrange.to - xrange.from, yrange.from - yrange.to, m.rounded); yrange.from - yrange.to, m.rounded);
ctx.fill(); ctx.fill();
} } else {
ctx.fillRect(
xrange.from, yrange.to, xrange.to - xrange.from,
yrange.from - yrange.to);
} }
} }
......
/* Flot plugin for drawing all elements of a plot on the canvas. /* Flot plugin for drawing all elements of a plot on the canvas.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
Flot normally produces certain elements, like axis labels and the legend, using Flot normally produces certain elements, like axis labels and the legend, using
......
/* Flot plugin for plotting textual data or categories. /* Flot plugin for plotting textual data or categories.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
Consider a dataset like [["February", 34], ["March", 20], ...]. This plugin Consider a dataset like [["February", 34], ["March", 20], ...]. This plugin
......
/* Flot plugin for showing crosshairs when the mouse hovers over the plot. /* Flot plugin for showing crosshairs when the mouse hovers over the plot.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The plugin supports these options: The plugin supports these options:
...@@ -145,7 +145,7 @@ The plugin also adds four public methods: ...@@ -145,7 +145,7 @@ The plugin also adds four public methods:
ctx.translate(plotOffset.left, plotOffset.top); ctx.translate(plotOffset.left, plotOffset.top);
if (crosshair.x !== -1) { if (crosshair.x !== -1) {
var adj = plot.getOptions().crosshair.lineWidth % 2 === 0 ? 0 : 0.5; var adj = plot.getOptions().crosshair.lineWidth % 2 ? 0.5 : 0;
ctx.strokeStyle = c.color; ctx.strokeStyle = c.color;
ctx.lineWidth = c.lineWidth; ctx.lineWidth = c.lineWidth;
...@@ -153,12 +153,12 @@ The plugin also adds four public methods: ...@@ -153,12 +153,12 @@ The plugin also adds four public methods:
ctx.beginPath(); ctx.beginPath();
if (c.mode.indexOf("x") !== -1) { if (c.mode.indexOf("x") !== -1) {
var drawX = Math.round(crosshair.x) + adj; var drawX = Math.floor(crosshair.x) + adj;
ctx.moveTo(drawX, 0); ctx.moveTo(drawX, 0);
ctx.lineTo(drawX, plot.height()); ctx.lineTo(drawX, plot.height());
} }
if (c.mode.indexOf("y") !== -1) { if (c.mode.indexOf("y") !== -1) {
var drawY = Math.round(crosshair.y) + adj; var drawY = Math.floor(crosshair.y) + adj;
ctx.moveTo(0, drawY); ctx.moveTo(0, drawY);
ctx.lineTo(plot.width(), drawY); ctx.lineTo(plot.width(), drawY);
} }
......
/* Flot plugin for plotting error bars. /* Flot plugin for plotting error bars.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
Error bars are used to show standard deviation and other statistical Error bars are used to show standard deviation and other statistical
......
/* Flot plugin for computing bottoms for filled line and bar charts. /* Flot plugin for computing bottoms for filled line and bar charts.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The case: you've got two series that you want to fill the area between. In Flot The case: you've got two series that you want to fill the area between. In Flot
......
/* Flot plugin for plotting images. /* Flot plugin for plotting images.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The data syntax is [ [ image, x1, y1, x2, y2 ], ... ] where (x1, y1) and The data syntax is [ [ image, x1, y1, x2, y2 ], ... ] where (x1, y1) and
......
/* Flot plugin for adding the ability to pan and zoom the plot. /* Flot plugin for adding the ability to pan and zoom the plot.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The default behaviour is double click and scrollwheel up/down to zoom in, drag The default behaviour is double click and scrollwheel up/down to zoom in, drag
...@@ -245,8 +245,8 @@ can set the default in the options. ...@@ -245,8 +245,8 @@ can set the default in the options.
var range = max - min; var range = max - min;
if (zr && if (zr &&
((zr[0] != null && range < zr[0]) || ((zr[0] != null && range < zr[0] && amount > 1) ||
(zr[1] != null && range > zr[1]))) { (zr[1] != null && range > zr[1] && amount < 1))) {
return; return;
} }
......
/* Flot plugin for rendering pie charts. /* Flot plugin for rendering pie charts.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The plugin assumes that each series has a single data value, and that each The plugin assumes that each series has a single data value, and that each
...@@ -225,13 +225,17 @@ More detail and specific examples can be found in the included HTML file. ...@@ -225,13 +225,17 @@ More detail and specific examples can be found in the included HTML file.
for (i = 0; i < data.length; ++i) { for (i = 0; i < data.length; ++i) {
value = data[i].data[0][1]; value = data[i].data[0][1];
if (numCombined < 2 || value / total > options.series.pie.combine.threshold) { if (numCombined < 2 || value / total > options.series.pie.combine.threshold) {
newdata.push({ newdata.push(
data: [[1, value]], // Use extend rather than replacing, so other original
color: data[i].color, // data values can be used, e.g. in labelFormatter.
label: data[i].label, $.extend(data[i], {
angle: value * Math.PI * 2 / total, data: [[1, value]],
percent: value / (total / 100) color: data[i].color,
}); label: data[i].label,
angle: value * Math.PI * 2 / total,
percent: value / (total / 100)
})
);
} }
} }
......
/* Flot plugin for automatically redrawing plots as the placeholder resizes. /* Flot plugin for automatically redrawing plots as the placeholder resizes.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
It works by listening for changes on the placeholder div (through the jQuery It works by listening for changes on the placeholder div (through the jQuery
......
/* Flot plugin for selecting regions of a plot. /* Flot plugin for selecting regions of a plot.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The plugin supports these options: The plugin supports these options:
......
/* Flot plugin for stacking data sets rather than overlyaing them. /* Flot plugin for stacking data sets rather than overlyaing them.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The plugin assumes the data is sorted on x (or y if stacking horizontally). The plugin assumes the data is sorted on x (or y if stacking horizontally).
......
/* Flot plugin that adds some extra symbols for plotting points. /* Flot plugin that adds some extra symbols for plotting points.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The symbols are accessed as strings through the standard symbol options: The symbols are accessed as strings through the standard symbol options:
......
/* Flot plugin for thresholding data. /* Flot plugin for thresholding data.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
The plugin supports these options: The plugin supports these options:
......
/* Pretty handling of time axes. /* Pretty handling of time axes.
Copyright (c) 2007-2013 IOLA and Ole Laursen. Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license. Licensed under the MIT license.
Set axis.mode to "time" to enable. See the section "Time series data" in Set axis.mode to "time" to enable. See the section "Time series data" in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment