I'm using the nvd3.js line with focus chart ( view finder ) model for a project. There are customizations that i need to add to this example -- such as different types of annotation overlays on top of the graph.
There's a couple ways i can see tackling this:
1. I could extend the nvd3 chart models to create one that does what i need ( that seems like a lot of work at the moment )
2. I can find the right interfaces in the existing nvd3 chart models and write my own d3 stuff to create annotations ( this seemed easier, and so i went down this route )
I've figured out most of what i need except how to get the chart's svg screen position for a value from my xScale ( d3.linear.scale() ). Once i have the correct screen position within the nvd3 chart i can make my annotation overlay in the correct spots.
Question: Does anyone know if there's an interface in nvd3 charts to calculate the chart's screen position from an xScale value? If there's no easy interface, how could i solve this problem?
Thanks
UPDATE: It looks like i had all the correct information to begin with thanks to Lars' comment. But it wasn't making sense since there seems to be a bug when setting xAxis with dates like this:
chart.xAxis
.tickFormat(function(d) { return d3.time.format('%Y-%m-%d')(new Date(d)); });
When you try to get the xAxis.scale(), you get a date back instead of the scale function. So it wasn't obvious.
xAxis.scale()
. – Lars Kotthoff