angularjs-nvd3-directives / angularjs-nvd3-directives

Angular.js directives for nvd3.js
http://angularjs-nvd3-directives.github.io/angularjs-nvd3-directives
Apache License 2.0
1.18k stars 303 forks source link

attributes for tooltips, inconsistency with casing/dashes. #253

Open jmarq opened 10 years ago

jmarq commented 10 years ago

the line chart directives 'want' the tooltipcontent scope variable, passed in as the tooltipcontent attribute.

the scatter chart directive,however, 'wants' tooltipYContent, tooltipContent, tooltipXContent scope variables, which need to be passed in as attributes "tooltip-y-content", "tooltip-content", "tooltip-x-content" because of the way camel casing and dashes work in angular.

the scatter plot directive link function code (like line #1993), however, checks for existence of tooltipycontent, tooltipxcontent attributes, which are NOT the same as above, because of casing/dashes. if those don't exist, then it uses the default tooltip functions. if those attrs DO exist, then it tries to use tooltipXContent and tooltipYContent scope variables. In other words, it checks for one attribute, but then uses a different one, when it should be using the same one it checks for. The difference is the casing/dashes.

so, in order for custom tooltips to work on a scatter plot, I have to pass the directive 4 attributes: tooltipycontent="true", tooltipxcontent="true" (so my functions get used rather than default), and the actual functions, tooltip-y-content="myYFunction", tooltip-x-content="myXFunction"

I also have to remember that line charts want "tooltipcontent" while scatters want "tooltip-content" for the attribute. This doesn't seem like intended behavior, so I thought I'd let you know!

softwords commented 9 years ago

Same applies to forcex, forcey, forcesize in the scatter chart. In all such cases, it's probably best for the name in the directive to exactly match the name used by nv-d3. nv-d3 uses tooltipContent everywhere, so perhaps it would be better to standardise with that - ie in directive we have tooltipContent, and attribute is tooltip-content throughout. Similarly force-x, force-y, force-size etc

JonathanSeguin commented 9 years ago

Woah thanks for pointing this out. I've been trying to understand why my scatterplot tooltips weren't showing up...