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 & axis formatting decoupling #428

Closed
milroc opened this issue Jan 29, 2014 · 20 comments
Closed

tooltip & axis formatting decoupling #428

milroc opened this issue Jan 29, 2014 · 20 comments

Comments

@milroc
Copy link

@milroc milroc commented Jan 29, 2014

nvd3 tightly couples the axis formatting to the tooltip display format, without anyway for the developer to override it.

http://stackoverflow.com/questions/19424344/nvd3-js-yaxis-and-tooltip-different-percision is an example of this limitation for a line graph.

It is however everywhere in the nvd3 library. Was this by design?

@emwalker
Copy link

@emwalker emwalker commented Apr 25, 2014

Another example that would be nice to be able to deal with would be an x-axis that shows dates in %m/%y and a tooltip that shows dates using %m/%d/%y.

@brettjonesdev
Copy link

@brettjonesdev brettjonesdev commented May 1, 2014

I have also found this limitation to be rather frustrating. It would be really nice to be able to use a custom tooltip function when using interactiveGuideline: true. Unfortunately, it looks like the function which draws the default interactive guideline tooltip ( contentGenerator) is buried deep within the library, and there does not appear to be a way to override it, except by modifying the source code (no thanks!).

It would be fantastic if there were an option one could pass to override this function, much like .tooltipContent() for the non-interactiveGuideline tooltip has.

@joejansen
Copy link

@joejansen joejansen commented Jun 7, 2014

+1

7 similar comments
@fernoftheandes
Copy link

@fernoftheandes fernoftheandes commented Jun 9, 2014

+1

@mbukosky
Copy link

@mbukosky mbukosky commented Jun 9, 2014

+1

@atlefren
Copy link

@atlefren atlefren commented Jul 10, 2014

+1

@searope
Copy link

@searope searope commented Jul 21, 2014

+1

@ggviana
Copy link

@ggviana ggviana commented Jul 24, 2014

+1

@vlenivenkogmail
Copy link

@vlenivenkogmail vlenivenkogmail commented Aug 26, 2014

+1

@abratchun
Copy link

@abratchun abratchun commented Aug 26, 2014

+1

@sherin
Copy link

@sherin sherin commented Sep 7, 2014

Forked the project and added customization functionality for interactive-guideline styled tooltips. For now, this is restricted to tooltip header and line charts but I will extend it. (We needed the tooltip to show "Aug 01 5 PM - 6 PM" instead of the default x-axis format.) Hope it helps :)

https://github.com/sherinkurian/nvd3

@pedrokost
Copy link

@pedrokost pedrokost commented Nov 10, 2014

+1

@jenslonkowski
Copy link

@jenslonkowski jenslonkowski commented Feb 10, 2015

Another solution for me is to use the context (this) as a conditional inside the tickFormat function:

function(d) {
    // case for tooltip
    if (this === window) return ...;
    // case for axis
    return ...;
}

This is working well if you don't show the min/max values on the axes like I do. Otherwise you probably could adjust the condition.

@liquidpele
Copy link
Contributor

@liquidpele liquidpele commented Feb 10, 2015

Probably worth doing this, tagging as enhancement request.

@floribon
Copy link
Contributor

@floribon floribon commented Feb 14, 2015

+1, for now using @jenslonkowski hack. This only allows to edit the heading, a full control over the template would be highly preferable.

@jufemaiz
Copy link

@jufemaiz jufemaiz commented Mar 2, 2015

Any thoughts?

When combined with using full conditional date for the xAxis it's kinda critical.

@robinfhu
Copy link
Member

@robinfhu robinfhu commented Mar 2, 2015

I recognize it's not obvious, but there should be a way to override that tooltip.

Try this:

lineChart.interactiveLayer.tooltip.contentGenerator( ...your function...)

@liquidpele
Copy link
Contributor

@liquidpele liquidpele commented Mar 2, 2015

lineChart.interactiveLayer.tooltip.contentGenerator( ...your function...)

Yup, I do that exact thing for the ohlcChart to override the tooltip from historicalBarChart.

@robinfhu
Copy link
Member

@robinfhu robinfhu commented Mar 2, 2015

PR opened.

@robinfhu robinfhu closed this Mar 2, 2015
@diaabaraka
Copy link

@diaabaraka diaabaraka commented Oct 2, 2017

@jenslonkowski Nice Hack!

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

Successfully merging a pull request may close this issue.

None yet