<?php require 'chart.php'; require 'data.php'; $chart = new chart(300, 200, "example3-1"); $chart->plot($data, false, "white"); $chart->set_grid_color("black"); $chart->set_background_color("blue", "ForestGreen"); $chart->set_title("Title, background and border"); $chart->stroke(); ?>
<?php require 'chart.php'; require 'data.php'; $chart = new chart(300, 200, "example26"); $chart->set_font("/usr/share/texmf/fonts/type1/adobe/utopia/putb8a.pfb", "type1"); $chart->set_title("Using The Adobe Utopia Font"); $chart->plot($data); $chart->stroke(); ?>
array_push($stacked_label_cols, $vo_ch_col->col_label); array_push($stacked_label_cols_color, $vo_ch_col->col_color); } if ($vo_ch_col->is_time == 1) { array_push($istime_cols, $col_idx); } $col_idx++; } //Create chart $wpbi_chart = new chart($my_test_rows); $wpbi_chart->set_name($vo_chart->chart_name); $wpbi_chart->set_tooltip($vo_chart->chart_tooltip); $wpbi_chart->set_width($vo_chart->chart_width . ($vo_chart->chart_width_percent ? '%' : '')); $wpbi_chart->set_height($vo_chart->chart_height . ($vo_chart->chart_height_percent ? '%' : '')); $wpbi_chart->set_bg_colour($vo_chart->chart_bg_color); $wpbi_chart->set_title($vo_chart->chart_title); $wpbi_chart->set_title_color($vo_chart->chart_title_color); $wpbi_chart->set_title_size($vo_chart->chart_title_size); $wpbi_chart->set_time_format($vo_chart->chart_time_format); $wpbi_chart->set_type($vo_chart->chart_type); $wpbi_chart->set_x_axis_step_percent($vo_chart->chart_x_grid_lines); $wpbi_chart->set_y_axis_step_percent($vo_chart->chart_y_grid_lines); $wpbi_chart->set_x_precision($_POST[$wpbi_settings['parameter']['ch-x-precision']]); $wpbi_chart->set_y_precision($_POST[$wpbi_settings['parameter']['ch-y-precision']]); $wpbi_chart->set_y_range($_POST[$wpbi_settings['parameter']['ch-y-range']]); $wpbi_chart->set_y_label($_POST[$wpbi_settings['parameter']['ch-y-label']]); $wpbi_chart->set_x_label($_POST[$wpbi_settings['parameter']['ch-x-label']]); $wpbi_chart->set_y_currency($_POST[$wpbi_settings['parameter']['ch-y-currency']]); //Get values, labels, colors $label_color = array(); $stacked_label_color = array();
if ($_GET[mm3]) { $chart->plot($mm3, false, "red"); $chart->add_legend("MM3", "red"); } if ($_GET[mm10]) { $chart->plot($mm10, false, "green"); $chart->add_legend("MM10", "green"); } //Dibujamos el cierre if ($_GET[cierre]) { $chart->plot($cierre, false, "black", "cross", false, 4); } //Dibujamos apertura if ($_GET[apertura]) { $chart->plot($apertura, false, "gray", "box", "black"); } // Dibujamos el valor de color azul $chart->plot($valor, false, "blue"); // Dibujamos el rango día bajo //$chart->plot($rango_dia_bajo, false, "black", "points"); // Elegimos que texto mostrar abajo if ($_GET[dias] == 1) { $chart->set_x_ticks($hora, $format = "text"); } else { $chart->set_x_ticks($fecha, $format = "text"); } $chart->set_title($_GET[ticker] . " - http://sukiweb.net"); $chart->stroke(); ?>
$data = $pdf->LoadData('EXPORT_REPORT.csv'); $pdf->ColorTable($header, $data); if ($_SESSION[create_graph] == "yes") { $_SESSION[no_header] = "yes"; $pdf->AddPage($_SESSION[pdf_layout]); $pdf->AliasNbPages(); $pdf->SetFont('Arial', '', 8); require "chart.php"; $data = explode(",", $pdf_graph_values); if ($_SESSION[pdf_layout] == "P") { $chart = new chart(535, 720); } elseif ($_SESSION[pdf_layout] == "L") { $chart = new chart(785, 485); } if ($_SESSION[pdf_graph_title] != "") { $chart->set_title("{$_SESSION['pdf_graph_title']}"); } if ($_SESSION[pdf_graph] == "line_graph") { $chart->plot($data, false, "black"); } elseif ($_SESSION[pdf_graph] == "bar_graph") { $chart->plot($data, false, "black", "impulse"); } elseif ($_SESSION[pdf_graph] == "box_graph") { $chart->plot($data, false, "gray", "box", "black"); } $chart->stroke(); $pdf->Ln(); if ($_SESSION[pdf_layout] == "P") { $pdf->Image("pdf_image.png", 10, 20); } elseif ($_SESSION[pdf_layout] == "L") { $pdf->Image("pdf_image.png", 10, 20); }
<?php require 'chart.php'; require 'data.php'; $chart = new chart(300, 200, "example27"); $chart->set_font("/usr/share/texmf/fonts/type1/adobe/utopia/putb8a.pfb", "type1", 16); $chart->set_title("A Big Utopia"); $chart->plot($data); $chart->stroke(); ?>
function get_html_4_chart($id) { global $wpdb, $qy_table_databases, $qy_table_queries, $wpbi_sql, $wpbi_settings, $wpbi_url, $wpbi_dialog, $lng, $language, $template_site; $template_site->set_filenames(array('chart' => $wpbi_url['tpl']['root-path'] . $wpbi_url['tpl']['nvd3chart'])); $chart_id = $id; //id or key $search_by_key = false; if (!is_numeric($chart_id)) { if (strlen($chart_id) == 32 && strpos($chart_id, ' ') === false) { $search_by_key = true; } else { return '<p>Could not create table. Wrong ID provided.</p>'; } } $test_output = ''; //Store the test output //Get chart metadata $selected_charts = $chart_id; $vo_chart = new vo_chart(NULL); $vo_chart->set_chart_id($selected_charts); $vo_chart->set_chart_key($selected_charts); $dao_chart = new dao_chart($wpdb, $wpbi_sql['tname']['charts']); $vo_chart = $search_by_key ? $dao_chart->select_by_key($vo_chart) : $dao_chart->select($vo_chart); $vo_chart = $vo_chart[0]; //Get cols metadata $vo_ch_cols = new vo_ch_cols(); $vo_ch_cols->set_ch_id($vo_chart->chart_id); $dao_ch_cols = new dao_ch_cols($wpdb, $wpbi_sql['tname']['chart-cols']); $vo_ch_cols = $dao_ch_cols->select($vo_ch_cols); //Get selected query $dao_query = new dao_query($wpdb, $wpbi_sql['tname']['queries']); $tgt_query = new vo_query($vo_chart->query_id, NULL, NULL, NULL, NULL); $vo_query = $dao_query->select($tgt_query); $vo_query = $vo_query[0]; //Select associated db $dao_database = new dao_database($wpdb, $wpbi_sql['tname']['databases']); $tgt_database = new vo_database($vo_query->db_id, NULL, NULL, NULL, NULL); $vo_database = $dao_database->select($tgt_database); $vo_database = $vo_database[0]; //Create wpdb object and execute the query $my_test_db = new wpdb($vo_database->user, $vo_database->pass, $vo_database->name, $vo_database->host); $query = new query($vo_query->statement, $wpdb, $wpbi_sql['tname']['vars']); $total_rows = $my_test_db->get_results($query->count_qy_results(), 'ARRAY_N'); if (count($total_rows) == 0) { return "<div style='padding:40px;'><h1 style='color: red;'>The query returned no data</h1>" . "<p>Please check the DB connectivity or your SQL query syntax</p></div>"; } $total_rows = intval($total_rows[0][0]); //get query resultset $my_test_rows = $my_test_db->get_results($query->stmt, 'ARRAY_N'); //get columns $x_label_cols = array(); $color_cols = array(); $tx_label_cols = array(); $values_cols = array(); $istime_cols = array(); $stacked_label_cols = array(); $stacked_label_cols_color = array(); $col_idx = 0; foreach ($vo_ch_cols as $vo_ch_col) { array_push($tx_label_cols, $vo_ch_col->col_label); array_push($color_cols, $vo_ch_col->col_color); if ($vo_ch_col->is_label) { array_push($x_label_cols, $col_idx); } if ($vo_ch_col->is_value) { array_push($values_cols, $col_idx); array_push($stacked_label_cols, $vo_ch_col->col_label); array_push($stacked_label_cols_color, $vo_ch_col->col_color); } if ($vo_ch_col->is_time) { array_push($istime_cols, $col_idx); } $col_idx++; } //Create chart $wpbi_chart = new chart($my_test_rows); $wpbi_chart->set_name($vo_chart->chart_name); $wpbi_chart->set_tooltip($vo_chart->chart_tooltip); $wpbi_chart->set_width($vo_chart->chart_width . ($vo_chart->chart_width_percent ? '%' : '')); $wpbi_chart->set_height($vo_chart->chart_height . ($vo_chart->chart_height_percent ? '%' : '')); $wpbi_chart->set_bg_colour($vo_chart->chart_bg_color); $wpbi_chart->set_title($vo_chart->chart_title); $wpbi_chart->set_title_color($vo_chart->chart_title_color); $wpbi_chart->set_title_size($vo_chart->chart_title_size); $wpbi_chart->set_type($vo_chart->chart_type); $wpbi_chart->set_x_axis_step_percent($vo_chart->chart_x_grid_lines); $wpbi_chart->set_y_axis_step_percent($vo_chart->chart_y_grid_lines); $wpbi_chart->set_time_format($vo_chart->chart_time_format); //Get values, labels, colors $label_color = array(); $stacked_label_color = array(); $row_idx = 0; $label_tmp_x = ""; foreach ($my_test_rows as $my_test_row) { for ($col_idx = 0; $col_idx < sizeof($my_test_row); $col_idx++) { //Colors $label_color[$tx_label_cols[$col_idx]] = $color_cols[$col_idx]; if (in_array($col_idx, $values_cols)) { $stacked_label_color[$tx_label_cols[$col_idx]] = $color_cols[$col_idx]; } if (in_array($col_idx, $values_cols)) { //create different array of values for each selected column $current_value = is_string($my_test_row[$col_idx]) ? $my_test_row[$col_idx] : floatval($my_test_row[$col_idx]); if (isset($data[$tx_label_cols[$col_idx]])) { array_push($data[$tx_label_cols[$col_idx]], $current_value); } else { $data[$tx_label_cols[$col_idx]] = array(); array_push($data[$tx_label_cols[$col_idx]], $current_value); } } if (in_array($col_idx, $values_cols)) { //create different array of values for each selected column (for stacked bar chart) $current_value = floatval($my_test_row[$col_idx]); if (isset($data_stacked[$row_idx])) { array_push($data_stacked[$row_idx], $current_value); } else { $data_stacked[$row_idx] = array(); array_push($data_stacked[$row_idx], $current_value); } } if (in_array($col_idx, $x_label_cols)) { //Concatenate selected columns $label_tmp_x = $label_tmp_x == '' ? $my_test_row[$col_idx] : $label_tmp_x . $wpbi_dialog['charts']['x-label']['concat-string'] . $my_test_row[$col_idx]; } } if ($label_tmp_x != NULL) { $label_x[] = $label_tmp_x; $label_tmp_x = ''; } $row_idx++; } //Assign values and labels switch ($wpbi_chart->type) { case chart::DONUT: case chart::PIE: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $vo_chart->chart_x_labels_size, $vo_chart->chart_x_labels_color); } foreach ($data as $key => $value) { //Overwrite data value for pie chart in order to show labels (via pie_value object) if (sizeof($label_x) > 0) { for ($idx = 0; $idx < sizeof($value); $idx++) { $value[$idx] = new pie_value($value[$idx], $label_x[$idx]); } } $wpbi_chart->set_tooltip($wpbi_dialog['charts']['pie']['tooltip']); $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colours($wpbi_settings['pie-chart']['color-set']); } break; case chart::BAR_STACKED: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $_POST[$wpbi_settings['parameter']['ch-x-label-size']], $_POST[$wpbi_settings['parameter']['ch-x-label-color']]); $wpbi_chart->x_axis_istime = sizeof($istime_cols) > 0; if ($wpbi_chart->x_axis_istime) { $wpbi_chart->x_axis_labels->labels = $wpbi_chart->convert_to_time($wpbi_chart->x_axis_labels->labels); } } $wpbi_chart->set_y_axis_labels_color($_POST[$wpbi_settings['parameter']['ch-y-label-color']]); $wpbi_chart->set_y_axis_labels_size($_POST[$wpbi_settings['parameter']['ch-y-label-size']]); foreach ($data_stacked as $key => $value) { $wpbi_chart->create_element('BAR_STACKED', $value); $wpbi_chart->elements['BAR_STACKED']->set_colours($stacked_label_color); } break; case chart::STACKED_AREA: case chart::LINE_AREA: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $vo_chart->chart_x_labels_size, $vo_chart->chart_x_labels_color); } $wpbi_chart->set_y_axis_labels_color($vo_chart->chart_y_labels_color); $wpbi_chart->set_y_axis_labels_size($vo_chart->chart_y_labels_size); foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); $wpbi_chart->elements[$key]->set_fill_colour($label_color[$key]); $wpbi_chart->elements[$key]->set_fill_alpha(0.5); } break; case chart::RADAR: if (sizeof($label_x) > 0) { $wpbi_chart->set_y_axis_labels($label_x, $vo_chart->chart_y_labels_size, $vo_chart->chart_y_labels_color); } foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); } break; case chart::BAR_HORIZONTAL: if (sizeof($label_x) > 0) { $wpbi_chart->set_y_axis_labels($label_x, $vo_chart->chart_y_labels_size, $vo_chart->chart_y_labels_color); } $wpbi_chart->set_x_axis_labels_color($vo_chart->chart_x_labels_color); $wpbi_chart->set_x_axis_labels_size($vo_chart->chart_x_labels_size); foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); } break; default: if (sizeof($label_x) > 0) { $wpbi_chart->set_x_axis_labels($label_x, $vo_chart->chart_x_labels_size, $vo_chart->chart_x_labels_color, sizeof($istime_cols) > 0); $wpbi_chart->x_axis_istime = sizeof($istime_cols) > 0; } else { $wpbi_chart->set_x_axis_labels_color($vo_chart->chart_x_labels_color); $wpbi_chart->set_x_axis_labels_size($vo_chart->chart_x_labels_size); } $wpbi_chart->set_y_axis_labels_color($vo_chart->chart_y_labels_color); $wpbi_chart->set_y_axis_labels_size($vo_chart->chart_y_labels_size); foreach ($data as $key => $value) { $wpbi_chart->create_element($key, $value); $wpbi_chart->elements[$key]->set_colour($label_color[$key]); } break; } //Set legends $wpbi_chart->set_y_legend($vo_chart->chart_y_legend, $vo_chart->chart_y_legend_size, $vo_chart->chart_y_legend_color); $wpbi_chart->set_x_legend($vo_chart->chart_x_legend, $vo_chart->chart_x_legend_size, $vo_chart->chart_x_legend_color); $wpbi_chart->set_x_label($vo_chart->chart_x_axis_label); $wpbi_chart->set_x_axis_labels_rotation($vo_chart->chart_x_labels_rotation); $wpbi_chart->set_y_axis_labels_rotation($vo_chart->chart_y_labels_rotation); $wpbi_chart->set_y_axis_color($vo_chart->chart_y_color); $wpbi_chart->set_y_axis_grid_color($vo_chart->chart_y_grid_color); $wpbi_chart->set_y_axis_thickness($vo_chart->chart_y_thickness); $wpbi_chart->set_x_axis_color($vo_chart->chart_x_color); $wpbi_chart->set_x_axis_grid_color($vo_chart->chart_x_grid_color); $wpbi_chart->set_x_axis_thickness($vo_chart->chart_x_thickness); $wpbi_chart->set_x_precision($vo_chart->chart_x_axis_precision); $wpbi_chart->set_y_precision($vo_chart->chart_y_axis_precision); $wpbi_chart->set_y_range($vo_chart->chart_y_axis_range); $wpbi_chart->set_y_label($vo_chart->chart_y_axis_label); $wpbi_chart->set_y_currency($vo_chart->chart_y_axis_currency); $wpbi_chart->set_snapshot($vo_chart->chart_snapshot == 1); $wpbi_chart->set_stacked($vo_chart->chart_stacked == 1); //Main legend for stacked chart if ($wpbi_chart->type == chart::BAR_STACKED) { $stacked_keys = array(); for ($i = 0; $i < sizeof($stacked_label_cols_color); $i++) { array_push($stacked_keys, new bar_stack_key($stacked_label_cols_color[$i], $stacked_label_cols[$i], 10)); } $wpbi_chart->elements['BAR_STACKED']->set_keys($stacked_keys); } $wpbi_chart->build(); //Import scripts echo ' <link rel="stylesheet" href="' . $wpbi_url['nvd3']['css'] . '" type="text/css" /> <script type="text/javascript" src="' . $wpbi_url['nvd3']['d3js'] . '"></script> <script type="text/javascript" src="' . $wpbi_url['nvd3']['nvd3'] . '"></script> '; //Set template variables $template_site->assign_vars(array('CH_NEW_CHART_NAME' => $selected_charts, 'CH_NEW_CHART_WIDTH' => $wpbi_chart->width, 'CH_NEW_CHART_HEIGHT' => $wpbi_chart->height, 'CH_NEW_CHART_RESIZE' => 'chart_resize', 'CH_NEW_CHART_JSON' => $wpbi_chart->get_json_code(), 'CH_NEW_CHART_NVD3_CODE' => $wpbi_chart->get_nvd3_chart_code(), 'CH_NEW_CHART_NVD3_HTML' => $wpbi_chart->get_nvd3_chart_html(), 'CH_NEW_CHART_NVD3_DATA' => $wpbi_chart->get_nvd3_chart_data(), 'CH_NEW_CHART_NVD3_PLACEHOLDER' => $wpbi_chart->get_nvd3_chart_placeholder())); ob_start(); $template_site->pparse('chart'); $chart_output = ob_get_contents(); ob_end_clean(); return $chart_output; }
<?php require 'chart.php'; require 'data.php'; $chart = new chart(300, 200, "example31"); $chart->set_font("/usr/share/texmf/fonts/type1/adobe/utopia/putb8a.pfb", "type1", 11); $chart->set_title("A Package For Generating Charts"); $chart->plot($data4, false, "red", "gradient", "white", 0); $chart->plot($data, false, "blue", "gradient", "white", 4); $chart->plot($data4, false, "gray"); $chart->plot($data4, false, "gray", "box", "black"); $chart->add_legend("Other Things", "red"); $chart->add_legend("More Stuff", "blue"); $chart->stroke(); ?>
//$chart = new chart($width, $height); $hora = date("i"); $nombrecache = "usuario-" . $_GET["usuario"] . "-" . $_GET["dias"] . "-" . $hora; $chart = new chart($width, $height, $nombrecache . ".png"); if ($_GET["beneficio"]) { // Dibujamos el beneficio de color amarillo $chart->plot($beneficio, false, "yellow", "gradient", "green", 0); } if ($_GET["invertido"]) { // Dibujamos el invertido de color azul $chart->plot($invertido, false, "red"); } if ($_GET["saldo"]) { // Dibujamos el saldo de color verde $chart->plot($saldo, false, "green"); } if ($_GET["total"]) { // Dibujamos el total de color azul $chart->plot($total, false, "blue"); } // Elegimos que texto mostrar abajo if ($_GET[dias] == 1) { $chart->set_x_ticks($hora, $format = "text"); } else { $chart->set_x_ticks($fecha, $format = "text"); } $chart->set_title($_GET["usuario"] . " - http://sukiweb.net"); $chart->stroke(); ?>