function customizeGraph() { parent::customizeGraph(); $this->prepareData(); $this->set_y_max($this->maxData); $line_1 = new line_hollow(1, 3, '0x3357A0'); $line_1->key('visits', 10); $i = 0; foreach ($this->arrayData as $value) { // hack until we have proper date handling $spacePosition = strpos($this->arrayLabel[$i], ' '); if ($spacePosition === false) { $spacePosition = strlen($this->arrayLabel[$i]); } // generate the link on the dot, to the given day' statistics $link = Piwik_Url::getCurrentScriptName() . Piwik_Url::getCurrentQueryStringWithParametersModified(array('date' => substr($this->arrayLabel[$i], 0, $spacePosition), 'module' => 'Home', 'action' => 'index', 'viewDataTable' => null)); $line_1->add_link($value, $link); $i++; } $this->data_sets[] = $line_1; $this->set_x_labels($this->arrayLabel); $this->area_hollow(1, 3, 4, '0x3357A0', ' visits', 10); }
function grafico($mes = NULL, $anio = NULL) { if (empty($mes) and empty($anio)) { return; } $this->load->library('Graph'); $titulo = $data_1 = $data_2 = $data_3 = $data_tips_1 = $data_tips_2 = $data_tips_3 = array(); $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $data = $this->_sincrodata($fechai, $fechaf); $om = 1; while ($this->maxval / $om > 100) { $om = $om * 10; } foreach ($data as $row) { $titulo[] = $row['dia']; $data_1[] = $row['contado'] / $om; $data_2[] = $row['credito'] / $om; $data_3[] = $row['cobrado'] / $om; $data_tips_1[] = graph::esc(number_format($row['contado'], 2, ',', '.')); $data_tips_2[] = graph::esc(number_format($row['credito'], 2, ',', '.')); $data_tips_3[] = graph::esc(number_format($row['cobrado'], 2, ',', '.')); } $odata_1 = new bar_fade(50, '0xCC3399'); $odata_1->key('Contado', 10); $odata_1->data = $data_1; $odata_1->tips = $data_tips_1; $odata_2 = new bar_fade(50, '0x80a033'); $odata_2->key('Crédito', 10); $odata_2->data = $data_2; $odata_2->tips = $data_tips_2; $odata_3 = new line_hollow(2, 3, '0x9933CC'); $odata_3->key('Cobranzas a Crédito', 10); $odata_3->data = $data_3; $odata_3->tips = $data_tips_3; $g = new Graph(); if ($this->maxval > 0) { $g->title('Ventas del mes ' . $mes . '/' . $anio, '{font-size:18px; color: #d01f3c}'); $g->set_is_decimal_separator_comma(1); $g->data_sets[] = $odata_3; $g->data_sets[] = $odata_1; $g->data_sets[] = $odata_2; $g->set_y_max(ceil($this->maxval / $om)); $g->y_label_steps(5); $g->set_x_labels($titulo); $ejey = number_format($om, 0, '', '.'); $g->set_y_legend('Venta X ' . $ejey . ' (Bs)', 14, '0x639F45'); $g->set_x_legend('Días del mes ' . $mes, 14, '0x639F45'); $g->set_tool_tip('#key#<br>Día: #x_label# <br>Monto: #tip#'); } else { $g->title('No existen ventas en la Fecha Seleccionada', '{font-size:18px; color: #d01f3c}'); } $g->bg_colour = '#FFFFFF'; //$g->set_bg_image(site_url('/images/ventafon.png'), 'center', 'middle' ); echo utf8_encode($g->render()); }
function grafico($anio = '') { if (empty($anio)) { return; } $this->load->library('Graph'); $titulo = $data_1 = $data_2 = $data_3 = $data_tips_1 = $data_tips_2 = $data_tips_3 = array(); $fechai = $anio . '0101'; $fechaf = $anio . '1231'; $data = $this->_sincrodata($fechai, $fechaf); $om = 1; while ($this->maxval / $om > 100) { $om = $om * 10; } //print_r($data); foreach ($data as $row) { $titulo[] = $row['mes']; $data_1[] = $row['contado'] / $om; $data_2[] = $row['credito'] / $om; $data_3[] = $row['cobrado'] / $om; $data_tips_1[] = graph::esc(number_format($row['contado'], 2, ',', '.')); $data_tips_2[] = graph::esc(number_format($row['credito'], 2, ',', '.')); $data_tips_3[] = graph::esc(number_format($row['cobrado'], 2, ',', '.')); } $odata_1 = new bar_fade(50, '0xCC3399'); $odata_1->key('Contado', 10); $odata_1->data = $data_1; $odata_1->tips = $data_tips_1; $odata_2 = new bar_fade(50, '0x80a033'); $odata_2->key('Crédito', 10); $odata_2->data = $data_2; $odata_2->tips = $data_tips_2; $odata_4 = new line_hollow(2, 3, '0x9933CC'); $odata_4->key('Cobranzas a Crédito', 10); $odata_4->data = $data_3; $odata_4->tips = $data_tips_3; for ($i = 0; $i < count($data_1); $i++) { $mes = $i + 1; $odata_1->links[] = site_url("/hospitalidad/mensuales/index/{$mes}/{$anio}"); $odata_2->links[] = site_url("/hospitalidad/mensuales/index/{$mes}/{$anio}"); $odata_3->links[] = site_url("/hospitalidad/mensuales/index/{$mes}/{$anio}"); } $g = new Graph(); $g->set_is_decimal_separator_comma(1); if ($this->maxval > 0) { $g->title('Ventas en el año ' . $anio, '{font-size:18px; color: #d01f3c}'); $g->data_sets[] = $odata_1; $g->data_sets[] = $odata_2; $g->data_sets[] = $odata_4; $g->set_y_max(ceil($this->maxval / $om)); $g->y_label_steps(5); $g->set_x_labels($titulo); $ejey = number_format($om, 0, '', ' '); $g->set_y_legend('Venta X ' . $ejey . ' (Bs)', 14, '0x639F45'); $g->set_x_legend('Meses', 14, '0x639F45'); $g->set_tool_tip('#key#<br>Mes: #x_label# <br>Monto: #tip#'); } else { $g->title('NO existen ventas en el año seleccionado', '{font-size:18px; color: #d01f3c}'); } $g->bg_colour = '#FFFFFF'; echo utf8_encode($g->render()); }