zabbix-d3js-widgets
zabbix-d3js-widgets copied to clipboard
itemGauges and timeSeries do not work in samples.html
TypeError: items[startIndex] is undefined
--- SNIP d3zabbix.js ---
function getIndex(items, value) {
var startIndex = 0,
stopIndex = items.length - 1,
middle = Math.floor((stopIndex + startIndex)/2),
floor = -1,
ceil = -1;
/// Here the issue hapens \/
if (value <= items[startIndex][0]) return [ -1, 0, 0 ];
/// Here the issue hapens /\
if (value >= items[stopIndex][0]) return [ stopIndex, -1, stopIndex ];
while (items[middle][0] != value && startIndex < stopIndex) {
if (value < items[middle][0]) {
stopIndex = middle - 1;
ceil = middle;
} else if (value > items[middle][0]) {
startIndex = middle + 1;
floor = middle;
}
middle = Math.floor((stopIndex + startIndex)/2);
}
--- SNAP d3zabbix.js ---