function mkCacheData($date_from, $date_to, $product_id) { $conditions = array(); $info = $this->dbstuff->GetRow("SELECT * FROM " . $this->table_prefix . "products WHERE id='" . $product_id . "'"); if (!empty($info)) { $_GET['pn'] = $info['name']; } $mdt = date("Ymd") . "_" . substr(md5($_GET['pn'] . $_GET['ds'] . $_GET['de']), 0, 6); $file_item = $mdt; $file_path = DATA_PATH . "tmp/" . $file_item . $this->cache_ext; if (!file_exists($file_path)) { // use the chart class to build the chart: include_once LIB_PATH . 'ofc/chart.php'; $g = new graph(); $result = $this->dbstuff->GetArray("SELECT DATE_FORMAT(FROM_UNIXTIME(created),'%m') as mn,avg(max_price) AS avmax,avg(min_price) AS avmin FROM " . $this->table_prefix . "quotes WHERE product_id=" . $product_id . " AND created BETWEEN {$date_from} AND {$date_to} group by mn ORDER BY created ASC"); if (!empty($result)) { foreach ($result as $val) { $data[] = floor(($val['avmax'] + $val['avmin']) / 2); } $title = L("stat_charts", "tpl") . $_GET['ds'] . L("arrive_to", "tpl") . $_GET['de']; } elseif ($info['name']) { $title = $info['name']; } else { $title = L("data_not_exists") . df(); } $g->title($title, '{font-size: 24px;color: #0000FF}'); $g->set_data($data); $g->line_hollow(2, 4, '0x80a033', $_GET['pn'], 10); // label each point with its value //$g->set_x_labels( explode(",", L("months", "tpl")) ); $x_result = $this->dbstuff->GetArray("select CONCAT(FROM_UNIXTIME(created, '%Y'),'/',FROM_UNIXTIME(created, '%m')) as m from " . $this->table_prefix . "quotes WHERE created BETWEEN {$date_from} AND {$date_to} group by DATE_FORMAT(FROM_UNIXTIME(created),'%m') ORDER BY created ASC"); foreach ($x_result as $val) { $x_tmp[] = $val['m']; } $g->set_x_labels($x_tmp); $label_y = $this->dbstuff->GetRow("select max(max_price) as price_max,min(min_price) as price_min from " . $this->table_prefix . "quotes WHERE product_id=" . $product_id . " AND created BETWEEN {$date_from} AND {$date_to}"); $y_max = !empty($label_y['price_max']) ? $label_y['price_max'] : 100; // set the Y max $this->max_price = $label_y['price_max']; $this->min_price = $label_y['price_min']; $g->set_y_max($label_y['price_max']); // label every 20 (0,20,40,60) $g->y_label_steps(6); // display the data file_put_contents($file_path, $g->render()); } $this->cache_datafile = $file_item . $this->cache_ext; }
$data_2[] = $row['vr_custo']; $data_3[] = $row['vr_totalvenda']-$row['vr_custo']; $labels[] = date('d/m/Y',strtotime($row['data_venda'])); $max_value = ($max_value<$row['vr_totalvenda'])?$row['vr_totalvenda']:$max_value; } $g = new graph(); $g->set_data( $data_1 ); $g->set_data( $data_2 ); $g->set_data( $data_3 ); $g->line_hollow( 3, 5, '0x9933CC', 'Venda', 10 ); $g->line_hollow( 3, 5, '0xCC3399', 'Custo', 10); // <-- 3px thick + dots $g->line_hollow( 3, 5, '0x80a033', 'Lucro', 10 ); $g->set_x_labels( $labels ); $g->set_x_label_style( 10, '0x000000', 0, 2 ); $g->set_y_max( $max_value ); $g->y_label_steps( 4 ); $g->set_y_legend( 'Valores em Real - R$', 12, '#000000' ); $g->bg_colour = '#FFFFFF'; echo $g->render(); ?>
$resubmit = $PHP_SELF . "?" . $_SERVER['QUERY_STRING']; $g = new graph(); $g->title( $title, '{font-size: 18px; color: #A0A0A0;}' ); $g->set_inner_background( '#E3F0FD', '#CBD7E6', 90 ); $g->bg_colour = '#FFFFFF'; if ($sort == true){ array_multisort($labels,$data); } if ($type == 'line'){ $g->set_data($data); $g->line_hollow( 2, 4, '#5E83BF', 'Documentos', 10 ); $g->set_x_labels($labels); $g->set_x_label_style( 10, '0x000000', 0, 2 ); $g->set_y_max( max($data) ); $g->y_label_steps(4); }else if ($type == 'pie'){ $g->pie(60,'#505050','{font-size: 11px; color: #404040}'); $g->pie_values( $data, $labels ); $g->pie_slice_colours( array('#d01f3c','#356aa0','#C79810','#FFCC99','#009933','#FF99FF','#33FFFF','#CCCC99','#330033','#00CCFF','#CCCCCC','#FFCC00','#FF0033','#660000','#FFCCCC','#33FF33','#FF6633' ) ); }else{
$data_2[] = $row['vr_custo']; $data_3[] = $row['vr_totalvenda']-$row['vr_custo']; $labels[] = date('d/m/Y',strtotime($row['data_venda'])); $max_value = ($max_value<$row['vr_totalvenda'])?$row['vr_totalvenda']:$max_value; } $g = new graph(); $g->set_data( $data_1 ); $g->set_data( $data_2 ); $g->set_data( $data_3 ); $g->line_hollow( 3, 5, '0x9933CC', 'Venda', 10 ); $g->line_hollow( 3, 5, '0xCC3399', 'Custo', 10); $g->line_hollow( 3, 5, '0x80a033', 'Lucro', 10 ); $g->set_x_labels( $labels ); $g->set_x_label_style( 10, '0x000000', 0, 2 ); $g->set_y_max( $max_value ); $g->y_label_steps( 4 ); $g->set_y_legend( 'Valores em Real - R$', 12, '#000000' ); $g->bg_colour = '#FFFFFF'; echo $g->render(); ?>
//$data_avg[] = $report->info[$i]['avg']; $data_sum[] = number_format($report->info[$i]['sum'], 0, '', ''); } $data_date = array(); for ($i = 0; $i < $report->size; $i++) { $data_date[] = $report->info[$i]['text']; } // use the chart class to build the chart: include_once DIR_WS_CLASSES . 'ofc-library/open-flash-chart.php'; $g = new graph(); $g->bg_colour = '0xFFFFFF'; $g->x_grid_colour = '0xd8d8d8'; $g->y_grid_colour = '0xd8d8d8'; $g->title(HEADING_TITLE . ': ' . $report_desc, '{font-size: 18px;}'); $g->set_data($data_count); $g->line_hollow(3, 4, '0x0077cc', TEXT_NUMBER_OF_ORDERS, 12); $g->set_data($data_sum); $g->line_dot(3, 4, '0xff9900', TEXT_TOTAL_SUMM, 12); // // Attach the second data line (Free Ram) to the right axis: // $g->attach_to_y_right_axis(2); // // label each point with its value $g->set_x_labels($data_date); $g->set_x_label_style(10, '0x000000', 0, 2); // set the Y max $g->set_y_max(max($data_count) / 10 + max($data_count)); $g->set_y_right_max(max($data_sum) / 10 + max($data_sum)); // label every 20 (0,20,40,60) $g->y_label_steps(4);