Skip to content

Commit e2dbb40

Browse files
committed
0.8.5 release
1 parent 214f1d2 commit e2dbb40

6 files changed

+44
-21
lines changed

README.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ __Important!__ You need to set flot option `hoverable` to `true` if you want flo
3030

3131
In comments there are default values
3232

33-
tooltip: boolean //false
34-
tooltipOpts: {
35-
id: string //"flotTip"
33+
tooltip: {
34+
show: boolean //false
35+
cssClass: string //"flotTip"
3636
content: string or function //"%s | X: %x | Y: %y"
3737
xDateFormat: string //null
3838
yDateFormat: string //null
@@ -45,16 +45,17 @@ In comments there are default values
4545
defaultTheme: boolean //true
4646
lines: boolean //false
4747
onHover: function(flotItem, $tooltipEl)
48-
compat: boolean //false
48+
$compat: boolean //false
4949
}
5050

5151

52-
- `tooltip` : set to `true` to turn on this plugin (if `grid.hoverable` is also set to `true`)
53-
- `id` : the id to assign to the tooltip's HTML DIV element, defaulted to "flotTip"
52+
- `show` : set to `true` to turn on this plugin (if `grid.hoverable` is also set to `true`)
53+
- `cssClass` : the class to assign to the tooltip's HTML DIV element, defaulted to "flotTip"
5454
- `content` : content of your tooltip, HTML tags are also allowed; use `%s` for series label, `%x` for X value, `%y` for Y value and `%p` for percentage value (useful with pie charts using flot.pie plugin)
55-
With `%x`, `%y` and `%p` values you can also use `.precision`, for example `%x.2` means that value of X will be rounded to 2 digits after the decimal point.
55+
With `%x`, `%y` and `%p` values you can also use `.precision`, for example `%x.2` means that value of X will be rounded to 2 digits after the decimal point.
5656
If no precision or dateFormat is set then plugin uses tickFormatter to format values displayed on tooltip.
5757
If you require even more control over how the tooltip is generated you can pass a callback `function(label, xval, yval, flotItem)` that must return a string with the format described.
58+
The content callback function pass may also return a boolean value of false (or empty string) if the tooltip is to be hidden for the given data point.
5859
Pull request [#64](https://github.com/krzysu/flot.tooltip/pull/64) introduced two more placeholders `%lx` and `%ly`, that work with flot-axislabels plugin.
5960
Pull request [#75](https://github.com/krzysu/flot.tooltip/pull/75) introduced `%ct` placeholder for any custom text withing label (see example in `examples/custom-label-text.html`)
6061
- `xDateFormat` : you can use the same specifiers as in Flot, for time mode data
@@ -89,7 +90,17 @@ when the pull request is merged and how many other changes were made at the same
8990
## Changelog
9091

9192

92-
### What's new in v0.8.4?
93+
### What's new in v0.8.5?
94+
95+
- IMPORTANT NOTE A: while a legacy check exists, the options object format has changed to be a single object `tooltip` with a property `show` (defaulted to false). The legacy check may not always exist, so it may be a good idea to update your production code.
96+
- IMPORTANT NOTE B: while there's a legacy check for the options object, there is not one for the id-to-class change (see below). This change will be far less relevant to developers, as it only matters when adding custom CSS styling. If your implementation does so, make sure you change your selectors with the new version!
97+
- merged pull requests: [#95](https://github.com/krzysu/flot.tooltip/pull/95), [#98](https://github.com/krzysu/flot.tooltip/pull/98), [#99](https://github.com/krzysu/flot.tooltip/pull/99), [#103](https://github.com/krzysu/flot.tooltip/pull/103)
98+
- corrected some errors in the documentation
99+
- improved line tracking feature - now utilizes flot's plot object's grid.mouseActiveRadius option for threshold and is based off pixel distance instead of data.
100+
- changed the id option to cssClass instead. This means the option is now cssClass instead of id, and will (obviously) be assigned as a class instead of an id. Therefore, any relevant CSS selectors need to be changed as well.
101+
- added fix that should allow x axis value to work properly in some multiple-series implementations
102+
103+
### v0.8.4
93104

94105
- merged pull request [#87](https://github.com/krzysu/flot.tooltip/pull/87), adding compatibility with jQuery < 1.2.6
95106
- added new API functions to Flot's base plot object:

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flot.tooltip",
3-
"version": "0.8.4",
3+
"version": "0.8.5",
44
"license": "MIT",
55
"main": "js/jquery.flot.tooltip.js",
66
"ignore": [

js/jquery.flot.tooltip.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* jquery.flot.tooltip
33
*
44
* description: easy-to-use tooltips for Flot charts
5-
* version: 0.8.4
5+
* version: 0.8.5
66
* authors: Krzysztof Urbas @krzysu [myviews.pl],Evan Steinkerchner @Roundaround
77
* website: https://github.com/krzysu/flot.tooltip
88
*
9-
* build on 2015-05-10
9+
* build on 2015-05-11
1010
* released under MIT License, 2012
1111
*/
1212
(function ($) {
@@ -43,6 +43,9 @@
4343
}
4444
};
4545

46+
// dummy default options object for legacy code (<0.8.5) - is deleted later
47+
defaultOptions.tooltipOpts = defaultOptions.tooltip;
48+
4649
// object
4750
var FlotTooltip = function (plot) {
4851
// variables
@@ -70,6 +73,13 @@
7073
// get plot options
7174
that.plotOptions = plot.getOptions();
7275

76+
// for legacy (<0.8.5) implementations
77+
if (typeof(that.plotOptions.tooltip) === 'boolean') {
78+
that.plotOptions.tooltipOpts.show = that.plotOptions.tooltip;
79+
that.plotOptions.tooltip = that.plotOptions.tooltipOpts;
80+
delete that.plotOptions.tooltipOpts;
81+
}
82+
7383
// if not enabled return
7484
if (that.plotOptions.tooltip.show === false || typeof that.plotOptions.tooltip.show === 'undefined') return;
7585

@@ -401,10 +411,12 @@
401411
// see https://github.com/krzysu/flot.tooltip/issues/65
402412
var tickIndex = item.dataIndex + item.seriesIndex;
403413

404-
if (item.series.xaxis[ticks].length > tickIndex && !this.isTimeMode('xaxis', item)) {
405-
var valueX = (this.isCategoriesMode('xaxis', item)) ? item.series.xaxis[ticks][tickIndex].label : item.series.xaxis[ticks][tickIndex].v;
406-
if (valueX === x) {
407-
content = content.replace(xPattern, item.series.xaxis[ticks][tickIndex].label);
414+
for (var index in item.series.xaxis[ticks]) {
415+
if (item.series.xaxis[ticks].hasOwnProperty(tickIndex) && !this.isTimeMode('xaxis', item)) {
416+
var valueX = (this.isCategoriesMode('xaxis', item)) ? item.series.xaxis[ticks][tickIndex].label : item.series.xaxis[ticks][tickIndex].v;
417+
if (valueX === x) {
418+
content = content.replace(xPattern, item.series.xaxis[ticks][tickIndex].label);
419+
}
408420
}
409421
}
410422
}
@@ -499,7 +511,7 @@
499511
init: init,
500512
options: defaultOptions,
501513
name: 'tooltip',
502-
version: '0.8.4'
514+
version: '0.8.5'
503515
});
504516

505517
})(jQuery);

0 commit comments

Comments
 (0)