Skip to content

Commit

Permalink
prepare 0.9 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Urbas committed Jul 26, 2016
1 parent dae90b2 commit 46be41a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 61 deletions.
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## For developers/contributors

If you wish to contribute, please do so by editing the jquery.flot.tooltip.source.js file. The other .js files are built with Grunt and should not be directly edited.

When working with external plugin support, you can use the array plotPlugins (via this.plotPlugins), which is a collection of the names of the currently loaded Flot plugins. For instance if checking for the existance of the official
symbol plugin, you would check `if ($.inArray('symbol', this.plotPlugins) !== -1)`.

There exists a Gruntfile.js for development purposes, but please do not commit built production or minified .js files when making a pull request. Additionally, do not change the version, because the new version could vary depending on
when the pull request is merged and how many other changes were made at the same time.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,13 @@ In comments there are default values

## For developers/contributors

If you wish to contribute, please do so by editing the jquery.flot.tooltip.source.js file. The other .js files are built with Grunt and should not be directly edited.
See CONTRIBUTING.md

When working with external plugin support, you can use the array plotPlugins (via this.plotPlugins), which is a collection of the names of the currently loaded Flot plugins. For instance if checking for the existance of the official
symbol plugin, you would check `if ($.inArray('symbol', this.plotPlugins) !== -1)`.
## Changelog

There exists a Gruntfile.js for development purposes, but please do not commit built production or minified .js files when making a pull request. Additionally, do not change the version, because the new version could vary depending on
when the pull request is merged and how many other changes were made at the same time.
### v0.9.0

## Changelog
- merged pull requests: [#140](https://github.com/krzysu/flot.tooltip/pull/140), [#142](https://github.com/krzysu/flot.tooltip/pull/142)

### v0.8.7

Expand Down
54 changes: 28 additions & 26 deletions js/jquery.flot.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ($) {
Expand All @@ -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,
Expand Down Expand Up @@ -260,18 +260,19 @@
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;
}

/*
/*
The section applies the new positioning ONLY if pos.x and pos.y
are numbers. If they are undefined or not a number, use the last
known numerical position. This hack fixes a bug that kept pie
known numerical position. This hack fixes a bug that kept pie
charts from keeping their tooltip positioning.
*/

if (isNaN(pos.x)) {
that.tipPosition.x = that.tipPosition.xPrev;
}
Expand All @@ -286,7 +287,7 @@
that.tipPosition.y = pos.y;
that.tipPosition.yPrev = pos.y;
}

};

// Quick little function for showing the tooltip.
Expand Down Expand Up @@ -333,7 +334,7 @@
if( $tip.length === 0 ){
$tip = $('<div />').addClass(this.tooltipOptions.cssClass);
$tip.appendTo('body').hide().css({position: 'absolute'});

if(this.tooltipOptions.defaultTheme) {
$tip.css({
'background': '#fff',
Expand Down Expand Up @@ -370,7 +371,7 @@
var yPatternWithoutPrecision = "%y";
var customTextPattern = "%ct";
var nPiePattern = "%n";

var x, y, customText, p, n;

// for threshold plugin we need to read data from different place
Expand All @@ -385,7 +386,7 @@
x = item.datapoint[0];
y = item.datapoint[1];
}

else if (typeof item.series.lines !== "undefined" && item.series.lines.steps) {
x = item.series.datapoints.points[item.dataIndex * 2];
y = item.series.datapoints.points[item.dataIndex * 2 + 1];
Expand All @@ -412,41 +413,42 @@
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') {
p = item.series.percent;
} else if (typeof (item.series.percents) !== 'undefined') {
p = item.series.percents[item.dataIndex];
}
}
if (typeof p === 'number') {
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') {
content = content.replace(seriesPattern, item.series.label);
} else {
//remove %s if label is undefined
content = content.replace(seriesPattern, "");
}

// color match
if (typeof(item.series.color) !== 'undefined') {
content = content.replace(colorPattern, item.series.color);
Expand Down
Loading

0 comments on commit 46be41a

Please sign in to comment.