I am current working on library d3.js.I have line graph using
Dynamic Line Graph
Here we have option of drawing power linear and log.
But my problem is that I might have some values zero in my data set and as log 0 is undefined so the code is unable to plot it.
Here in my code the scale set like this
y = d3.scale.log().domain([0.1, max_y _value]).range([h, 0]).nice();
and this is how it is used
lineFunction = d3.svg.line()
.y(function(d) {
return y(d);
});
I know that its an odd question.But is there a way by which I can handle log 0 value so that if I have single zero value the rest of them are plotted correctly.
Can I gave two domain and range in same statement (to handle 0 value) if yes than how will it bind to y axis?
Thanks any help will be appreciated.
I solved my problem by using a clamp function. This is how I have changed the code: