ChartJS v2: Scale value at click coordinates (time scale)
<p>I have a time-base line chart and I'm attempting to obtain the values for each scale at the click coordinates.</p>

<p>My onClick function specified in ChartJS options:</p>

<pre><code>onClick: function(event, elementsAtEvent)
{
    console.log(event, elementsAtEvent, this);
    var valueX = null, valueY = null;
    for (var scaleName in this.scales) {
        var scale = this.scales[scaleName];
        console.log(scale.id, scale.isHorizontal());
        if (scale.isHorizontal()) {
            valueX = scale.getValueForPixel(event.offsetX);
        } else {
            valueY = scale.getValueForPixel(event.offsetY);
        }
    }
    console.log(event.offsetX, valueX, null, event.offsetY, valueY);
},
</code></pre>

<p>JSFiddle: <a href="https://jsfiddle.net/AllenJB/dmebo9g5/1/" rel="nofollow">https://jsfiddle.net/AllenJB/dmebo9g5/1/</a></p>

<p>The code above appears to work well for the Y axis, but not the X (time scale) - it always returns the last value regardless of where in the chart you click.</p>

<p>What might I be doing wrong?</p>