Skip to content

Commit

Permalink
0.8.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Roundaround committed May 11, 2015
1 parent 214f1d2 commit e2dbb40
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ __Important!__ You need to set flot option `hoverable` to `true` if you want flo

In comments there are default values

tooltip: boolean //false
tooltipOpts: {
id: string //"flotTip"
tooltip: {
show: boolean //false
cssClass: string //"flotTip"
content: string or function //"%s | X: %x | Y: %y"
xDateFormat: string //null
yDateFormat: string //null
Expand All @@ -45,16 +45,17 @@ In comments there are default values
defaultTheme: boolean //true
lines: boolean //false
onHover: function(flotItem, $tooltipEl)
compat: boolean //false
$compat: boolean //false
}


- `tooltip` : set to `true` to turn on this plugin (if `grid.hoverable` is also set to `true`)
- `id` : the id to assign to the tooltip's HTML DIV element, defaulted to "flotTip"
- `show` : set to `true` to turn on this plugin (if `grid.hoverable` is also set to `true`)
- `cssClass` : the class to assign to the tooltip's HTML DIV element, defaulted to "flotTip"
- `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)
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.
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.
If no precision or dateFormat is set then plugin uses tickFormatter to format values displayed on tooltip.
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.
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.
Pull request [#64](https://github.com/krzysu/flot.tooltip/pull/64) introduced two more placeholders `%lx` and `%ly`, that work with flot-axislabels plugin.
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`)
- `xDateFormat` : you can use the same specifiers as in Flot, for time mode data
Expand Down Expand Up @@ -89,7 +90,17 @@ when the pull request is merged and how many other changes were made at the same
## Changelog


### What's new in v0.8.4?
### What's new in v0.8.5?

- 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.
- 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!
- 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)
- corrected some errors in the documentation
- 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.
- 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.
- added fix that should allow x axis value to work properly in some multiple-series implementations

### v0.8.4

- merged pull request [#87](https://github.com/krzysu/flot.tooltip/pull/87), adding compatibility with jQuery < 1.2.6
- added new API functions to Flot's base plot object:
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flot.tooltip",
"version": "0.8.4",
"version": "0.8.5",
"license": "MIT",
"main": "js/jquery.flot.tooltip.js",
"ignore": [
Expand Down
26 changes: 19 additions & 7 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.4
* version: 0.8.5
* authors: Krzysztof Urbas @krzysu [myviews.pl],Evan Steinkerchner @Roundaround
* website: https://github.com/krzysu/flot.tooltip
*
* build on 2015-05-10
* build on 2015-05-11
* released under MIT License, 2012
*/
(function ($) {
Expand Down Expand Up @@ -43,6 +43,9 @@
}
};

// dummy default options object for legacy code (<0.8.5) - is deleted later
defaultOptions.tooltipOpts = defaultOptions.tooltip;

// object
var FlotTooltip = function (plot) {
// variables
Expand Down Expand Up @@ -70,6 +73,13 @@
// get plot options
that.plotOptions = plot.getOptions();

// for legacy (<0.8.5) implementations
if (typeof(that.plotOptions.tooltip) === 'boolean') {
that.plotOptions.tooltipOpts.show = that.plotOptions.tooltip;
that.plotOptions.tooltip = that.plotOptions.tooltipOpts;
delete that.plotOptions.tooltipOpts;
}

// if not enabled return
if (that.plotOptions.tooltip.show === false || typeof that.plotOptions.tooltip.show === 'undefined') return;

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

if (item.series.xaxis[ticks].length > tickIndex && !this.isTimeMode('xaxis', item)) {
var valueX = (this.isCategoriesMode('xaxis', item)) ? item.series.xaxis[ticks][tickIndex].label : item.series.xaxis[ticks][tickIndex].v;
if (valueX === x) {
content = content.replace(xPattern, item.series.xaxis[ticks][tickIndex].label);
for (var index in item.series.xaxis[ticks]) {
if (item.series.xaxis[ticks].hasOwnProperty(tickIndex) && !this.isTimeMode('xaxis', item)) {
var valueX = (this.isCategoriesMode('xaxis', item)) ? item.series.xaxis[ticks][tickIndex].label : item.series.xaxis[ticks][tickIndex].v;
if (valueX === x) {
content = content.replace(xPattern, item.series.xaxis[ticks][tickIndex].label);
}
}
}
}
Expand Down Expand Up @@ -499,7 +511,7 @@
init: init,
options: defaultOptions,
name: 'tooltip',
version: '0.8.4'
version: '0.8.5'
});

})(jQuery);
Loading

5 comments on commit e2dbb40

@mojoaxel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the syntax changed I think this should be released as 0.9.0 instead of 0.8.5

@Roundaround
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mayhaps, but I was saving the 0.9.0 version for when we removed the legacy support. At this point, it's really not practical to change the version anyway since it's been release for quite some time now.

@mojoaxel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the problem that an automatic bower update from v0.8.4 to v0.8.5 broke my code.
bower expects semantic versioning, were patch revisions should not break backwards compatibility.

By the way, is v0.8.6 already on the horizon?

@Roundaround
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to say. We definitely could release the work of @kenirwin as a minor update, but I've been especially busy these last few weeks and so a bit unable to review all of the changes made or to run tests.

Apologies for the automatic bower update breaking the code though. It was surely an oversight on my part. I'll be more careful with the versioning in the future.

@krzysu
Copy link
Owner

@krzysu krzysu commented on e2dbb40 Jul 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mojoaxel is right, we should not break backwards compatibility with patch version, that is important to deliver code people can relay on

Please sign in to comment.