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

Piechart tooltip content: '%p%, Series1' #35

Closed
darsee opened this issue Jul 10, 2013 · 4 comments
Closed

Piechart tooltip content: '%p%, Series1' #35

darsee opened this issue Jul 10, 2013 · 4 comments

Comments

@darsee
Copy link

darsee commented Jul 10, 2013

I've just cloned the repository and am running the examples.

For examples/pie.html, when I hover over a segment, the tooltip content is %p%, Series1.

If I comment out tooltipOpts.content in pie.html, the tooltip content is Series1 | X: %x | Y:%y.

I'm looking into this now, but wondering if you can see anything obvious?

@mmahomar
Copy link

Hi, I have the same issue, it seems to be with the adjustValPrecision function in Pie percentage.
I did a temp fix:

Replaced Line 167 from this:
content = this.adjustValPrecision(percentPattern, content, item.series.percent);

to this:
content = content.replace(percentPattern, parseFloat(item.series.percent).toFixed(2) + '%');

Still have to find out what the problem is with the precision function.

@krzysu krzysu closed this as completed in b36576d Jul 10, 2013
@krzysu
Copy link
Owner

krzysu commented Jul 10, 2013

I wonder why the problem exists only for pie charts, but check my commit details to see how to make it work, I hope it will be enough in your use cases.

@darsee
Copy link
Author

darsee commented Jul 11, 2013

Thanks for the update! Percentage is working for pie charts.

I'm working on a project that uses flot.tooltip v0.4.4, with tooltipOpts.content for pie charts set to %s: %y, which correctly displays as "Series 1: 10". When I replace v0.4.4 with the latest version, the tooltip content displays as "Series 1: %y'.

I can get the correct content to display if I set tooltipOpts.content to %s: %y.0 and change

var yPattern = /%y\.{0,1}(?:\d{0,})/;

to

var yPattern = /%y\.{0,1}(\d{0,})/;

I see that the :? in the patterns was added as part of a fix to #16 so I'm not sure how to reconcile both use cases here - I usually try to stay far away from RegEx's :)

@krzysu
Copy link
Owner

krzysu commented Jul 11, 2013

To be honest I am also not sure what is the best solution for all the issues. Looks like fix for one causes problems with others :/

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

No branches or pull requests

3 participants