Open ajaybc opened 7 years ago
@ajaybc You can use a closure:
function formatter(offset) {
return function(d) {
return d3.time.format('%Y-%m-%d %H:%M')(new Date(d + offset));
}
}
<...... xAxis={{tickFormat : formatter(10000)}} ../>
@topicus Thanks for the reply. But I was asking how to use .ticks(d3.time.weeks, 2)
because that function expects 2 parameters. Sorry if the question seemed confusing
@ajaybc I think it doesn't work as d3. Tick function it's not inherited from d3 but used inside nvd3 as you can see in the link https://github.com/novus/nvd3/blob/master/src/models/axis.js#L52
You might play with tickValues and tickFormat to achieve the same result.
I need to use the xAxis.ticks function which accepts 2 parameters eg.
.ticks(d3.time.weeks, 2)
. If it was just 1 parameter I could do I what I did with tick format below.<...... xAxis={{tickFormat : function (d) { return d3.time.format('%Y-%m-%d %H:%M')(new Date(d)) }}} ../>
How do I call multiparameter functions using react-nvd3 ?