Rishabh Rishabh - 1 year ago 101
Javascript Question

show the bottom most tick of y axis

The bottom most tick in the Y axis is not visible in the line chart I've created. The axis creation code is:

var y = d3.scale.linear().range([height, 0]);

var yAxis = d3.svg.axis().scale(y)

enter image description here

The axis is ok, but I need to show the tick and text at the bottom most of the Y axis. What's going wrong here? Here is the JSFiddle.

Answer Source

Use nice() in the domain:

    d3.min(chartData, function(n) {
        return d3.min(n.values, function(d) {
            return d.value;
    d3.max(chartData, function(n) {
        return d3.max(n.values, function(d) {
            return d.value;

Here is your Fiddle: https://jsfiddle.net/c8mjha3o/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download