Skip to content

Commit

Permalink
Merge pull request #66 from vitorbaptista/master
Browse files Browse the repository at this point in the history
Fix tooltip when displaying multiple series
  • Loading branch information
Kris Urbas committed Mar 14, 2014
2 parents 744ea16 + d21ecc5 commit 98de0bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions js/jquery.flot.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* author: Krzysztof Urbas @krzysu [myviews.pl]
* website: https://github.com/krzysu/flot.tooltip
*
* build on 2014-02-10
* build on 2014-03-10
* released under MIT License, 2012
*/
(function ($) {
Expand Down Expand Up @@ -224,8 +224,9 @@

// change x from number to given label, if given
if(typeof item.series.xaxis.ticks !== 'undefined') {
if(item.series.xaxis.ticks.length > item.dataIndex && !this.isTimeMode('xaxis', item))
content = content.replace(xPattern, item.series.xaxis.ticks[item.dataIndex].label);
var tickIndex = item.dataIndex + item.seriesIndex;
if(item.series.xaxis.ticks.length > tickIndex && !this.isTimeMode('xaxis', item))
content = content.replace(xPattern, item.series.xaxis.ticks[tickIndex].label);
}

// change y from number to given label, if given
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.flot.tooltip.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions js/jquery.flot.tooltip.source.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@

// change x from number to given label, if given
if(typeof item.series.xaxis.ticks !== 'undefined') {
if(item.series.xaxis.ticks.length > item.dataIndex && !this.isTimeMode('xaxis', item))
content = content.replace(xPattern, item.series.xaxis.ticks[item.dataIndex].label);
var tickIndex = item.dataIndex + item.seriesIndex;
if(item.series.xaxis.ticks.length > tickIndex && !this.isTimeMode('xaxis', item))
content = content.replace(xPattern, item.series.xaxis.ticks[tickIndex].label);
}

// change y from number to given label, if given
Expand Down

0 comments on commit 98de0bc

Please sign in to comment.