I have arrays that are filled with two variables and I am doing very well but now I have not been able to identify which is the minor value and greater value of a selected point with a slider, I am looking at the Underscore.js library and there are three possible options to choose but I do not know which one will be, can you please help me with my problem?
_.findIndex (array, predicate, [context])
_.findLastIndex (array, predicate, [context])
_.range ([start], stop, [step])
in being options is where I stayed
Chart.types.Line.extend({
name: "LineAlt",
highlightPoints: function(datasetIndex, pointIndexArray){
var activePoints = [];
// var activePoints_2 = [];
var points = this.datasets[datasetIndex].points;
for(i in pointIndexArray){
if(points[pointIndexArray[i]]){
activePoints.push(points[pointIndexArray[i]]);
}
//mostrar siguiente punto seleccionado
// if(points[pointIndexArray[i]+1]){
// activePoints_2.push(points[pointIndexArray[i]+1]);
// }
}
//mostrar puntos activos en input
$("#if_a").val(activePoints[0].value)
$("#if_b").val(activePoints[0].label)
change_values()
this.showTooltip(activePoints);
}
});
function initChart_custom(data) {
var data_new = data.split(/\n/)
var c_1 = []
var c_2 = []
data_new.forEach(function(data_f){
data_c = data_f.split(",");
c_1.push(data_c[1]);
c_2.push(data_c[0]);
})
c_1 = c_1.slice(1,c_1.length-1)
c_2 = c_2.slice(1,c_2.length-1)
var lineChartData = {
"datasets": [{
"data": c_1,
"pointStrokeColor": "#1A81C5",
"fillColor": "rgba(254, 254, 254, 0.4)",
"pointColor": "#1A81C5",
"strokeColor": "#5D9CC6"
}],
"labels": c_2,
};
var options = {showTooltips: true};
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).LineAlt(lineChartData, options);
var highlight = function(index){
myLine.highlightPoints(0, [index]);
}
$("#slider").slider({
max: lineChartData.datasets[0].data.length-1,
slide: function( event, ui ) { highlight(ui.value); },
});
}