Merge branch '757-fullscale-chart-system-dev' into 'develop'

Added some code to manage timestamps in chart data

See merge request !581
This commit is contained in:
vgilc 2017-06-12 17:54:07 +02:00
commit 0b91390aa7
1 changed files with 35 additions and 58 deletions

View File

@ -256,6 +256,10 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
for ($i = 0; $i <= $resolution; $i++) { for ($i = 0; $i <= $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i); $timestamp = $datelimit + ($interval * $i);
if ($fullscale) {
$timestamp = $data[$i]['utimestamp'];
}
$total = 0; $total = 0;
$count = 0; $count = 0;
@ -263,6 +267,7 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
$interval_min = false; $interval_min = false;
$interval_max = false; $interval_max = false;
if (!$fullscale) {
while (isset ($data[$data_i]) && $data[$data_i]['utimestamp'] >= $timestamp && $data[$data_i]['utimestamp'] < ($timestamp + $interval)) { while (isset ($data[$data_i]) && $data[$data_i]['utimestamp'] >= $timestamp && $data[$data_i]['utimestamp'] < ($timestamp + $interval)) {
if ($interval_min === false) { if ($interval_min === false) {
$interval_min = $data[$data_i]['datos']; $interval_min = $data[$data_i]['datos'];
@ -282,6 +287,7 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
$count++; $count++;
$data_i++; $data_i++;
} }
}
if ($max_value < $interval_max) { if ($max_value < $interval_max) {
$max_value = $interval_max; $max_value = $interval_max;
@ -692,7 +698,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
foreach ($chart as $c_timestamp => $c_data) { foreach ($chart as $c_timestamp => $c_data) {
$timestamp_short = date($time_format, $c_timestamp); $timestamp_short = date($time_format, $c_timestamp);
$new_long_index[$timestamp_short] = date( $new_long_index[$timestamp_short] = date(
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $c_timestamp); html_entity_decode($time_format, ENT_QUOTES, "UTF-8"), $c_timestamp);
$new_chart[$timestamp_short] = $c_data; $new_chart[$timestamp_short] = $c_data;
} }
@ -3772,6 +3778,10 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
for ($i = 0; $i <= $resolution; $i++) { for ($i = 0; $i <= $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i); $timestamp = $datelimit + ($interval * $i);
if ($fullscale) {
$timestamp = $data[$i]['utimestamp'];
}
$zero = 0; $zero = 0;
$total = 0; $total = 0;
$count = 0; $count = 0;
@ -4078,55 +4088,22 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
if ($fullscale) { if ($fullscale) {
if (!$flash_chart) { if (!$flash_chart) {
// Set the title and time format $time_format = "Y M \nd H:i:s";
if ($period <= SECONDS_6HOURS) {
$time_format = 'H:i:s';
}
elseif ($period < SECONDS_1DAY) {
$time_format = 'H:i';
}
elseif ($period < SECONDS_15DAYS) {
$time_format = "M \nd H:i";
}
elseif ($period < SECONDS_1MONTH) {
$time_format = "M \nd H\h";
}
elseif ($period < SECONDS_6MONTHS) {
$time_format = "M \nd H\h";
} }
else { else {
$time_format = "M Y"; $time_format = "Y M d H:i:s";
}
}
else {
// Set the title and time format
if ($period <= SECONDS_6HOURS) {
$time_format = 'H:i:s';
}
elseif ($period < SECONDS_1DAY) {
$time_format = 'H:i';
}
elseif ($period < SECONDS_15DAYS) {
$time_format = "M d H:i";
}
elseif ($period < SECONDS_1MONTH) {
$time_format = "M d H\h";
}
elseif ($period < SECONDS_6MONTHS) {
$time_format = "M d H\h";
}
else {
$time_format = "M Y";
}
} }
$new_chart = array(); $new_chart = array();
$new_long_index = array();
foreach ($chart as $c_timestamp => $c_data) { foreach ($chart as $c_timestamp => $c_data) {
$timestamp_short = date($time_format, $c_timestamp); $timestamp_short = date($time_format, $c_timestamp);
$new_long_index[$timestamp_short] = date(
html_entity_decode($time_format, ENT_QUOTES, "UTF-8"), $c_timestamp);
$new_chart[$timestamp_short] = $c_data; $new_chart[$timestamp_short] = $c_data;
} }
$long_index = $new_long_index;
$chart = $new_chart; $chart = $new_chart;
} }