function return_ofc_day() { global $cms, $ps; $styles =& $cms->theme->styles; $days = array(); $labels = array(); $data = array(); $data_avg = array(); $sum = 0; $avg = 0; $max = 31; $maxlimit = 100; // get the last 31 days of data $list = $ps->db->fetch_rows(1, "SELECT statdate,SUM(connections) connections " . "FROM {$ps->t_map_data} " . "GROUP BY statdate " . "ORDER BY statdate DESC LIMIT {$max}"); $now = $list ? ymd2time($list[0]['statdate']) : time(); while (count($days) < $max) { $days[date('Y-m-d', $now)] = 'null'; $labels[] = date('M jS', $now); $now -= 60 * 60 * 24; } $days = array_reverse($days); $labels = array_reverse($labels); // build our data and labels $data = $days; $maxdata = 0; foreach ($list as $d) { if (!array_key_exists($d['statdate'], $days)) { continue; } $sum += $d['connections']; $data[$d['statdate']] = $d['connections']; $maxdata = max($maxdata, $d['connections']); } if ($data) { $avg = $sum / count($data); $data_avg[] = $avg; $data_avg = array_pad($data_avg, count($data), 'null'); $data_avg[] = $avg; # $data_avg = array_pad(array(), count($data), $avg); $maxlimit = ceil(ceil($maxdata / 100) * 100); } include_once PS_ROOTDIR . '/includes/ofc/open-flash-chart.php'; $g = new graph(); $g->bg_colour = $styles->val('flash.conn.bgcolor', 'flash.bgcolor'); $g->title($styles->val('flash.conn.title', $cms->trans('Daily Connections'), true), '{' . $styles->val('flash.conn.title.style', 'font-size: 16px', true) . '}'); # $g->set_data($data_avg); # $g->line(1, '#9999ee', 'Average Connections', 9); # $g->set_data($data); ## $g->line_hollow(1, 3, '#5555ff', 'Connections', 9); # $g->bar(75, '#5555ff', 'Connections', 9); $avg_line = new line($styles->val('flash.conn.line.width'), $styles->val('flash.conn.line.color')); $avg_line->key($styles->val('flast.conn.line.key', $cms->trans('Average Connections'), true), $styles->val('flash.conn.line.size', 9, true)); $avg_line->data = $data_avg; $conn_bar = new bar_3d($styles->val('flash.conn.bar3d.opacity', 75, true), $styles->val('flash.conn.bar3d.color1', '#5555ff', true), $styles->val('flash.conn.bar3d.color2', '#3333DD', true)); $conn_bar->key($styles->val('flash.conn.bar3d.key', $cms->trans('Connections'), true), $styles->val('flash.conn.bar3d.size', 9, true)); $conn_bar->data = $data; /* $keys = array_keys($data); for ($i=0; $i<count($data); $i++) { $conn_bar->add_data_tip($data[$keys[$i]], $cms->trans("Connections: %d", $data[$keys[$i]]) . "<br>" . $cms->trans("Average: %d", $data_avg[0]) ); } /**/ $g->set_tool_tip(sprintf($styles->val('flash.conn.tooltip', '#x_label#<br>#key#: #val# (' . $cms->trans('Avg') . ': %d)', true), round($data_avg[0]))); $g->data_sets[] = $avg_line; $g->data_sets[] = $conn_bar; $g->set_x_axis_3d(6); // label each point with its value $g->set_x_labels($labels); // $g->set_x_axis_steps(count($labels) / 3 + 1); // $g->set_x_tick_size(1); $g->set_x_label_style(10, '#000000', 0, 3, '#cccccc'); // $g->set_x_label_style('none'); # $g->set_x_label_style( 8, '#000000', 2 ); $g->set_inner_background(coalesce($styles->val('flash.conn.bg_inner1', 'flash.bg_inner1'), '#E3F0FD'), coalesce($styles->val('flash.conn.bg_inner2', 'flash.bg_inner2'), '#CBD7E6'), coalesce($styles->val('flash.conn.bg_inner_angle', 'flash.bg_inner_angle'), 90)); $g->x_axis_colour('#909090', '#ADB5C7'); // $g->x_axis_colour('#eeeeee', '#eeeeee'); $g->y_axis_colour('#5555ff', '#eeeeee'); // $g->set_x_offset( false ); // set the Y max $g->set_y_min(0); $g->set_y_max($maxlimit); $g->set_y_legend($styles->val('flash.conn.bar3d.key', $cms->trans('Connections')), 12, $styles->val('flash.conn.bar3d.color1', '#5555ff', true)); print $g->render(); }
} else { $data_propre[$i] = 0; } } $data_propre_old = $data_propre; //lissage sur 3 jours $data_propre = array(); $data_propre = $data_propre_old; echo '<br>'; print_r($data_propre); echo '<br>'; include_once '../php-ofc-library/open-flash-chart.php'; $g = new graph(); //$g->set_data( $data_propre ); $data_1 = new line(2, '#9933CC'); $data_1->key('Nombre d\'occurrences brutes', 10); for ($i = $dated; $i < $datef + 1; $i += 1) { $data_1->add_data_tip($data_propre[$i], '(Billets: ' . $data_propre[$i] . ')'); } $g->data_sets[] = $data_1; $g->set_x_axis_steps(1); $g->set_x_label_style(10, '#9933CC', 0, 1, '#00A000'); if ($racine == 'veille') { $g->set_x_labels(array('', '', '', '21/09', '', '', '', '', '', '', '28/09', '', '', '', '', '', '', '5/10', '', '', '', '', '', '', '12/10', '', '', '', '', '', '', '19/10', '', '', '', '', '', '', '26/10', '', '', '', '', '', '', '2/11', '', '', '', '', '', '', '9/11', '', '', '', '', '', '', '16/11', '', '', '', '', '', '', '23/11', '', '', '', '', '', '', '30/11', '', '', '', '', '', '', '7/12', '', '', '', '', '', '', '14/12', '', '')); } elseif ($racine == 'biofuel') { $g->set_x_labels(array('1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010')); } elseif ($racine == 'biodiv') { $g->set_x_labels(array('1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009')); } else { $g->set_x_labels($xlab); }
echo '***************<br>'; echo $periodes['from']; echo '<br>***************<br>'; for ($i = $periodes['from']; $i <= $periodes['to']; $i += 1) { $xlab_an[] = $i; if (array_key_exists($i, $data)) { $data_propre[$i] = $data[$i] + $j / 45; } else { $data_propre[$i] = 0 + $j / 45; } } //print_r($data_propre); //$g->set_data( $data_propre ); echo '<br>' . 'couleur' . $colors[$j] . '<br>'; $data_1 = new line(2, $colors[$j]); $data_1->key($label, 10); for ($i = $periodes['from']; $i <= $periodes['to']; $i += 1) { echo $i . '<br>'; echo '<br>(' . $label . ': Billets: ' . $data_propre[$i] . ')' . '<br>'; $data_1->add_data_tip($data_propre[$i], '(' . $label . ': Billets: ' . intval($data_propre[$i]) . ')'); } $g->data_sets[] = $data_1; $max_data = max(5, max(intval(ceil(max($data_propre) * 1.1) / $steps_nb) * $steps_nb, $max_data)); echo $max_data; } print_r($g); echo '<br>on a envoye toutes les donnees<br>'; if ($racine == 'veille') { $xlab = array('', '', '', '21/09', '', '', '', '', '', '', '28/09', '', '', '', '', '', '', '5/10', '', '', '', '', '', '', '12/10', '', '', '', '', '', '', '19/10', '', '', '', '', '', '', '26/10', '', '', '', '', '', '', '2/11', '', '', '', '', '', '', '9/11', '', '', '', '', '', '', '16/11', '', '', '', '', '', '', '23/11', '', '', '', '', '', '', '30/11', '', '', '', '', '', '', '7/12', '', '', '', '', '', '', '14/12', '', ''); } elseif ($racine == 'biofuel') { $xlab = array('1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010');
// // $data_propre[$i] =($data_propre_old[$i]+$data_propre_old[$i-1]+$data_propre_old[$i+1])/3; //} $data_propre = $data_propre_old; echo '<br>'; echo 'apres norm'; echo '<br>'; print_r($data_propre); echo '<br>'; include_once '../php-ofc-library/open-flash-chart.php'; //$data_1=$data_propre; $g = new graph(); //$g->set_data( $data_propre ); echo '<br>'; print_r($data_propre); $data_1 = new line(2, '#9933CC'); $data_1->key('Nombre d\'occurrences normalisé (pour mille billets)', 10); for ($i = $dated; $i < $datef + 1; $i += 1) { $data_1->add_data_tip($data_propre[$i], '(Billets: ' . $data_propre[$i] . ')'); } $g->data_sets[] = $data_1; //$g->title( 'Evolution temporelle du terme'.$id_concept ); //$g->line_dot( 2, 4, '#9933CC', '', 18 ); $g->set_x_axis_steps(1); $g->set_x_label_style(10, '#9933CC', 0, 1, '#00A000'); if ($racine == 'veille') { $g->set_x_labels(array('', '', '', '21/09', '', '', '', '', '', '', '28/09', '', '', '', '', '', '', '5/10', '', '', '', '', '', '', '12/10', '', '', '', '', '', '', '19/10', '', '', '', '', '', '', '26/10', '', '', '', '', '', '', '2/11', '', '', '', '', '', '', '9/11', '', '', '', '', '', '', '16/11', '', '', '', '', '', '', '23/11', '', '', '', '', '', '', '30/11', '', '', '', '', '', '', '7/12', '', '', '', '', '', '', '14/12', '', '')); } elseif ($racine == 'biofuel') { $g->set_x_labels(array('1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010')); } elseif ($racine == 'biodiv') { $g->set_x_labels(array('1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009')); } else {