Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip does not replace x label by given x. #18

Closed
jevanlingen opened this issue Feb 5, 2013 · 4 comments
Closed

Tooltip does not replace x label by given x. #18

jevanlingen opened this issue Feb 5, 2013 · 4 comments
Labels

Comments

@jevanlingen
Copy link

If you have given your xaxis your own label with ticks, the tooltip does not show those ticks.

E.G.

data: [ [0, 450], [1, 550], [2, 320], [3, 700] ],
xaxis: {
     ticks: [
       [0, "great"],
       [1, "greater"],
       [2, "greatest"]
     ]
}   

Could you fix this in your next version?


N.B. For those whom need a quick fix, go to your jquery.flot.tooltip to line 181.

There you should see:

if(typeof item.series.xaxis.tickFormatter !== 'undefined') {

Change that line to:

 if(typeof item.series.xaxis.tickFormatter !== 'undefined' && item.series.xaxis.ticks.length == 0) {

And add above these line:

// change x from number to given label, if given
if(item.series.xaxis.ticks.length != 0) {
   content = content.replace(xPattern, item.series.xaxis.ticks[item.dataIndex].label);
}

Done :D.

@krzysu
Copy link
Owner

krzysu commented Feb 5, 2013

good job, you can always send pull request with the change

@jevanlingen
Copy link
Author

Missed some things, so my code was wrong. Change code to:

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

// if no value customization, use tickFormatter by default
if(typeof item.series.xaxis.tickFormatter !== 'undefined' && (item.series.xaxis.ticks === 'undefined' || item.series.xaxis.ticks.length == 0 || this.isTimeMode('xaxis', item))) {

@lmacko
Copy link
Contributor

lmacko commented Sep 3, 2013

nice I was looking for something like this. I use a workaround with tickFormatter your solution looks better. Do you plan to send a pull request, @jevanlingen ?

@emakarov
Copy link

Hi
Could you post a short example how to display tick labels in tooltips?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants