2012-03-01 Sergio Martin <sergio.martin@artica.es>

* include/functions_graph.php
	include/graphs/functions_flot.php
	include/graphs/flot
	include/graphs/flot/jquery.flot.resize.min.js
	include/graphs/flot/jquery.flot.min.js
	include/graphs/flot/pandora.flot.js
	include/graphs/flot/jquery.flot.symbol.min.js
	include/graphs/flot/jquery.flot.selection.min.js
	include/graphs/flot/jquery.flot.stack.min.js
	include/graphs/flot/jquery.flot.threshold.js
	include/graphs/flot/jquery.flot.pie.min.js
	include/graphs/flot/jquery.flot.crosshair.min.js
	include/graphs/fgraph.php
	include/graphs/functions_utils.php
	include/javascript/pandora.js
	include/javascript/jquery.mousewheel.js
	include/javascript/jquery-1.6.1.min.js
	include/ajax/events.php
	include/include_graph_dependencies.php
	operation/agentes/estado_generalagente.php
	operation/agentes/stat_win.php
	images/zoom_cross.png
	images/zoom_cross.disabled.png
	images/chart_curve_overview.png
	godmode/setup/setup_visuals.php
	godmode/users/configure_user.php: Added a new graphs engine (Flot) and
	replace the old flash charts by it.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5685 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2012-03-01 16:41:02 +00:00
parent 33c24eeb02
commit f7c0726660
26 changed files with 2546 additions and 147 deletions

View File

@ -1,3 +1,33 @@
2012-03-01 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php
include/graphs/functions_flot.php
include/graphs/flot
include/graphs/flot/jquery.flot.resize.min.js
include/graphs/flot/jquery.flot.min.js
include/graphs/flot/pandora.flot.js
include/graphs/flot/jquery.flot.symbol.min.js
include/graphs/flot/jquery.flot.selection.min.js
include/graphs/flot/jquery.flot.stack.min.js
include/graphs/flot/jquery.flot.threshold.js
include/graphs/flot/jquery.flot.pie.min.js
include/graphs/flot/jquery.flot.crosshair.min.js
include/graphs/fgraph.php
include/graphs/functions_utils.php
include/javascript/pandora.js
include/javascript/jquery.mousewheel.js
include/javascript/jquery-1.6.1.min.js
include/ajax/events.php
include/include_graph_dependencies.php
operation/agentes/estado_generalagente.php
operation/agentes/stat_win.php
images/zoom_cross.png
images/zoom_cross.disabled.png
images/chart_curve_overview.png
godmode/setup/setup_visuals.php
godmode/users/configure_user.php: Added a new graphs engine (Flot) and
replace the old flash charts by it.
2012-03-01 Vanessa Gil <vanessa.gil@artica.es>
* godmode/agentes/planned_downtime.php: Fixed bug #3474901: Planned

View File

@ -91,7 +91,7 @@ $table->data[11][1] = html_print_select($fonts, 'fontpath', $config["fontpath"],
$table->data[12][0] = __('Font size');
$table->data[12][1] = html_print_select(range(1, 15), 'font_size', $config["font_size"], '', '', 0, true);
$table->data[13][0] = __('Flash charts') . ui_print_help_tip(__('Whether to use Flash charts or static PNG graphs'), true);
$table->data[13][0] = __('Interactive charts') . ui_print_help_tip(__('Whether to use Javascript or static PNG graphs'), true);
$table->data[13][1] = __('Yes').'&nbsp;'.html_print_radio_button ('flash_charts', 1, '', $config["global_flash_charts"], true).'&nbsp;&nbsp;';
$table->data[13][1] .= __('No').'&nbsp;'.html_print_radio_button ('flash_charts', 0, '', $config["global_flash_charts"], true);

View File

@ -158,7 +158,7 @@ if ($create_user) {
' Phone: ' . $values['phone'] . ' Comments: ' . $values['comments'] .
' Is_admin: ' . $values['is_admin'] .
' Language: ' . $values['language'] .
' Block size: ' . $values['block_size'] . ' Flash Chats: ' . $values['flash_chart'];
' Block size: ' . $values['block_size'] . ' Interactive Charts: ' . $values['flash_chart'];
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
$info .= ' Skin: ' . $values['id_skin'];
@ -401,7 +401,7 @@ if (count($usr_groups) > 1){
}
}
$table->data[11][0] = __('Flash charts');
$table->data[11][0] = __('Interactive charts');
$values = array(-1 => __('Use global conf'), 1 => __('Yes'), 0 => __('No'));
$table->data[11][1] = html_print_select($values, 'flash_charts', $user_info["flash_chart"], '', '', -1, true, false, false);
$table->data[12][0] = __('Block size for pagination');

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

View File

@ -0,0 +1,60 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
require_once ('include/functions_events.php');
require_once ('include/functions_db.php');
require_once ('include/functions_io.php');
require_once ('include/functions.php');
$get_events_details = (bool) get_parameter ('get_events_details');
if($get_events_details) {
$event_ids = explode(',',get_parameter ('event_ids'));
$events = db_get_all_rows_filter ('tevento',
array ('id_evento' => $event_ids,
'order' => 'utimestamp ASC'),
array ('evento', 'utimestamp', 'estado', 'criticity'));
$out = '<table class="eventtable" style="width:100%;height:100%;padding:0px 0px 0px 0px; border-spacing: 0px; margin: 0px 0px 0px 0px;">';
$out .= '<tr style="font-size:0px; heigth: 0px; background: #ccc;"><td></td><td></td></tr>';
foreach($events as $event) {
switch($event["estado"]) {
case 0:
$img = "../../images/star.png";
$title = __('New event');
break;
case 1:
$img = "../../images/tick.png";
$title = __('Event validated');
break;
case 2:
$img = "../../images/hourglass.png";
$title = __('Event in process');
break;
}
$out .= '<tr class="'.get_priority_class ($event['criticity']).'"><td class="'.get_priority_class ($event['criticity']).'">';
$out .= '<img src="'.$img.'" alt="'.$title.'" title="'.$title.'">';
$out .= '</td><td class="'.get_priority_class ($event['criticity']).'" style="font-size:7pt">';
$out .= io_safe_output($event['evento']);
$out .= '</td></tr><tr style="font-size:0px; heigth: 0px; background: #999;"><td></td><td>';
$out .= '</td></tr><tr style="font-size:0px; heigth: 0px; background: #ccc;"><td></td><td>';
$out .= '</td></tr>';
}
$out .= '</table>';
echo $out;
}
?>

View File

@ -60,7 +60,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
"utimestamp > $datelimit",
"utimestamp < $date",
'order' => 'utimestamp ASC'),
array ('evento', 'utimestamp', 'event_type'));
array ('id_evento', 'evento', 'utimestamp', 'event_type'));
if ($events === false) {
$events = array ();
}
@ -152,6 +152,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$unit = modules_get_unit($agent_module_id);
}
$chart_extra_data = array();
// Calculate chart data
for ($i = 0; $i < $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i);
@ -188,12 +190,16 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
// Read events and alerts that fall in the current interval
$event_value = 0;
$alert_value = 0;
$event_ids = array();
$alert_ids = array();
while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] <= ($timestamp + $interval)) {
if ($show_events == 1) {
$event_value++;
$event_ids[] = $events[$k]['id_evento'];
}
if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') {
$alert_value++;
$alert_ids[] = $events[$k]['id_evento'];
}
$k++;
}
@ -284,11 +290,15 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
//$chart[$timestamp]['timestamp_bottom'] = $timestamp;
//$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
/////////
$series_type = array();
if($show_events) {
$chart[$timestamp]['event'] = $event_value;
$series_type['event'] = 'points';
}
if($show_alerts) {
$chart[$timestamp]['alert'] = $alert_value;
$series_type['alert'] = 'points';
}
if ($baseline) {
$chart[$timestamp]['baseline'] = array_shift ($baseline_data);
@ -296,6 +306,13 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$chart[$timestamp]['baseline'] = 0;
}
}
if(!empty($event_ids)) {
$chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids);
}
if(!empty($alert_ids)) {
$chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids);
}
}
// Return chart data and don't draw
@ -309,10 +326,10 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$avg_value = round(reporting_get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
// Fix event and alert scale
$event_max = $max_value * 1.25;
$event_max = $max_value * 1.15;
foreach ($chart as $timestamp => $chart_data) {
if ($show_events && $chart_data['event'] > 0) {
$chart[$timestamp]['event'] = $event_max;
$chart[$timestamp]['event'] = $event_max * 1.15;
}
if ($show_alerts && $chart_data['alert'] > 0) {
$chart[$timestamp]['alert'] = $event_max;
@ -328,26 +345,28 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
///////
// Color commented not to restrict serie colors
/*$color = array();
$color = array();
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
if($show_events) {
$color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
$color['event'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
}
if($show_alerts) {
$color['alert'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
$color['alert'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
}
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
$color['unit'] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10); */
$color['unit'] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10);
$legend = array();
$legend['sum'] = __('Avg') . ' (' . $avg_value . ')';
if($show_events) {
$legend['event'] = __('Events');
$chart_extra_data['legend_events'] = $legend['event'];
}
if($show_alerts) {
$legend['alert'] = __('Alerts');
$chart_extra_data['legend_alerts'] = $legend['alert'];
}
$legend['max'] = __('Max') . ' (' .format_for_graph($max_value) . ')';
$legend['min'] = __('Min') . ' (' . format_for_graph($min_value) . ')';
@ -361,11 +380,14 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
include_flash_chart_script($homeurl);
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
// Color commented not to restrict serie colors
return area_graph($flash_chart, $chart, $width, $height, '' /*$color*/ ,$legend,
$long_index, "images/image_problem.opaque.png", "", $unit, $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$config['fontpath'], $config['font_size'], $unit, $ttl);
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
$long_index, "images/image_problem.opaque.png", "", "", $homeurl,
$water_mark,
$config['fontpath'], $config['font_size'], $unit, $ttl, $series_type, $chart_extra_data);
}
function graph_get_formatted_date($timestamp, $format1, $format2) {
@ -750,17 +772,19 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$flash_charts = false;
}
if ($flash_charts){
include_flash_chart_script();
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
switch ($stacked) {
case GRAPH_AREA:
$color = null;
return area_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $homeurl, $config['homedir'] . "/images/logo_vertical_water.png",
"", "", $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl);
break;
default:
@ -768,21 +792,21 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$color = null;
return stacked_area_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $config['homedir'] . "/images/logo_vertical_water.png",
"", "", $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl);
break;
case GRAPH_LINE:
$color = null;
return line_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $config['homedir'] . "/images/logo_vertical_water.png",
"", "", $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl);
break;
case GRAPH_STACKED_LINE:
$color = null;
return stacked_line_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $config['homedir'] . "/images/logo_vertical_water.png",
"", "", $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl);
break;
}
@ -846,12 +870,15 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
}
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
if ($empty_data)
echo fs_error_image();
else {
echo area_graph($config['flash_charts'], $data, $width, $height,
null, null, null, "images/image_problem.opaque.png", "", "", "",
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], "");
}
}
@ -909,8 +936,11 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
}
asort ($data);
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return pie3d_graph($config['flash_charts'], $data, $width, $height, __("other"),
'', $config['homedir'] . "/images/logo_vertical_water.png",
'', $water_mark,
$config['fontpath'], $config['font_size']);
}
@ -923,7 +953,7 @@ function progress_bar($progress, $width, $height, $title = '', $mode = 1) {
require_once("include_graph_dependencies.php");
include_graphs_dependencies($config['homedir'].'/');
return "<img title='" . $title . "' alt='" . $title . "' src='include/graphs/fgraph.php?homeurl=../../&graph_type=progressbar&width=".$width."&height=".$height."&progress=".$progress.
return "<img title='" . $title . "' alt='" . $title . "' src='include/graphs/fgraph.php?static_graph=1&homeurl=../../&graph_type=progressbar&width=".$width."&height=".$height."&progress=".$progress.
"&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str."&title=".$title."&font=".$config['fontpath']."' />";
}
@ -948,7 +978,6 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
global $config;
global $graphic_type;
include_flash_chart_script();
if ($id_agent < 1) {
$id_agent = -1;
@ -997,9 +1026,12 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) {
$data["1 ".__("Month")] == 0 && $data["3 ".__("Months")] == 0 && $data[__("Older")] == 0) {
return html_print_image('images/image_problem.png', true);
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return pie3d_graph($config['flash_charts'], $data, $width, $height,
__('Other'), '', $config['homedir'] . "/images/logo_vertical_water.png",
__('Other'), '', $water_mark,
$config['fontpath'], $config['font_size']);
}
@ -1080,9 +1112,12 @@ function graph_db_agentes_modulos2($width, $height) {
}
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return hbar_graph($config['flash_charts'], $data, $width, $height, array(),
array(), "", "", true, "",
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], false);
}
@ -1639,6 +1674,7 @@ function graph_graphic_agentevents_static($id_agent, $width, $height, $period =
$time = array ();
$data = array ();
$legend = array();
$full_legend = array();
$cont = 0;
for ($i = 0; $i < $interval; $i++) {
@ -1653,6 +1689,8 @@ function graph_graphic_agentevents_static($id_agent, $width, $height, $period =
if ($cont == 0 or $cont % 2)
$legend[$name] = $name;
$full_legend[$name] = $name;;
$top = $datelimit + ($periodtime * ($i + 1));
$event = db_get_row_filter ('tevento',
array ('id_agente' => $id_agent,
@ -1680,14 +1718,20 @@ function graph_graphic_agentevents_static($id_agent, $width, $height, $period =
$colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3');
// Draw slicebar graph
echo slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
// Draw legend
echo "<br>";
echo "&nbsp;";
foreach ($legend as $hour){
echo "<span style='font-size: 6pt'>" . $hour . "</span>";
if($config['flash_charts']) {
echo flot_slicesbar_graph($data, $period, $width, $height, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
}
else {
echo slicesbar_graph($data, $period, $width, $height, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
// Draw legend
echo "<br>";
echo "&nbsp;";
foreach ($legend as $hour){
echo "<span style='font-size: 6pt'>" . $hour . "</span>";
echo "&nbsp;";
}
}
}
@ -2450,9 +2494,12 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$legend = null;
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
return vbar_graph($flash_chart, $chart, $width, $height, $color,
$legend, "", $unit, $homeurl,
$config['homedir'] . "/images/logo_vertical_water.png",
$water_mark,
$config['fontpath'], $config['font_size'], true, true, 1, true);
}
@ -2836,10 +2883,6 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu
global $config;
global $graphic_type;
if ($config['flash_charts']) {
include_flash_chart_script($homeurl);
}
$data = array ();
$resolution = $config['graph_res'] * ($period * 2 / $width); // Number of "slices" we want in graph
@ -2880,46 +2923,32 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu
$top = $datelimit + ($periodtime * ($i + 1));
if ($config['flash_charts']){
$criticity = (int) db_get_value_filter ('criticity',
'tevento',
array ('id_agentmodule' => $id_module,
'utimestamp > '.$bottom,
'utimestamp < '.$top));
switch ($criticity) {
case 3: $data[$name] = 'E5DF63';
$event = db_get_row_filter ('tevento',
array ('id_agentmodule' => $id_module,
'utimestamp > '.$bottom,
'utimestamp < '.$top), 'criticity, utimestamp');
if (!empty($event['utimestamp'])){
$data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) {
case 3: $data[$cont]['data'] = 2;
break;
case 4: $data[$name] = 'FF3C4B';
case 4: $data[$cont]['data'] = 3;
break;
default:$data[$cont]['data'] = 1;
break;
default: $data[$name] = '9ABD18';
}
}else{
$event = db_get_row_filter ('tevento',
array ('id_agentmodule' => $id_module,
'utimestamp > '.$bottom,
'utimestamp < '.$top), 'criticity, utimestamp');
if (!empty($event['utimestamp'])){
$data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) {
case 3: $data[$cont]['data'] = 2;
break;
case 4: $data[$cont]['data'] = 3;
break;
default:$data[$cont]['data'] = 1;
break;
}
$current_timestamp = $event['utimestamp'];
}
else{
$data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1;
$current_timestamp = $bottom;
}
$legend[] = date($time_format, $current_timestamp);
$cont++;
$current_timestamp = $event['utimestamp'];
}
else{
$data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1;
$current_timestamp = $bottom;
}
$legend[] = date($time_format, $current_timestamp);
$cont++;
}
$pixels_between_xdata = 25;
@ -2934,37 +2963,43 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu
$step = round($ndata/$xdata_display);
if ($config['flash_charts']) {
return fs_module_event_chart ($data, $width, $height, /*$resolution / 750*/ $step, $homeurl, 1);
} else {
$colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3');
$colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3');
// Draw slicebar graph
// Draw slicebar graph
if($config['flash_charts']) {
echo flot_slicesbar_graph($data, $period, $width, 15, $legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
}
else {
echo slicesbar_graph($data, $period, $width, 15, $colors, $config['fontpath'], $config['round_corner'], $homeurl);
// Draw legend
echo "<br>";
//echo "<div id='legend' style='overflow:hidden;'";
$count = 0;
foreach ($legend as $name => $value) {
$file_name = string2image(ui_print_truncate_text($value, 15, false, true, false, '...'), 115, 13, 2, 270, '#FFFFFF', '#696969', 4, 0);
if (($step >= 1) && ($count++ % $step == 0)) {
if ($zoom == 1)
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
elseif ($zoom == 2)
echo "&nbsp;&nbsp;";
elseif ($zoom == 3)
echo "&nbsp;&nbsp;";
elseif ($zoom == 4)
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo html_print_image($file_name, true, array('title' => $value));
if(!$config['flash_charts']) {
// Draw legend
echo "<br>";
//echo "<div id='legend' style='overflow:hidden;'";
$count = 0;
foreach ($legend as $name => $value) {
$file_name = string2image(ui_print_truncate_text($value, 15, false, true, false, '...'), 115, 13, 2, 270, '#FFFFFF', '#696969', 4, 0);
if (($step >= 1) && ($count++ % $step == 0)) {
if ($zoom == 1)
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
elseif ($zoom == 2)
echo "&nbsp;&nbsp;";
elseif ($zoom == 3)
echo "&nbsp;&nbsp;";
elseif ($zoom == 4)
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo html_print_image($file_name, true, array('title' => $value));
}
}
}
//echo "</div>";
}
}
//echo "</div>";
}
?>

View File

@ -116,7 +116,7 @@ function histogram($chart_data, $width, $height, $font, $max, $title, $mode, $tt
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='include/graphs/functions_gd.php?graph_type=histogram&ttl=".$ttl."&id_graph=".$id_graph."'>";
return "<img src='include/graphs/functions_gd.php?static_graph=1&graph_type=histogram&ttl=".$ttl."&id_graph=".$id_graph."'>";
}
function progressbar($progress, $width, $height, $title, $font, $mode = 1,
@ -134,7 +134,7 @@ function progressbar($progress, $width, $height, $title, $font, $mode = 1,
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='include/graphs/functions_gd.php?graph_type=progressbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
return "<img src='include/graphs/functions_gd.php?static_graph=1&graph_type=progressbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
}
@ -151,15 +151,17 @@ function slicesbar_graph($chart_data, $period, $width, $height, $colors, $font,
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$home_url."include/graphs/functions_pchart.php?graph_type=slicebar&ttl=".$ttl."&id_graph=".$id_graph."'>";
return "<img src='".$home_url."include/graphs/functions_pchart.php?static_graph=1&graph_type=slicebar&ttl=".$ttl."&id_graph=".$id_graph."'>";
}
function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array(),
$legend = array(), $xaxisname = "", $yaxisname = "", $homedir="",
$water_mark = '', $font = '', $font_size = '', $force_steps = true, $ttl = 1, $reduce_data_columns = false) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if($flash_chart) {
echo fs_2d_column_chart ($chart_data, $width, $height, $homedir, $reduce_data_columns, $yaxisname);
echo flot_vcolumn_chart ($chart_data, $width, $height, $water_mark_url, $homedir, $reduce_data_columns);
}
else {
$graph = array();
@ -170,14 +172,14 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['force_steps'] = $force_steps;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=vbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=vbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
}
}
@ -186,14 +188,17 @@ function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) {
echo fs_area_chart ($chart_data, $width, $height);
}
else {
echo "<img src='include/graphs/functions_pchart.php?graph_type=threshold&ttl=".$ttl."&data=".json_encode($chart_data)."&width=".$width."&height=".$height."'>";
echo "<img src='include/graphs/functions_pchart.php?static_graph=1&graph_type=threshold&ttl=".$ttl."&data=".json_encode($chart_data)."&width=".$width."&height=".$height."'>";
}
}
function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homeurl="",
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1) {
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $series_type = array(),
$chart_extra_data = array()) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
// ATTENTION: The min height is 101
if($height <= 100) {
$height = 101;
@ -204,7 +209,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
}
if($flash_chart) {
return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit);
return flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $series_type, $chart_extra_data);
}
else {
$graph = array();
@ -215,13 +220,13 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$homeurl."include/graphs/functions_pchart.php?graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
return "<img src='".$homeurl."include/graphs/functions_pchart.php?static_graph=1&graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
}
}
@ -229,12 +234,14 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
$legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "",
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '') {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
if($flash_chart) {
return fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index);
return flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
}
else {
//Stack the data
@ -248,13 +255,13 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
@ -262,17 +269,19 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
$legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "",
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '') {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
//Stack the data
stack_data($chart_data, $legend, $color);
if($flash_chart) {
return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index);
return flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
}
else {
//Stack the data
stack_data($chart_data, $legend, $color);
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
@ -281,13 +290,13 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
@ -295,12 +304,14 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "",
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '') {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
if($flash_chart) {
return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index);
return flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
}
else {
$graph = array();
@ -311,13 +322,13 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['water_mark'] = $water_mark;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?static_graph=1&graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
}
@ -333,7 +344,7 @@ function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$homedir."include/graphs/functions_pchart.php?graph_type=".$graph_type."&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=".$graph_type."&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
}
function radar_graph($flash_chart, $chart_data, $width, $height, $no_data_image, $ttl = 1, $homedir="") {
@ -347,13 +358,15 @@ function polar_graph($flash_chart, $chart_data, $width, $height, $no_data_image,
function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array(),
$legend = array(), $xaxisname = "", $yaxisname = "", $force_height = true,
$homedir="", $water_mark = '', $font = '', $font_size = '', $force_steps = true, $ttl = 1, $return = false) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if($flash_chart) {
include_flash_chart_script();
if ($return){
return fs_2d_hcolumn_chart ($chart_data, $width, $height);
return flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url);
}
else{
echo fs_2d_hcolumn_chart ($chart_data, $width, $height);
echo flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url);
}
}
else {
@ -366,14 +379,14 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$graph['force_height'] = $force_height;
$graph['water_mark'] = $water_mark;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
$graph['force_steps'] = $force_steps;
$id_graph = serialize_in_temp($graph, null, $ttl);
return "<img src='".$homedir."include/graphs/functions_pchart.php?graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
return "<img src='".$homedir."include/graphs/functions_pchart.php?static_graph=1&graph_type=hbar&ttl=".$ttl."&id_graph=".$id_graph."'>";
}
}
@ -391,6 +404,9 @@ function pie2d_graph($flash_chart, $chart_data, $width, $height,
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
$others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) {
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
// This library allows only 8 colors
$max_values = 8;
@ -418,7 +434,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
return fs_2d_pie_chart (array_values($chart_data), array_keys($chart_data), $width, $height);
break;
case "3d":
return fs_3d_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height);
return flot_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height, $water_mark_url, $font, $font_size);
break;
}
}
@ -427,7 +443,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['water_mark'] = $water_mark;
$graph['water_mark'] = $water_mark_file;
$graph['font'] = $font;
$graph['font_size'] = $font_size;
@ -435,10 +451,10 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
switch($graph_type) {
case "2d":
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=pie2d&ttl=".$ttl."&id_graph=".$id_graph."'>";
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=pie2d&ttl=".$ttl."&id_graph=".$id_graph."'>";
break;
case "3d":
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=pie3d&ttl=".$ttl."&id_graph=".$id_graph."'>";
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?static_graph=1&graph_type=pie3d&ttl=".$ttl."&id_graph=".$id_graph."'>";
break;
}
}

View File

@ -0,0 +1 @@
(function(b){var a={crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}};function c(h){var j={x:-1,y:-1,locked:false};h.setCrosshair=function e(l){if(!l){j.x=-1}else{var k=h.p2c(l);j.x=Math.max(0,Math.min(k.left,h.width()));j.y=Math.max(0,Math.min(k.top,h.height()))}h.triggerRedrawOverlay()};h.clearCrosshair=h.setCrosshair;h.lockCrosshair=function f(k){if(k){h.setCrosshair(k)}j.locked=true};h.unlockCrosshair=function g(){j.locked=false};function d(k){if(j.locked){return}if(j.x!=-1){j.x=-1;h.triggerRedrawOverlay()}}function i(k){if(j.locked){return}if(h.getSelection&&h.getSelection()){j.x=-1;return}var l=h.offset();j.x=Math.max(0,Math.min(k.pageX-l.left,h.width()));j.y=Math.max(0,Math.min(k.pageY-l.top,h.height()));h.triggerRedrawOverlay()}h.hooks.bindEvents.push(function(l,k){if(!l.getOptions().crosshair.mode){return}k.mouseout(d);k.mousemove(i)});h.hooks.drawOverlay.push(function(m,k){var n=m.getOptions().crosshair;if(!n.mode){return}var l=m.getPlotOffset();k.save();k.translate(l.left,l.top);if(j.x!=-1){k.strokeStyle=n.color;k.lineWidth=n.lineWidth;k.lineJoin="round";k.beginPath();if(n.mode.indexOf("x")!=-1){k.moveTo(j.x,0);k.lineTo(j.x,m.height())}if(n.mode.indexOf("y")!=-1){k.moveTo(0,j.y);k.lineTo(m.width(),j.y)}k.stroke()}k.restore()});h.hooks.shutdown.push(function(l,k){k.unbind("mouseout",d);k.unbind("mousemove",i)})}b.plot.plugins.push({init:c,options:a,name:"crosshair",version:"1.0"})})(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(function(n,p,u){var w=n([]),s=n.resize=n.extend(n.resize,{}),o,l="setTimeout",m="resize",t=m+"-special-event",v="delay",r="throttleWindow";s[v]=250;s[r]=true;n.event.special[m]={setup:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.add(a);n.data(this,t,{w:a.width(),h:a.height()});if(w.length===1){q()}},teardown:function(){if(!s[r]&&this[l]){return false}var a=n(this);w=w.not(a);a.removeData(t);if(!w.length){clearTimeout(o)}},add:function(b){if(!s[r]&&this[l]){return false}var c;function a(d,h,g){var f=n(this),e=n.data(this,t);e.w=h!==u?h:f.width();e.h=g!==u?g:f.height();c.apply(this,arguments)}if(n.isFunction(b)){c=b;return a}else{c=b.handler;b.handler=a}}};function q(){o=p[l](function(){w.each(function(){var d=n(this),a=d.width(),b=d.height(),c=n.data(this,t);if(a!==c.w||b!==c.h){d.trigger(m,[c.w=a,c.h=b])}});q()},s[v])}})(jQuery,this);(function(b){var a={};function c(f){function e(){var h=f.getPlaceholder();if(h.width()==0||h.height()==0){return}f.resize();f.setupGrid();f.draw()}function g(i,h){i.getPlaceholder().resize(e)}function d(i,h){i.getPlaceholder().unbind("resize",e)}f.hooks.bindEvents.push(g);f.hooks.shutdown.push(d)}b.plot.plugins.push({init:c,options:a,name:"resize",version:"1.0"})})(jQuery);

View File

@ -0,0 +1 @@
(function(a){function b(k){var p={first:{x:-1,y:-1},second:{x:-1,y:-1},show:false,active:false};var m={};var r=null;function e(s){if(p.active){l(s);k.getPlaceholder().trigger("plotselecting",[g()])}}function n(s){if(s.which!=1){return}document.body.focus();if(document.onselectstart!==undefined&&m.onselectstart==null){m.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!==undefined&&m.ondrag==null){m.ondrag=document.ondrag;document.ondrag=function(){return false}}d(p.first,s);p.active=true;r=function(t){j(t)};a(document).one("mouseup",r)}function j(s){r=null;if(document.onselectstart!==undefined){document.onselectstart=m.onselectstart}if(document.ondrag!==undefined){document.ondrag=m.ondrag}p.active=false;l(s);if(f()){i()}else{k.getPlaceholder().trigger("plotunselected",[]);k.getPlaceholder().trigger("plotselecting",[null])}return false}function g(){if(!f()){return null}var u={},t=p.first,s=p.second;a.each(k.getAxes(),function(v,w){if(w.used){var y=w.c2p(t[w.direction]),x=w.c2p(s[w.direction]);u[v]={from:Math.min(y,x),to:Math.max(y,x)}}});return u}function i(){var s=g();k.getPlaceholder().trigger("plotselected",[s]);if(s.xaxis&&s.yaxis){k.getPlaceholder().trigger("selected",[{x1:s.xaxis.from,y1:s.yaxis.from,x2:s.xaxis.to,y2:s.yaxis.to}])}}function h(t,u,s){return u<t?t:(u>s?s:u)}function d(w,t){var v=k.getOptions();var u=k.getPlaceholder().offset();var s=k.getPlotOffset();w.x=h(0,t.pageX-u.left-s.left,k.width());w.y=h(0,t.pageY-u.top-s.top,k.height());if(v.selection.mode=="y"){w.x=w==p.first?0:k.width()}if(v.selection.mode=="x"){w.y=w==p.first?0:k.height()}}function l(s){if(s.pageX==null){return}d(p.second,s);if(f()){p.show=true;k.triggerRedrawOverlay()}else{q(true)}}function q(s){if(p.show){p.show=false;k.triggerRedrawOverlay();if(!s){k.getPlaceholder().trigger("plotunselected",[])}}}function c(s,w){var t,y,z,A,x=k.getAxes();for(var u in x){t=x[u];if(t.direction==w){A=w+t.n+"axis";if(!s[A]&&t.n==1){A=w+"axis"}if(s[A]){y=s[A].from;z=s[A].to;break}}}if(!s[A]){t=w=="x"?k.getXAxes()[0]:k.getYAxes()[0];y=s[w+"1"];z=s[w+"2"]}if(y!=null&&z!=null&&y>z){var v=y;y=z;z=v}return{from:y,to:z,axis:t}}function o(t,s){var v,u,w=k.getOptions();if(w.selection.mode=="y"){p.first.x=0;p.second.x=k.width()}else{u=c(t,"x");p.first.x=u.axis.p2c(u.from);p.second.x=u.axis.p2c(u.to)}if(w.selection.mode=="x"){p.first.y=0;p.second.y=k.height()}else{u=c(t,"y");p.first.y=u.axis.p2c(u.from);p.second.y=u.axis.p2c(u.to)}p.show=true;k.triggerRedrawOverlay();if(!s&&f()){i()}}function f(){var s=5;return Math.abs(p.second.x-p.first.x)>=s&&Math.abs(p.second.y-p.first.y)>=s}k.clearSelection=q;k.setSelection=o;k.getSelection=g;k.hooks.bindEvents.push(function(t,s){var u=t.getOptions();if(u.selection.mode!=null){s.mousemove(e);s.mousedown(n)}});k.hooks.drawOverlay.push(function(v,D){if(p.show&&f()){var t=v.getPlotOffset();var s=v.getOptions();D.save();D.translate(t.left,t.top);var z=a.color.parse(s.selection.color);D.strokeStyle=z.scale("a",0.8).toString();D.lineWidth=1;D.lineJoin="round";D.fillStyle=z.scale("a",0.4).toString();var B=Math.min(p.first.x,p.second.x),A=Math.min(p.first.y,p.second.y),C=Math.abs(p.second.x-p.first.x),u=Math.abs(p.second.y-p.first.y);D.fillRect(B,A,C,u);D.strokeRect(B,A,C,u);D.restore()}});k.hooks.shutdown.push(function(t,s){s.unbind("mousemove",e);s.unbind("mousedown",n);if(r){a(document).unbind("mouseup",r)}})}a.plot.plugins.push({init:b,options:{selection:{mode:null,color:"#e8cfac"}},name:"selection",version:"1.1"})})(jQuery);

View File

@ -0,0 +1 @@
(function(b){var a={series:{stack:null}};function c(f){function d(k,j){var h=null;for(var g=0;g<j.length;++g){if(k==j[g]){break}if(j[g].stack==k.stack){h=j[g]}}return h}function e(C,v,g){if(v.stack==null){return}var p=d(v,C.getData());if(!p){return}var z=g.pointsize,F=g.points,h=p.datapoints.pointsize,y=p.datapoints.points,t=[],x,w,k,J,I,r,u=v.lines.show,G=v.bars.horizontal,o=z>2&&(G?g.format[2].x:g.format[2].y),n=u&&v.lines.steps,E=true,q=G?1:0,H=G?0:1,D=0,B=0,A;while(true){if(D>=F.length){break}A=t.length;if(F[D]==null){for(m=0;m<z;++m){t.push(F[D+m])}D+=z}else{if(B>=y.length){if(!u){for(m=0;m<z;++m){t.push(F[D+m])}}D+=z}else{if(y[B]==null){for(m=0;m<z;++m){t.push(null)}E=true;B+=h}else{x=F[D+q];w=F[D+H];J=y[B+q];I=y[B+H];r=0;if(x==J){for(m=0;m<z;++m){t.push(F[D+m])}t[A+H]+=I;r=I;D+=z;B+=h}else{if(x>J){if(u&&D>0&&F[D-z]!=null){k=w+(F[D-z+H]-w)*(J-x)/(F[D-z+q]-x);t.push(J);t.push(k+I);for(m=2;m<z;++m){t.push(F[D+m])}r=I}B+=h}else{if(E&&u){D+=z;continue}for(m=0;m<z;++m){t.push(F[D+m])}if(u&&B>0&&y[B-h]!=null){r=I+(y[B-h+H]-I)*(x-J)/(y[B-h+q]-J)}t[A+H]+=r;D+=z}}E=false;if(A!=t.length&&o){t[A+2]+=r}}}}if(n&&A!=t.length&&A>0&&t[A]!=null&&t[A]!=t[A-z]&&t[A+1]!=t[A-z+1]){for(m=0;m<z;++m){t[A+z+m]=t[A+m]}t[A+1]=t[A-z+1]}}g.points=t}f.hooks.processDatapoints.push(e)}b.plot.plugins.push({init:c,options:a,name:"stack",version:"1.2"})})(jQuery);

View File

@ -0,0 +1 @@
(function(b){function a(h,e,g){var d={square:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.rect(j-l,n-l,l+l,l+l)},diamond:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI/2);k.moveTo(j-l,n);k.lineTo(j,n-l);k.lineTo(j+l,n);k.lineTo(j,n+l);k.lineTo(j-l,n)},triangle:function(l,k,o,j,n){var m=j*Math.sqrt(2*Math.PI/Math.sin(Math.PI/3));var i=m*Math.sin(Math.PI/3);l.moveTo(k-m/2,o+i/2);l.lineTo(k+m/2,o+i/2);if(!n){l.lineTo(k,o-i/2);l.lineTo(k-m/2,o+i/2)}},cross:function(k,j,n,i,m){var l=i*Math.sqrt(Math.PI)/2;k.moveTo(j-l,n-l);k.lineTo(j+l,n+l);k.moveTo(j-l,n+l);k.lineTo(j+l,n-l)}};var f=e.points.symbol;if(d[f]){e.points.symbol=d[f]}}function c(d){d.hooks.processDatapoints.push(a)}b.plot.plugins.push({init:c,name:"symbols",version:"1.0"})})(jQuery);

View File

@ -0,0 +1,132 @@
/*
Flot plugin for thresholding data. Controlled through the option
"threshold" in either the global series options
series: {
threshold: {
below: number
color: colorspec
}
}
or in a specific series
$.plot($("#placeholder"), [{ data: [ ... ], threshold: { ... }}])
An array can be passed for multiple thresholding
threshold: [{
below: number1
color: color1
},{
below: number2
color: color2
}]
These multiple threshold objects can be passed in any order since they
are sorted by the processing function.
The data points below "below" are drawn with the specified color. This
makes it easy to mark points below 0, e.g. for budget data.
Internally, the plugin works by splitting the data into two series,
above and below the threshold. The extra series below the threshold
will have its label cleared and the special "originSeries" attribute
set to the original series. You may need to check for this in hover
events.
*/
(function ($) {
var options = {
series: { threshold: null } // or { below: number, color: color spec}
};
function init(plot) {
function thresholdData(plot, s, datapoints, below, color) {
var ps = datapoints.pointsize, i, x, y, p, prevp,
thresholded = $.extend({}, s); // note: shallow copy
thresholded.datapoints = { points: [], pointsize: ps };
thresholded.label = null;
thresholded.color = color;
thresholded.threshold = null;
thresholded.originSeries = s;
thresholded.data = [];
var origpoints = datapoints.points,
addCrossingPoints = s.lines.show;
threspoints = [];
newpoints = [];
for (i = 0; i < origpoints.length; i += ps) {
x = origpoints[i]
y = origpoints[i + 1];
prevp = p;
if (y < below)
p = threspoints;
else
p = newpoints;
if (addCrossingPoints && prevp != p && x != null
&& i > 0 && origpoints[i - ps] != null) {
var interx = (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]) * (below - y) + x;
prevp.push(interx);
prevp.push(below);
for (m = 2; m < ps; ++m)
prevp.push(origpoints[i + m]);
p.push(null); // start new segment
p.push(null);
for (m = 2; m < ps; ++m)
p.push(origpoints[i + m]);
p.push(interx);
p.push(below);
for (m = 2; m < ps; ++m)
p.push(origpoints[i + m]);
}
p.push(x);
p.push(y);
if (thresholded.lines.fill) {
p.push(0)
}
}
datapoints.points = newpoints;
thresholded.datapoints.points = threspoints;
if (thresholded.datapoints.points.length > 0)
plot.getData().push(thresholded);
// FIXME: there are probably some edge cases left in bars
}
function iterateThresholds(plot, s, datapoints) {
if(!s.threshold)
return;
if(s.threshold instanceof Array) {
s.threshold.sort(function(a, b) {
return a.below - b.below;
});
$(s.threshold).each(function(i, th) {
thresholdData(plot, s, datapoints, th.below, th.color);
});
} else {
thresholdData(plot, s, datapoints, s.threshold.below, s.threshold.color);
}
}
plot.hooks.processDatapoints.push(iterateThresholds);
}
$.plot.plugins.push({
init: init,
options: options,
name: 'threshold',
version: '1.0'
});
})(jQuery);

View File

@ -0,0 +1,912 @@
/*
*/
function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator) {
var labels = labels.split(separator);
var data = values.split(separator);
for( var i = 0; i<nseries; i++)
{
data[i] = { label: labels[i], data: parseInt(data[i]) }
}
var label_conf;
if(width < 300) {
label_conf = {
show: false
};
}
else {
label_conf = {
show: true,
radius: 3/4,
formatter: function(label, series){
return '<div style="font-size:'+font_size+'pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
},
background: {
opacity: 0.5,
color: '#000'
}
};
}
var plot = $jq161.plot($('#'+graph_id), data,
{
series: {
pie: {
show: true,
radius: 3/4,
label: label_conf
//$label_str
}
},
legend: {
show: true
},
grid: {
hoverable: true,
clickable: true
}
});
var legends = $('#'+graph_id+' .legendLabel');
legends.each(function () {
// fix the widths so they don't jump around
$(this).css('width', $(this).width()+5);
});
// Events
$jq161('#'+graph_id).bind('plothover', pieHover);
$jq161('#'+graph_id).bind('plotclick', pieClick);
$jq161('#'+graph_id).bind('mouseout',resetInteractivity);
function pieHover(event, pos, obj)
{
if (!obj)
return;
index = obj.seriesIndex;
legends.css('font-weight', '');
legends.eq(index).css('font-weight', 'bold');
}
// Reset styles
function resetInteractivity() {
legends.each(function () {
// fix the widths so they don't jump around
$(this).css('font-weight', '');
});
}
if(water_mark) {
// Set the watermark position
$('#watermark_image_'+graph_id)[0].onload = function() {
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
$('#watermark_'+graph_id).css('left',canvaslimit_right-parseInt(this.width));
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
$('#watermark_'+graph_id).show();
}
}
}
function pandoraFlotHBars(graph_id, values, labels, water_mark, maxvalue, water_mark, separator, separator2) {
values = values.split(separator2);
var datas = new Array();
for(i=0;i<values.length;i++) {
var serie = values[i].split(separator);
var aux = new Array();
$.each(serie.reverse(),function(i,v) {
aux.push([v, i]);
});
datas.push({
data: aux,
bars: { show: true, horizontal: true, fillColor: { colors: [ { opacity: 0.7 }, { opacity: 1 } ] }, lineWidth:1, steps:false }
});
}
labels = labels.split(separator).reverse();
var stack = 0, bars = true, lines = false, steps = false;
var options = {
series: {
shadowSize: 0.1
},
grid: {
hoverable: true,
borderWidth:1,
borderColor: '#666',
tickColor: '#eee'
},
xaxes: [ {
tickFormatter: yFormatter,
color: '#000'
} ],
yaxes: [ {
tickFormatter: xFormatter,
tickSize: 1,
color: '#000'
},
{
// align if we are to the right
alignTicksWithAxis: 1,
position: 'right',
//tickFormatter: dFormatter
} ]
,
legend: {
show: false
}
};
var plot = $jq161.plot($('#'+graph_id),datas, options );
// Adjust the top of yaxis tick to set it in the middle of the bars
yAxisHeight = $('#'+graph_id+' .yAxis .tickLabel').css('height').split('px')[0];
i = 0;
$('#'+graph_id+' .yAxis .tickLabel').each(function() {
tickTop = $(this).css('top').split('px')[0];
tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight/2)-3);
$(this).css('top', tickNewTop+'px');
valuesNewTop = parseInt(parseInt(tickTop) - (yAxisHeight));
$('#value_'+i+'_'+graph_id).css('top',parseInt(plot.offset().top) + parseInt(valuesNewTop));
pixelPerValue = parseInt(plot.width()) / maxvalue;
inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html()));
$('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3);
i++;
});
// When resize the window, adjust the values
$jq161('#'+graph_id).parent().resize(function () {
i = 0;
pixelPerValue = parseInt(plot.width()) / maxvalue;
$('#'+graph_id+' .yAxis .tickLabel').each(function() {
inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html()));
$('#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) {
return labels[v];
}
else {
return '';
}
}
function yFormatter(v, axis) {
return v;
}
function lFormatter(v, axis) {
return '<div style=color:#000>'+v+'</div>';
}
// Events
$jq161('#'+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) {
// Adjust the menu image on top of the plot
$('#watermark_image_'+graph_id)[0].onload = function() {
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
$('#watermark_'+graph_id).css('left',canvaslimit_right);
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
$('#watermark_'+graph_id).show();
}
}
}
function pandoraFlotVBars(graph_id, values, labels, water_mark, maxvalue, water_mark, separator, separator2) {
values = values.split(separator2);
var datas = new Array();
for(i=0;i<values.length;i++) {
var serie = values[i].split(separator);
var aux = new Array();
$.each(serie,function(i,v) {
aux.push([i, v]);
});
datas.push({
data: aux,
bars: { show: true, horizontal: false, fillColor: { colors: [ { opacity: 0.7 }, { opacity: 1 } ] }, lineWidth:1, steps:false }
});
}
labels = labels.split(separator).reverse();
var stack = 0, bars = true, lines = false, steps = false;
var options = {
series: {
shadowSize: 0.1
},
grid: {
hoverable: true,
borderWidth:1,
borderColor: '#666',
tickColor: '#eee'
},
xaxes: [ {
tickFormatter: xFormatter,
color: '#000'
} ],
yaxes: [ {
tickFormatter: yFormatter,
tickSize: 1,
color: '#000'
},
{
// align if we are to the right
alignTicksWithAxis: 1,
position: 'right',
//tickFormatter: dFormatter
} ]
,
legend: {
show: false
}
};
var plot = $jq161.plot($('#'+graph_id),datas, options );
// Adjust the top of yaxis tick to set it in the middle of the bars
yAxisHeight = $('#'+graph_id+' .yAxis .tickLabel').css('height').split('px')[0];
i = 0;
//~ $('#'+graph_id+' .yAxis .tickLabel').each(function() {
//~ tickTop = $(this).css('top').split('px')[0];
//~ tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight/2)-3);
//~ $(this).css('top', tickNewTop+'px');
//~
//~ valuesNewTop = parseInt(parseInt(tickTop) - (yAxisHeight));
//~
//~ $('#value_'+i+'_'+graph_id).css('top',parseInt(plot.offset().top) + parseInt(valuesNewTop));
//~
//~ pixelPerValue = parseInt(plot.width()) / maxvalue;
//~
//~ inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html()));
//~
//~ $('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3);
//~ i++;
//~ });
// When resize the window, adjust the values
//~ $jq161('#'+graph_id).parent().resize(function () {
//~ i = 0;
//~ pixelPerValue = parseInt(plot.width()) / maxvalue;
//~
//~ $('#'+graph_id+' .yAxis .tickLabel').each(function() {
//~ inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html()));
//~
//~ $('#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) {
return labels[v];
}
else {
return '';
}
}
function yFormatter(v, axis) {
return v;
}
function lFormatter(v, axis) {
return '<div style=color:#000>'+v+'</div>';
}
// Events
//~ $jq161('#'+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) {
// Adjust the menu image on top of the plot
$('#watermark_image_'+graph_id)[0].onload = function() {
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
$('#watermark_'+graph_id).css('left',canvaslimit_right);
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
$('#watermark_'+graph_id).show();
}
}
}
function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumulate_data, intervaltick, water_mark, maxvalue, separator, separator2) {
values = values.split(separator2);
labels = labels.split(separator);
legend = legend.split(separator);
acumulate_data = acumulate_data.split(separator);
datacolor = datacolor.split(separator);
var datas = new Array();
for(i=0;i<values.length;i++) {
var serie = values[i].split(separator);
var aux = new Array();
$.each(serie,function(i,v) {
aux.push([v, i]);
});
datas.push({
data: aux,
bars: { show: true, fill: true ,fillColor: datacolor[i] , horizontal: true, lineWidth:0, steps:false }
});
}
var stack = 0, bars = true, lines = false, steps = false;
var options = {
series: {
stack: stack,
shadowSize: 0.1,
color: '#ddd'
},
grid: {
hoverable: true,
borderWidth:1,
borderColor: '#000',
tickColor: '#fff'
},
xaxes: [ {
tickFormatter: xFormatter,
color: '#000',
tickSize: intervaltick,
tickLength: 0
} ],
yaxes: [ {
show: false,
tickLength: 0
}],
legend: {
show: false
}
};
var plot = $jq161.plot($('#'+graph_id), datas, options );
// Format functions
function xFormatter(v, axis) {
for(i = 0; i < acumulate_data.length; i++) {
if(acumulate_data[i] == v) {
return '<span style=\'font-size: 7pt\'>' + 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, separator, separator2) {
var threshold = false;
values = values.split(separator2);
serie_types = serie_types.split(separator);
labels_long = labels_long.split(separator);
labels = labels.split(separator);
legend = legend.split(separator);
events = events.split(separator);
event_ids = event_ids.split(separator);
alerts = alerts.split(separator);
alert_ids = alert_ids.split(separator);
colors = colors.split(separator);
var eventsz = new Array();
$.each(events,function(i,v) {
eventsz[event_ids[i]] = v;
});
var alertsz = new Array();
$.each(alerts,function(i,v) {
alertsz[alert_ids[i]] = v;
});
switch(type) {
case 'line_simple':
stacked = null;
filled = false;
break;
case 'line_stacked':
stacked = 'stack';
filled = false;
break;
case 'area_simple':
stacked = null;
filled = true;
break;
case 'area_stacked':
stacked = 'stack';
filled = true;
break;
}
var datas = new Array();
vwarning_min = 60;
vwarning_max = 70;
vcritical_min = 70;
vcritical_max = -1;
for(i=0;i<values.length;i++) {
var serie = values[i].split(separator);
var aux = new Array();
var critical_min = new Array();
var warning_min = new Array();
$.each(serie,function(i,v) {
aux.push([i, v]);
if(threshold) {
critical_min.push([i,vcritical_min]);
warning_min.push([i,vwarning_min]);
}
});
switch(serie_types[i]) {
case 'line':
default:
line_show = true;
points_show = false;
break;
case 'points':
line_show = false;
points_show = true;
break;
}
var serie_color;
if(colors[i] != '') {
serie_color = colors[i];
}
else {
serie_color = null;
}
var normalw = '#efe';
var warningw = '#ffe';
var criticalw = '#fee';
var normal = '#0f0';
var warning = '#ff0';
var critical = '#f00';
// setup background areas
vnormal_max = vwarning_min - 1;
var markings = null;
// Fill the grid background with weak threshold colors
//~ markings = [
//~ { color: normalw, yaxis: { from: -1,to: vnormal_max } },
//~ { color: warningw, yaxis: { from: vwarning_min, to: vwarning_max } },
//~ { color: criticalw, yaxis: { from: vcritical_min } },
//~ { color: criticalw, yaxis: { to: -1 } }
//~ ];
if(threshold) {
// Warning and critical treshold
datas.push({
id: 'critical_min',
data: critical_min,
label: null,
color: critical,
lines: { show: true, fill: false, lineWidth:3},
});
datas.push({
id: 'warning_min',
data: warning_min,
label: null,
color: warning,
lines: { show: true, fill: false, lineWidth:3},
});
}
// Data
datas.push({
data: aux,
label: legend[i],
color: serie_color,
//threshold: [{ below: 80, color: "rgb(200, 20, 30)" } , { below: 65, color: "rgb(30, 200, 30)" }, { below: 50, color: "rgb(30, 200, 30)" }],
lines: { show: line_show, fill: filled, fillColor: { colors: [ { opacity: 1 }, { opacity: 0.7 } ]}, lineWidth:1, steps:false },
points: { show: points_show }
});
//~ datas.push({
//~ id: 'normal_min',
//~ data: normal_min,
//~ label: null,
//~ color: normal,
//~ lines: { show: true, fill: filled, fillColor: { colors: [ { opacity: 0.4 }, { opacity: 0.4 } ]}, lineWidth:0},
//~ });
}
// minTickSize
var mts = 130;
var options = {
series: {
stack: stacked,
shadowSize: 0.1
},
crosshair: { mode: 'xy' },
selection: { mode: 'x', color: '#777' },
grid: {
hoverable: true,
clickable: true,
borderWidth:1,
borderColor: '#666',
tickColor: '#eee',
markings: markings
},
xaxes: [ {
tickFormatter: xFormatter,
minTickSize: mts,
color: '#000'
} ],
yaxes: [ {
tickFormatter: yFormatter,
min: 0,
color: '#000'
},
{
// align if we are to the right
alignTicksWithAxis: 1,
position: 'right',
//tickFormatter: dFormatter
} ]
,
legend: {
position: 'se',
container: $('#legend_'+graph_id),
labelFormatter: lFormatter
}
};
var stack = 0, bars = true, lines = false, steps = false;
var plot = $jq161.plot($('#'+graph_id), datas, options );
// Adjust the overview plot to the width and position of the main plot
yAxisWidth = $('#'+graph_id+' .yAxis .tickLabel').css('width');
overview_pix = $('#overview_'+graph_id).css('width').split('px');
new_overview_width = parseInt(overview_pix[0])-parseInt(yAxisWidth);
$('#overview_'+graph_id).css('width',new_overview_width);
$('#overview_'+graph_id).css('margin-left',yAxisWidth);
// Miniplot
var overview = $jq161.plot($('#overview_'+graph_id),datas, {
series: {
stack: stacked,
lines: { show: true, lineWidth: 1 },
shadowSize: 0
},
grid: { borderWidth: 1, hoverable: true, autoHighlight: false},
xaxis: { },
xaxes: [ {
tickFormatter: xFormatter,
minTickSize: mts,
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
$jq161('#'+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;
new_mts = parseInt(factor*mts);
plot = $jq161.plot($('#'+graph_id), datas,
$jq161.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to},
xaxes: [ {
tickFormatter: xFormatter,
minTickSize: new_mts,
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);
});
$jq161('#overview_'+graph_id).bind('plotselected', function (event, ranges) {
plot.setSelection(ranges);
});
var legends = $('#legend_'+graph_id+' .legendLabel');
var updateLegendTimeout = 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;
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 j, dataset = currentPlot.getData();
var i = 0;
for (k = 0; k < dataset.length; ++k) {
// k is the real series counter
// i is the series counter without thresholds
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;
}
var y = series.data[j][1];
if(currentRanges == null || (currentRanges.xaxis.from < j && j < currentRanges.xaxis.to)) {
$jq161('#timestamp_'+graph_id).show();
if(width < 400) {
$('#timestamp_'+graph_id).text(labels[j] + ' (' + parseFloat(y).toFixed(2) + ')');
}
else {
$('#timestamp_'+graph_id).text(labels_long[j]);
}
$('#timestamp_'+graph_id).css('top', plot.offset().top);
var timesize = $('#timestamp_'+graph_id).width();
if(currentRanges != null) {
dataset = plot.getData();
}
var timenewpos = dataset[0].xaxis.p2c(pos.x)+plot.offset().left;
var canvaslimit = plot.offset().left + plot.width();
if(timesize+timenewpos > canvaslimit) {
$('#timestamp_'+graph_id).css('left', timenewpos - timesize);
}
else {
$('#timestamp_'+graph_id).css('left', timenewpos);
}
}
else {
$jq161('#timestamp_'+graph_id).hide();
}
var label_aux = series.label + ' = ';
if(serie_types[i] != 'points') {
legends.eq(i).text(label_aux.replace(/=.*/, '= ' + parseFloat(y).toFixed(2) +' '+unit));
}
legends.eq(i).css('font-size',font_size+'pt');
legends.eq(i).css('color','#000');
i++;
}
}
// Events
$jq161('#'+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);
}
});
$jq161('#'+graph_id).bind("plotclick", function (event, pos, item) {
plot.unhighlight();
if (item) {
plot.unhighlight();
var canvaslimit = parseInt(plot.offset().left + plot.width());
var dataset = plot.getData();
var timenewpos = parseInt(dataset[0].xaxis.p2c(pos.x)+plot.offset().left);
var extrasize = parseInt($('#extra_'+graph_id).css('width').split('px')[0]);
var left_pos;
if(extrasize+timenewpos > canvaslimit) {
left_pos = timenewpos - extrasize - 20;
}
else {
left_pos = timenewpos + 20;
}
var extra_info = '<i>No info to show</i>';
var extra_show = false;
$('#extra_'+graph_id).css('left',left_pos);
$('#extra_'+graph_id).css('top',plot.offset().top + 25);
switch(item.series.label) {
case legend_alerts:
extra_info = '<b>'+legend_alerts+' - '+labels_long[item.dataIndex]+'</b>'+get_event_details(alertsz[item.dataIndex]);
extra_show = true;
break;
case legend_events:
extra_info = '<b>'+legend_events+' - '+labels_long[item.dataIndex]+'</b>'+get_event_details(eventsz[item.dataIndex]);
extra_show = true;
break;
}
if(extra_show) {
$('#extra_'+graph_id).html(extra_info);
$('#extra_'+graph_id).css('display','');
}
plot.highlight(item.series, item.datapoint);
}
else {
$('#extra_'+graph_id).css('display','none');
}
});
$jq161('#overview_'+graph_id).bind('plothover', function (event, pos, item) {
plot.setCrosshair({ x: pos.x, y: 0 });
currentPlot = overview;
latestPosition = pos;
if (!updateLegendTimeout) {
updateLegendTimeout = setTimeout(updateLegend, 50);
}
});
$jq161('#'+graph_id).bind('mouseout',resetInteractivity);
$jq161('#overview_'+graph_id).bind('mouseout',resetInteractivity);
// Reset interactivity styles
function resetInteractivity() {
$('#timestamp_'+graph_id).hide();
dataset = plot.getData();
for (i = 0; i < dataset.length; ++i) {
legends.eq(i).text(legends.eq(i).text().replace(/=.*/, ''));
}
plot.clearCrosshair();
overview.clearCrosshair();
}
// Format functions
function xFormatter(v, axis) {
if(labels[v] == undefined) {
return '';
}
return '<div style=font-size:'+font_size+'pt>'+labels[v]+'</div>';
}
function yFormatter(v, axis) {
return '<div style=font-size:'+font_size+'pt>'+v+' '+unit+'</div>';
}
function lFormatter(v, axis) {
return '<div style=color:#000;font-size:'+font_size+'pt>'+v+'</div>';
}
if(menu) {
$('#menu_overview_'+graph_id).click(function() {
$('#overview_'+graph_id).toggle();
});
$('#menu_cancelzoom_'+graph_id).click(function() {
// cancel the zooming
plot = $jq161.plot($('#'+graph_id), datas,
$jq161.extend(true, {}, options, {
xaxis: { min: 0, max: max_x },
legend: { show: false }
}));
$('#menu_cancelzoom_'+graph_id).attr('src',homeurl+'/images/zoom_cross.disabled.png');
overview.clearSelection();
});
// Adjust the menu image on top of the plot
$('#menu_overview_'+graph_id)[0].onload = function() {
var canvaslimit_right = parseInt(plot.offset().left + plot.width() - 20);
var canvaslimit_top = parseInt(plot.offset().top - 8);
var n_options = parseInt($('#menu_'+graph_id).children().length);
$('#menu_'+graph_id).css('left',canvaslimit_right-parseInt(this.width)*n_options);
$('#menu_'+graph_id).css('top',canvaslimit_top-parseInt(this.height));
$('#menu_'+graph_id).show();
}
}
if(water_mark) {
// Adjust the menu image on top of the plot
$('#watermark_image_'+graph_id)[0].onload = function() {
var canvaslimit_right = parseInt(plot.offset().left + plot.width());
var canvaslimit_bottom = parseInt(plot.offset().top + plot.height());
$('#watermark_'+graph_id).css('left',canvaslimit_right);
$('#watermark_'+graph_id).css('top',canvaslimit_bottom-parseInt(this.height));
$('#watermark_'+graph_id).show();
}
}
}
function get_event_details (event_ids) {
var inputs = [];
var table;
inputs.push ("get_events_details=1");
inputs.push ("event_ids="+event_ids);
inputs.push ("page=include/ajax/events");
jQuery.ajax ({
data: inputs.join ("&"),
type: 'GET',
url: action="../../ajax.php",
timeout: 10000,
dataType: 'html',
async: false,
success: function (data) {
table = data;
}
});
return table;
}

File diff suppressed because it is too large Load Diff

View File

@ -131,4 +131,25 @@ function graph_get_max_index($legend_values) {
return $max_chars;
}
function setup_watermark($water_mark, &$water_mark_file, &$water_mark_url) {
if(!is_array($water_mark)) {
$water_mark['file'] = $water_mark;
}
if(isset($water_mark['file'])) {
$water_mark_file = $water_mark['file'];
}
else {
$water_mark_file = '';
}
if(isset($water_mark['url'])) {
$water_mark_url = $water_mark['url'];
}
else {
$water_mark_url = '';
}
}
?>

View File

@ -16,6 +16,7 @@
/* Function that includes all graph dependencies */
function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) {
global $config;
global $ttl;
global $homeurl;
@ -24,7 +25,10 @@
include_once($homeurl . 'include/functions_io.php');
include_once($homeurl . 'include/functions.php');
include_once($homeurl . 'include/functions_html.php');
if($config['flash_charts'] && !defined('AJAX') && !get_parameter('static_graph',0)) {
include_once($homeurl . 'include/graphs/functions_flot.php');
}
include_once($homeurl . 'include/graphs/functions_fsgraph.php');
include_once($homeurl . 'include/graphs/functions_gd.php');
include_once($homeurl . 'include/graphs/functions_utils.php');

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,78 @@
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
*
* Requires: 1.2.2+
*/
(function($) {
var types = ['DOMMouseScroll', 'mousewheel'];
$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},
unmousewheel: function(fn) {
return this.unbind("mousewheel", fn);
}
});
function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";
// Old school scrollwheel delta
if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
if ( event.detail ) { delta = -event.detail/3; }
// New school multidimensional scroll (touchpads) deltas
deltaY = delta;
// Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0;
deltaX = -1*delta;
}
// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
return $.event.handle.apply(this, args);
}
})(jQuery);

View File

@ -10,8 +10,8 @@ function toggleDiv (divid){
}
function winopeng (url, wid) {
open (url, wid,"width=590,height=410,status=no,toolbar=no,menubar=no,scrollbar=no");
// WARNING !! Internet Explorer DOESNT SUPPORT "-" CARACTERS IN WINDOW HANDLE VARIABLE
open (url, wid,"width=650,height=410,status=no,toolbar=no,menubar=no,scrollbar=no");
// WARNING !! Internet Explorer DOESNT SUPPORT "-" CHARACTERS IN WINDOW HANDLE VARIABLE
status =wid;
}

View File

@ -66,12 +66,9 @@ if ($config["agentaccess"]){
echo '<div style="height:25px">&nbsp;</div>';
echo '<b>'.__('Events generated -by module-').'</b><br />';
echo graph_event_module (290, 120, $id_agente);
if ($config['flash_charts']) {
echo graphic_agentevents ($id_agente, 290, 60, 86400);
}
else{
graph_graphic_agentevents_static ($id_agente, 290, 15, 86400, '');
}
echo '<br>';
graph_graphic_agentevents_static ($id_agente, 290, 15, 86400, '');
echo '</div>';
echo '<div width="450px">';

View File

@ -14,16 +14,14 @@
// GNU General Public License for more details.
// Global & session management
require_once ('../../include/config.php');
require_once ('../../include/auth/mysql.php');
if (! isset($_SESSION['id_usuario'])) {
session_start();
session_write_close();
}
// Global & session management
require_once ('../../include/config.php');
require_once ('../../include/auth/mysql.php');
require_once ($config['homedir'] . '/include/functions.php');
require_once ($config['homedir'] . '/include/functions_db.php');
require_once ($config['homedir'] . '/include/functions_reporting.php');
@ -32,6 +30,8 @@ require_once ($config['homedir'] . '/include/functions_modules.php');
check_login ();
echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css"/>';
$id = get_parameter('id');
$label = base64_decode(get_parameter('label', ''));
?>
@ -108,7 +108,7 @@ function show_others() {
//-->
</script>
</head>
<body bgcolor="#ffffff">
<body bgcolor="#ffffff" style='background:#ffffff;'>
<?php
// Get input parameters
@ -161,6 +161,9 @@ $urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/';
// log4x doesnt support flash yet
//
echo "<br>";
echo "<div style='margin-left:20px'>";
switch ($graph_type) {
case 'boolean':
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
@ -195,6 +198,7 @@ switch ($graph_type) {
echo fs_error_image ('../images');
break;
}
echo "</div>";
//z-index is 1 because 2 made the calendar show under the divmenu.
echo '<div id="divmenu" class="menu" style="z-index:1; height:280px;"><b>'.__('Pandora FMS Graph configuration menu').'</b><br />'.__('Please, make your changes and apply with the <i>Reload</i> button');
@ -273,7 +277,7 @@ html_print_checkbox ("show_events_graph", 1, (bool) $show_events_graph);
echo '</td><td>';
html_print_submit_button ('GO', "submit", false, 'class="sub next"');
html_print_submit_button (__('GO'), "submit", false, 'class="sub next"');
echo '</td></tr></table></form></div></body></html>';
?>