How to get value of corresponding x-axis label on click event of rectangular bars in nvd3.js historical chart
<p>I have created a historical bar chart using nvd3 js. I want to get the value of corresponding x-axis label when a bar is clicked. How to get value of corresponding x-axis label on click event of rectangular bars in nvd3.js historical chart?</p>

<p>My current code is</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;link href="../build/nv.d3.css" rel="stylesheet" type="text/css"&gt;
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.2/d3.min.js" charset="utf-8"&gt;&lt;/script&gt;
    &lt;script src="../build/nv.d3.js"&gt;&lt;/script&gt;

    &lt;style&gt;
        text {
            font: 12px sans-serif;
        }
        svg {
            display: block;
        }
        html, body, svg {
            margin: 0px;
            padding: 0px;
            height: 100%;
            width: 100%;
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body class='with-3d-shadow with-transitions'&gt;

&lt;svg id="test1"&gt;&lt;/svg&gt;

&lt;script&gt;

    var chart;
    nv.addGraph(function() {
        chart = nv.models.historicalBarChart();
        chart
            .margin({left: 100, bottom: 100})
            .useInteractiveGuideline(true)
            .duration(250)
            ;

        // chart sub-models (ie. xAxis, yAxis, etc) when accessed directly, return themselves, not the parent chart, so need to chain separately
        chart.xAxis
            .axisLabel("Time (s)")
            .tickFormat(d3.format(',.1f'));

        chart.yAxis
            .axisLabel('Voltage (v)')
            .tickFormat(d3.format(',.2f'));

        chart.showXAxis(true);

        d3.select('#test1')
            .datum(sinData())
            .transition()
            .call(chart);

            var rectArray=d3.select('g.nv-bars').selectAll('rect').on('click',function(d,i){alert(d+i)});

        nv.utils.windowResize(chart.update);

        return chart;
    });

    //Simple test data generators
    function sinAndCos() {
        var sin = [],
            cos = [];

        for (var i = 0; i &lt; 100; i++) {
            sin.push({x: i*2, y: Math.sin(i/10)});
            cos.push({x: i, y: .5 * Math.cos(i/10)});
        }

        return [
            {values: sin, key: "Sine Wave", color: "#ff7f0e"},
            {values: cos, key: "Cosine Wave", color: "#2ca02c"}
        ];
    }

    function sinData() {
        var sin = [];

        for (var i = 0; i &lt; 100; i++) {
            sin.push({x: i, y: Math.sin(i/10) * Math.random() * 100});
        }

        return [{
            values: sin,
            key: "Sine Wave",
            color: "#ff7f0e"
        }];
    }

&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>