2013-02-06 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/flot/pandora.flot.js: cleaned source code style. * include/graphs/functions_utils.php: fixed the unasigned var. Fixes: #3603439 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7597 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
5767594f30
commit
db0aab59c0
|
@ -1,3 +1,11 @@
|
|||
2013-02-06 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/graphs/flot/pandora.flot.js: cleaned source code style.
|
||||
|
||||
* include/graphs/functions_utils.php: fixed the unasigned var.
|
||||
|
||||
Fixes: #3603439
|
||||
|
||||
2013-02-06 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_graph.php, include/functions_ui.php,
|
||||
|
|
|
@ -159,7 +159,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, maxvalue, water_
|
|||
legend: {
|
||||
show: false
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var plot = $.plot($('#'+graph_id),datas, options );
|
||||
|
||||
|
@ -195,34 +195,34 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, maxvalue, water_
|
|||
$('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3);
|
||||
i++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Format functions
|
||||
function xFormatter(v, axis) {
|
||||
if(labels[v] != undefined) {
|
||||
function xFormatter(v, axis) {
|
||||
if (labels[v] != undefined) {
|
||||
return labels[v];
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function yFormatter(v, axis) {
|
||||
return v;
|
||||
}
|
||||
function yFormatter(v, axis) {
|
||||
return v;
|
||||
}
|
||||
|
||||
function lFormatter(v, axis) {
|
||||
return '<div style=color:#000>'+v+'</div>';
|
||||
}
|
||||
function lFormatter(v, axis) {
|
||||
return '<div style=color:#000>'+v+'</div>';
|
||||
}
|
||||
|
||||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
$('.values_'+graph_id).css('font-weight', '');
|
||||
if(item != null) {
|
||||
index = item.dataIndex;
|
||||
$('#value_'+index+'_'+graph_id).css('font-weight', 'bold');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if(water_mark) {
|
||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||
|
@ -286,17 +286,17 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
|
|||
color: '#000'
|
||||
},
|
||||
{
|
||||
// align if we are to the right
|
||||
alignTicksWithAxis: 1,
|
||||
position: 'right',
|
||||
// align if we are to the right
|
||||
alignTicksWithAxis: 1,
|
||||
position: 'right',
|
||||
|
||||
//tickFormatter: dFormatter
|
||||
//tickFormatter: dFormatter
|
||||
} ]
|
||||
,
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var plot = $.plot($('#'+graph_id),datas, options );
|
||||
|
||||
|
@ -332,28 +332,28 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
|
|||
//~ $('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3);
|
||||
//~ i++;
|
||||
//~ });
|
||||
//~ });
|
||||
//~ });
|
||||
|
||||
// Format functions
|
||||
function xFormatter(v, axis) {
|
||||
function xFormatter(v, axis) {
|
||||
if(labels[v] != undefined) {
|
||||
return labels[v];
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function yFormatter(v, axis) {
|
||||
return v;
|
||||
}
|
||||
function yFormatter(v, axis) {
|
||||
return v;
|
||||
}
|
||||
|
||||
function lFormatter(v, axis) {
|
||||
return '<div style=color:#000>'+v+'</div>';
|
||||
}
|
||||
function lFormatter(v, axis) {
|
||||
return '<div style=color:#000>'+v+'</div>';
|
||||
}
|
||||
|
||||
// Events
|
||||
//~ $('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
// Events
|
||||
//~ $('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
//~ $('.values_'+graph_id).css('font-weight', '');
|
||||
//~ if(item != null) {
|
||||
//~ index = item.dataIndex;
|
||||
|
@ -419,12 +419,12 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||
legend: {
|
||||
show: false
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var plot = $.plot($('#'+graph_id), datas, options );
|
||||
|
||||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
if(item) {
|
||||
var from = legend[item.seriesIndex];
|
||||
var to = legend[item.seriesIndex+1];
|
||||
|
@ -441,7 +441,7 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||
|
||||
$('#extra_'+graph_id).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#'+graph_id).bind('mouseout',resetInteractivity);
|
||||
|
||||
|
@ -451,14 +451,14 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||
}
|
||||
|
||||
// Format functions
|
||||
function xFormatter(v, axis) {
|
||||
function xFormatter(v, axis) {
|
||||
for(i = 0; i < acumulate_data.length; i++) {
|
||||
if(acumulate_data[i] == v) {
|
||||
return '<span style=\'font-size: 6pt\'>' + legend[i] + '</span>';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors, type, serie_types, water_mark, width, max_x, homeurl, unit, font_size, menu, events, event_ids, legend_events, alerts, alert_ids, legend_alerts, yellow_threshold, red_threshold, force_integer, separator, separator2, series_suffix_str) {
|
||||
|
@ -512,7 +512,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
var datas = new Array();
|
||||
var data_base = new Array();
|
||||
|
||||
// Prepared to turn series with a checkbox
|
||||
// Prepared to turn series with a checkbox
|
||||
// var showed = new Array();
|
||||
|
||||
for(i=0;i<values.length;i++) {
|
||||
|
@ -649,7 +649,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
container: $('#legend_'+graph_id),
|
||||
labelFormatter: lFormatter
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var stack = 0, bars = true, lines = false, steps = false;
|
||||
|
||||
|
@ -661,97 +661,97 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
// Adjust linked graph to the width and position of the main plot
|
||||
|
||||
// Miniplot
|
||||
var overview = $.plot($('#overview_'+graph_id),datas, {
|
||||
series: {
|
||||
var overview = $.plot($('#overview_'+graph_id),datas, {
|
||||
series: {
|
||||
stack: stacked,
|
||||
lines: { show: true, lineWidth: 1 },
|
||||
shadowSize: 0
|
||||
},
|
||||
grid: { borderWidth: 1, hoverable: true, autoHighlight: false},
|
||||
xaxis: { },
|
||||
lines: { show: true, lineWidth: 1 },
|
||||
shadowSize: 0
|
||||
},
|
||||
grid: { borderWidth: 1, hoverable: true, autoHighlight: false},
|
||||
xaxis: { },
|
||||
xaxes: [ {
|
||||
tickFormatter: xFormatter,
|
||||
minTickSize: steps,
|
||||
color: '#000'
|
||||
} ],
|
||||
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
|
||||
selection: { mode: 'x', color: '#777' },
|
||||
legend: {show: false},
|
||||
crosshair: { mode: 'x' }
|
||||
});
|
||||
tickFormatter: xFormatter,
|
||||
minTickSize: steps,
|
||||
color: '#000'
|
||||
} ],
|
||||
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
|
||||
selection: { mode: 'x', color: '#777' },
|
||||
legend: {show: false},
|
||||
crosshair: { mode: 'x' }
|
||||
});
|
||||
|
||||
// Connection between plot and miniplot
|
||||
// Connection between plot and miniplot
|
||||
|
||||
$('#'+graph_id).bind('plotselected', function (event, ranges) {
|
||||
// do the zooming
|
||||
dataInSelection = ranges.xaxis.to - ranges.xaxis.from;
|
||||
dataInPlot = plot.getData()[0].data.length;
|
||||
$('#'+graph_id).bind('plotselected', function (event, ranges) {
|
||||
// do the zooming
|
||||
dataInSelection = ranges.xaxis.to - ranges.xaxis.from;
|
||||
dataInPlot = plot.getData()[0].data.length;
|
||||
|
||||
factor = dataInSelection / dataInPlot;
|
||||
factor = dataInSelection / dataInPlot;
|
||||
|
||||
new_steps = parseInt(factor*steps);
|
||||
new_steps = parseInt(factor*steps);
|
||||
|
||||
plot = $.plot($('#'+graph_id), datas,
|
||||
$.extend(true, {}, options, {
|
||||
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to},
|
||||
xaxes: [ {
|
||||
tickFormatter: xFormatter,
|
||||
minTickSize: new_steps,
|
||||
color: '#000'
|
||||
} ],
|
||||
legend: { show: false },
|
||||
}));
|
||||
plot = $.plot($('#'+graph_id), datas,
|
||||
$.extend(true, {}, options, {
|
||||
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to},
|
||||
xaxes: [ {
|
||||
tickFormatter: xFormatter,
|
||||
minTickSize: new_steps,
|
||||
color: '#000'
|
||||
} ],
|
||||
legend: { show: false },
|
||||
}));
|
||||
|
||||
$('#menu_cancelzoom_'+graph_id).attr('src',homeurl+'/images/zoom_cross.png');
|
||||
|
||||
currentRanges = ranges;
|
||||
// don't fire event on the overview to prevent eternal loop
|
||||
overview.setSelection(ranges, true);
|
||||
});
|
||||
// don't fire event on the overview to prevent eternal loop
|
||||
overview.setSelection(ranges, true);
|
||||
});
|
||||
|
||||
$('#overview_'+graph_id).bind('plotselected', function (event, ranges) {
|
||||
plot.setSelection(ranges);
|
||||
});
|
||||
$('#overview_'+graph_id).bind('plotselected', function (event, ranges) {
|
||||
plot.setSelection(ranges);
|
||||
});
|
||||
|
||||
var legends = $('#legend_'+graph_id+' .legendLabel');
|
||||
var legends = $('#legend_'+graph_id+' .legendLabel');
|
||||
|
||||
var updateLegendTimeout = null;
|
||||
var latestPosition = null;
|
||||
var currentPlot = null;
|
||||
var currentRanges = null;
|
||||
var latestPosition = null;
|
||||
var currentPlot = null;
|
||||
var currentRanges = null;
|
||||
|
||||
// Update legend with the data of the plot in the mouse position
|
||||
function updateLegend() {
|
||||
updateLegendTimeout = null;
|
||||
// Update legend with the data of the plot in the mouse position
|
||||
function updateLegend() {
|
||||
updateLegendTimeout = null;
|
||||
|
||||
var pos = latestPosition;
|
||||
var pos = latestPosition;
|
||||
|
||||
var axes = currentPlot.getAxes();
|
||||
if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max ||
|
||||
pos.y < axes.yaxis.min || pos.y > axes.yaxis.max) {
|
||||
return;
|
||||
var axes = currentPlot.getAxes();
|
||||
if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max ||
|
||||
pos.y < axes.yaxis.min || pos.y > axes.yaxis.max) {
|
||||
return;
|
||||
}
|
||||
|
||||
var j, dataset = currentPlot.getData();
|
||||
var j, dataset = currentPlot.getData();
|
||||
|
||||
var i = 0;
|
||||
for (k = 0; k < dataset.length; k++) {
|
||||
for (k = 0; k < dataset.length; k++) {
|
||||
|
||||
// k is the real series counter
|
||||
// i is the series counter without thresholds
|
||||
var series = dataset[k];
|
||||
var series = dataset[k];
|
||||
|
||||
if(series.label == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// find the nearest points, x-wise
|
||||
for (j = 0; j < series.data.length; ++j)
|
||||
if (series.data[j][0] > pos.x) {
|
||||
break;
|
||||
// find the nearest points, x-wise
|
||||
for (j = 0; j < series.data.length; ++j)
|
||||
if (series.data[j][0] > pos.x) {
|
||||
break;
|
||||
}
|
||||
|
||||
var y = series.data[j][1];
|
||||
var y = series.data[j][1];
|
||||
|
||||
if(currentRanges == null || (currentRanges.xaxis.from < j && j < currentRanges.xaxis.to)) {
|
||||
$('#timestamp_'+graph_id).show();
|
||||
|
@ -788,7 +788,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
|
||||
var label_aux = series.label + ' = ';
|
||||
|
||||
if(serie_types[i] != 'points') {
|
||||
if (serie_types[i] != 'points') {
|
||||
legends.eq(i).text(label_aux.replace(/=.*/, '= ' + parseFloat(y).toFixed(2) +' '+unit));
|
||||
}
|
||||
|
||||
|
@ -796,19 +796,19 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
|||
legends.eq(i).css('color','#000');
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
overview.setCrosshair({ x: pos.x, y: 0 });
|
||||
currentPlot = plot;
|
||||
latestPosition = pos;
|
||||
if (!updateLegendTimeout) {
|
||||
updateLegendTimeout = setTimeout(updateLegend, 50);
|
||||
// Events
|
||||
$('#'+graph_id).bind('plothover', function (event, pos, item) {
|
||||
overview.setCrosshair({ x: pos.x, y: 0 });
|
||||
currentPlot = plot;
|
||||
latestPosition = pos;
|
||||
if (!updateLegendTimeout) {
|
||||
updateLegendTimeout = setTimeout(updateLegend, 50);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$('#'+graph_id).bind("plotclick", function (event, pos, item) {
|
||||
plot.unhighlight();
|
||||
|
|
|
@ -134,7 +134,7 @@ function graph_get_max_index($legend_values) {
|
|||
|
||||
function setup_watermark($water_mark, &$water_mark_file, &$water_mark_url) {
|
||||
if (!is_array($water_mark)) {
|
||||
$water_mark['file'] = $water_mark;
|
||||
$water_mark_file = $water_mark;
|
||||
}
|
||||
|
||||
if (isset($water_mark['file'])) {
|
||||
|
|
Loading…
Reference in New Issue