2๐
โ
I solved my problem. Just had to add 2 or 3 lines. Here are the two methods which I modified:
function getElement(chartInstance, callback) {
return function () {
if (_d3Selection.event) {
var e = _d3Selection.event.sourceEvent;
element = chartInstance.getElementAtEvent(e)[0];
if (element) {
scale = element['_yScale'].id;
scaleX = element['_xScale'].id;
if (typeof callback === 'function' && element) callback(e, element);
}
}
};
}
function updateData(chartInstance, callback) {
return function () {
if (element && _d3Selection.event) {
var e = _d3Selection.event.sourceEvent;
var datasetIndex = element['_datasetIndex'];
var index = element['_index'];
var value = chartInstance.scales[scale].getValueForPixel(e.clientY - chartInstance.canvas.getBoundingClientRect().top);
var valueX = chartInstance.scales[scaleX].getValueForPixel(e.clientX-chartInstance.canvas.getBoundingClientRect().left );
chartInstance.data.datasets[datasetIndex].data[index] = {x:valueX, y:value};
chartInstance.update(0);
if (typeof callback === 'function') callback(e, datasetIndex, index, value);
}
};
}
Source:stackexchange.com