Update flot-tooltip to 0.9.0

This commit is contained in:
Garret Wassermann 2017-05-26 16:05:19 -04:00
parent 1e9c4888b9
commit 23898fbf35
3 changed files with 59 additions and 55 deletions

View File

@ -2,11 +2,11 @@
* jquery.flot.tooltip
*
* description: easy-to-use tooltips for Flot charts
* version: 0.8.7
* version: 0.9.0
* authors: Krzysztof Urbas @krzysu [myviews.pl],Evan Steinkerchner @Roundaround
* website: https://github.com/krzysu/flot.tooltip
*
* build on 2016-03-15
* build on 2016-07-26
* released under MIT License, 2012
*/
(function ($) {
@ -25,7 +25,7 @@
// %y -> Y value,
// %x.2 -> precision of X value,
// %p -> percent
// %n -> value (not percent) of pie chart
// %n -> value (not percent) of pie chart
xDateFormat: null,
yDateFormat: null,
monthNames: null,
@ -260,6 +260,7 @@
var totalTipHeight = $tip.outerHeight() + that.tooltipOptions.shifts.y;
if ((pos.x - $(window).scrollLeft()) > ($(window)[that.wfunc]() - totalTipWidth)) {
pos.x -= totalTipWidth;
pos.x = Math.max(pos.x, 0);
}
if ((pos.y - $(window).scrollTop()) > ($(window)[that.hfunc]() - totalTipHeight)) {
pos.y -= totalTipHeight;
@ -299,7 +300,7 @@
return;
$tip.html(tipText);
plot.setTooltipPosition({ x: position.pageX, y: position.pageY });
plot.setTooltipPosition({ x: that.tipPosition.x, y: that.tipPosition.y });
$tip.css({
left: that.tipPosition.x + that.tooltipOptions.shifts.x,
top: that.tipPosition.y + that.tooltipOptions.shifts.y
@ -412,12 +413,13 @@
return '';
}
/* replacement of %ct and other multi-character templates must
precede the replacement of single-character templates
to avoid conflict between '%c' and '%ct' and similar substrings
*/
if (customText)
/* replacement of %ct and other multi-character templates must
precede the replacement of single-character templates
to avoid conflict between '%c' and '%ct' and similar substrings
*/
if (customText) {
content = content.replace(customTextPattern, customText);
}
// percent match for pie charts and stacked percent
if (typeof (item.series.percent) !== 'undefined') {
@ -429,15 +431,15 @@
content = this.adjustValPrecision(percentPattern, content, p);
}
// replace %n with number of items represented by slice in pie charts
if (item.series.hasOwnProperty('pie')) {
if (typeof (item.series.data[0][1] !== 'undefined')) {
n = item.series.data[0][1];
}
}
if (typeof n === 'number') {
// replace %n with number of items represented by slice in pie charts
if (item.series.hasOwnProperty('pie')) {
if (typeof item.series.data[0][1] !== 'undefined') {
n = item.series.data[0][1];
}
}
if (typeof n === 'number') {
content = content.replace(nPiePattern, n);
}
}
// series match
if (typeof(item.series.label) !== 'undefined') {

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@
// %y -> Y value,
// %x.2 -> precision of X value,
// %p -> percent
// %n -> value (not percent) of pie chart
// %n -> value (not percent) of pie chart
xDateFormat: null,
yDateFormat: null,
monthNames: null,
@ -249,6 +249,7 @@
var totalTipHeight = $tip.outerHeight() + that.tooltipOptions.shifts.y;
if ((pos.x - $(window).scrollLeft()) > ($(window)[that.wfunc]() - totalTipWidth)) {
pos.x -= totalTipWidth;
pos.x = Math.max(pos.x, 0);
}
if ((pos.y - $(window).scrollTop()) > ($(window)[that.hfunc]() - totalTipHeight)) {
pos.y -= totalTipHeight;
@ -288,7 +289,7 @@
return;
$tip.html(tipText);
plot.setTooltipPosition({ x: position.pageX, y: position.pageY });
plot.setTooltipPosition({ x: that.tipPosition.x, y: that.tipPosition.y });
$tip.css({
left: that.tipPosition.x + that.tooltipOptions.shifts.x,
top: that.tipPosition.y + that.tooltipOptions.shifts.y
@ -401,12 +402,13 @@
return '';
}
/* replacement of %ct and other multi-character templates must
precede the replacement of single-character templates
to avoid conflict between '%c' and '%ct' and similar substrings
*/
if (customText)
/* replacement of %ct and other multi-character templates must
precede the replacement of single-character templates
to avoid conflict between '%c' and '%ct' and similar substrings
*/
if (customText) {
content = content.replace(customTextPattern, customText);
}
// percent match for pie charts and stacked percent
if (typeof (item.series.percent) !== 'undefined') {
@ -418,15 +420,15 @@
content = this.adjustValPrecision(percentPattern, content, p);
}
// replace %n with number of items represented by slice in pie charts
if (item.series.hasOwnProperty('pie')) {
if (typeof (item.series.data[0][1] !== 'undefined')) {
n = item.series.data[0][1];
}
}
if (typeof n === 'number') {
// replace %n with number of items represented by slice in pie charts
if (item.series.hasOwnProperty('pie')) {
if (typeof item.series.data[0][1] !== 'undefined') {
n = item.series.data[0][1];
}
}
if (typeof n === 'number') {
content = content.replace(nPiePattern, n);
}
}
// series match
if (typeof(item.series.label) !== 'undefined') {