Example #1
0
 /**
  * Generates data for OFC2 line chart in json format
  *
  * @return void
  */
 public function get_laba_rugi()
 {
     $this->load->plugin('ofc2');
     $this->load->model('jurnal_model');
     $model_data = $this->jurnal_model->get_laba_rugi_data();
     $bulan_data = array("Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des");
     for ($i = date('n') + 1; $i <= 12; $i++) {
         $pendapatan_kredit = isset($model_data[$i][date('Y') - 1][4][0]) ? $model_data[$i][date('Y') - 1][4][0] : 0;
         $pendapatan_debit = isset($model_data[$i][date('Y') - 1][4][1]) ? $model_data[$i][date('Y') - 1][4][1] : 0;
         $beban_kredit = isset($model_data[$i][date('Y') - 1][5][0]) ? $model_data[$i][date('Y') - 1][5][0] : 0;
         $beban_debit = isset($model_data[$i][date('Y') - 1][5][1]) ? $model_data[$i][date('Y') - 1][5][1] : 0;
         $data[] = $pendapatan_kredit - $pendapatan_debit - ($beban_debit - $beban_kredit);
         $thn = date('y') - 1;
         $thn = strlen($thn) == 1 ? '0' . $thn : $thn;
         $x_data[] = $bulan_data[$i - 1] . "'" . $thn;
     }
     for ($i = 1; $i <= date('n'); $i++) {
         $pendapatan_kredit = isset($model_data[$i][date('Y')][4][0]) ? $model_data[$i][date('Y')][4][0] : 0;
         $pendapatan_debit = isset($model_data[$i][date('Y')][4][1]) ? $model_data[$i][date('Y')][4][1] : 0;
         $beban_kredit = isset($model_data[$i][date('Y')][5][0]) ? $model_data[$i][date('Y')][5][0] : 0;
         $beban_debit = isset($model_data[$i][date('Y')][5][1]) ? $model_data[$i][date('Y')][5][1] : 0;
         $data[] = $pendapatan_kredit - $pendapatan_debit - ($beban_debit - $beban_kredit);
         $x_data[] = $bulan_data[$i - 1] . "'" . date('y');
     }
     $max = (int) max($data);
     $maxlen = strlen($max);
     $up = round($max, -($maxlen - 1));
     $min = (int) min($data);
     $minlen = strlen($min);
     $down = round($min, -($minlen - 1));
     $abs_max = (int) max(abs($max), abs($min));
     $len = strlen($abs_max);
     $round = round($abs_max, -($len - 1));
     $step = '1' . substr($round, 1);
     $up = $max > $up ? $up + $step : $up;
     $down = $min < $down ? $down - $step : $down;
     $d = new hollow_dot();
     $d->size(4)->halo_size(1)->colour('#668053');
     $line = new line();
     $line->set_values($data);
     $line->set_default_dot_style($d);
     $line->set_width(5);
     $line->set_colour('#7491a0');
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($x_data);
     $x = new x_axis();
     $x->set_labels($x_labels);
     $x->set_grid_colour('#bfb8b3');
     $y = new y_axis();
     $y->set_grid_colour('#bfb8b3');
     $y->set_range($down, $up, $step);
     $chart = new open_flash_chart();
     $chart->add_element($line);
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     $chart->set_bg_colour('#FFFFFF');
     echo $chart->toPrettyString();
 }
Example #2
0
 function customizeChartProperties()
 {
     parent::customizeChartProperties();
     $dataSetsToDisplay = $this->getDataSetsToDisplay();
     if ($dataSetsToDisplay === false) {
         return;
     }
     $colors = array("0x3357A0", "0xCC3399", "0x9933CC", "0x80a033", "0xFD9816", "0x246AD2", "0xFD16EA", "0x49C100");
     $i = 0;
     foreach ($dataSetsToDisplay as $dataSetToDisplay) {
         $color = $colors[$i % count($colors)];
         $labelName = $this->yLabels[$dataSetToDisplay];
         $d = new hollow_dot();
         $d->size(3)->halo_size(0)->colour($color);
         $line = new line();
         $line->set_default_dot_style($d);
         $line->set_key($labelName, 11);
         $line->set_width(1);
         $line->set_colour($color);
         // Line Values
         // Note: we have to manually create the dot values as the steps feature doens't work on X axis
         // when it's working again, we can remove code below and set generic tooltip above: // ->tooltip('#x_label#<br>#val# '.$labelName)
         $yValues = $this->yValues[$dataSetToDisplay];
         $labelName = $this->yLabels[$dataSetToDisplay];
         $lineValues = array();
         $j = 0;
         $unit = $this->yUnit;
         foreach ($this->xLabels as $label) {
             $value = (double) $yValues[$j];
             $lineValue = new hollow_dot($value);
             $whole = (int) $value;
             if ($value - $whole >= 0.005) {
                 $value = sprintf('%.2f', $value);
             }
             $lineValue->tooltip("{$label}<br><b>{$value}{$unit}</b> {$labelName}");
             if (!empty($this->xOnClick)) {
                 $lineValue->on_click("piwikHelper.redirectToUrl('" . $this->xOnClick[$j] . "')");
             }
             $lineValues[] = $lineValue;
             $j++;
         }
         $line->set_values($lineValues);
         $lines[] = $line;
         $i++;
     }
     foreach ($lines as $line) {
         $this->chart->add_element($line);
     }
     // if one column is a percentage we set the grid accordingly
     // note: it is invalid to plot a percentage dataset along with a numeric dataset
     if ($this->yUnit == '%' && $this->maxValue > 90) {
         $this->y->set_range(0, 100, 50);
     }
 }
Example #3
0
 /**
  * assign the chartdata object for open flash chart library
  * @param $config
  * @return unknown_type
  */
 function _setChartdata($config)
 {
     $model = $this->getModel();
     $rounds = $this->get('Rounds');
     $round_labels = array();
     foreach ($rounds as $r) {
         $round_labels[] = $r->name;
     }
     $division = $this->get('division');
     $data = $model->getDataByDivision($division->id);
     //create a line
     $length = count($rounds) - 0.5;
     $linewidth = $config['color_legend_line_width'];
     $lines = array();
     //$title = $division->name;
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     //colors defined for ranking table lines
     //todo: add support for more than 2 lines
     foreach ($this->colors as $color) {
         foreach ($rounds as $r) {
             for ($n = $color['from']; $n <= $color['to']; $n++) {
                 $lines[$color['color']][$n][] = $n;
             }
         }
     }
     //set lines on the graph
     foreach ($lines as $key => $value) {
         foreach ($value as $line => $key2) {
             $chart->add_element(hline($key, $length, $line, $linewidth));
         }
     }
     //load team1, first team in the dropdown
     $team = $this->team1;
     $d = new $config['dotstyle_1']();
     $d->size((int) $config['line1_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line1']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($team->rankings);
     $line->set_width((int) $config['line1_strength']);
     $line->set_key($team->name, 12);
     $line->set_colour($config['line1']);
     $line->on_show(new line_on_show($config['l_animation_1'], $config['l_cascade_1'], $config['l_delay_1']));
     $chart->add_element($line);
     //load team2, second team in the dropdown
     $team = $this->team2;
     $d = new $config['dotstyle_2']();
     $d->size((int) $config['line2_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line2']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($team->rankings);
     $line->set_width((int) $config['line2_strength']);
     $line->set_key($team->name, 12);
     $line->set_colour($config['line2']);
     $line->on_show(new line_on_show($config['l_animation_2'], $config['l_cascade_2'], $config['l_delay_2']));
     $chart->add_element($line);
     $x = new x_axis();
     if ($config['x_axis_label'] == 1) {
         $xlabels = new x_axis_labels();
         $xlabels->set_labels($round_labels);
         $xlabels->set_vertical();
     }
     $x->set_labels($xlabels);
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_CURVE_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(count($data), 1, -1);
     $y->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_CURVE_RANK'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     ob_clean();
     echo $chart->toString();
 }
Example #4
0
}
$title = new title("How far from the budget I was each month");
sort($labellist);
$x_labels = new x_axis_labels();
$x_labels->rotate(45);
$x_labels->set_labels($labellist);
$x = new x_axis();
$x->set_labels($x_labels);
$y = new y_axis();
$y->set_range(round($min) * 1.1, round($max) * 1.1);
$y->set_label_text("\$#val#");
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
$chart->set_bg_colour('#FFFFFF');
foreach ($categorylist as $category) {
    $color = "#" . substr(md5($category), 0, 6);
    $default_dot = new dot();
    $default_dot->size(3)->colour($color)->tooltip('#key#:<br>$#val#');
    $l = new line();
    $l->set_default_dot_style($default_dot);
    $l->set_values($datalist[$category]);
    $l->set_key($category, 12);
    $l->set_colour($color);
    $chart->add_element($l);
}
echo $chart->toPrettyString();
?>

//CREATE DATA 4 (MANUAL REFILL HISTORY)
$data_4_color = '#800080';
$data_4 = array();
foreach ($daily_refill_mans as $date => $qty) {
    $kw = $k + 1;
    $lv = new dot($qty);
    $lv->colour($data_4_color)->size(1);
    $lv->tooltip('Manual Refill Qty (#x_label#) = #val# .');
    $data_4[] = $lv;
    if ($qty > $data_max) {
        $data_max = $qty;
    }
}
$line_4 = new line();
$line_4->set_values($data_4);
$line_4->set_colour($data_4_color);
$line_4->set_width(1);
//CREATE DATA 5 (SOLD HISTORY QTY)
$data_5_color = '#ff69b4';
$data_5 = array();
foreach ($daily_sold as $date => $qty) {
    $kw = $k + 1;
    $lv = new dot($qty);
    $lv->colour($data_5_color)->size(1);
    $lv->tooltip('Order Qty (#x_label#) = #val# .');
    $data_5[] = $lv;
    if ($qty > $data_max) {
        $data_max = $qty;
    }
}
$line_5 = new line();
Example #6
0
                    }
                }
            }
        } else {
            $x_labels[] = '';
        }
    }
    $date_count++;
}
// line properties
$d = new hollow_dot();
$d->size(5)->halo_size(0)->colour('#3D5C56');
$line->set_default_dot_style($d);
$line->set_values($returns);
$line->set_width(2);
$line->set_colour('#668053');
$chart->add_element($line);
// title properties
$portfolio_type = array("", "Unknown", "401(k)", "Traditional IRA", "Roth IRA", "SIMPLE IRA", "SEP-IRA", "Solo 401(k)", "Roth 401(k)", "403(b)", "Other");
$type_idx = $_GET['i'];
$type_idx = $type_idx == 0 ? $type_idx : $type_idx - 1;
$title = new title("Individual Portfolio Performance (" . $portfolio_type[$type_idx] . ")");
$title->set_style("{font-size: 25px; font-family: Calibri; font-weight: bold; color: #121212; text-align: center;}");
$chart->set_title($title);
// y axis properties
$y = new y_axis();
$y_min = 0.0;
$y_max = 0.0;
$y_min = floor(0.995 * $amt_min);
$y_max = ceil(1.005 * $amt_max);
$y->set_grid_colour('#EFEFEF');
Example #7
0
 function _setChartdata($config)
 {
     require_once JLG_PATH_SITE . '/assets/classes/open-flash-chart/open-flash-chart.php';
     $data = $this->get('ChartData');
     // Calculate Values for Chart Object
     $forSum = array();
     $againstSum = array();
     $matchDayGoalsCount = array();
     $round_labels = array();
     foreach ($data as $rw) {
         if (!$rw->homegoalspd) {
             $rw->homegoalspd = 0;
         }
         if (!$rw->guestgoalspd) {
             $rw->guestgoalspd = 0;
         }
         $homeSum[] = (int) $rw->homegoalspd;
         $awaySum[] = (int) $rw->guestgoalspd;
         // check, if both results are missing and avoid drawing the flatline of "0" goals for not played games yet
         if (!$rw->homegoalspd && !$rw->guestgoalspd) {
             $matchDayGoalsCount[] = null;
         } else {
             $matchDayGoalsCount[] = (int) $rw->homegoalspd + $rw->guestgoalspd;
         }
         $round_labels[] = $rw->roundcode;
     }
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     if (!empty($homeSum) && !empty($awaySum)) {
         if ($config['home_away_stats']) {
             $bar1 = new $config['bartype_1']();
             $bar1->set_values($homeSum);
             $bar1->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_HOME') . ": #val#");
             $bar1->set_colour($config['bar1']);
             $bar1->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
             $bar1->set_key(JText::_('COM_JOOMLEAGUE_STATS_HOME'), 12);
             $bar2 = new $config['bartype_2']();
             $bar2->set_values($awaySum);
             $bar2->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_AWAY') . ": #val#");
             $bar2->set_colour($config['bar2']);
             $bar2->set_on_show(new bar_on_show($config['animation_2'], $config['cascade_2'], $config['delay_2']));
             $bar2->set_key(JText::_('COM_JOOMLEAGUE_STATS_AWAY'), 12);
             $chart->add_element($bar1);
             $chart->add_element($bar2);
         }
     }
     // total
     $d = new $config['dotstyle_3']();
     $d->size((int) $config['line3_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line3']);
     $d->tooltip(JText::_('COM_JOOMLEAGUE_STATS_TOTAL2') . ' #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($matchDayGoalsCount);
     $line->set_width((int) $config['line3_strength']);
     $line->set_key(JText::_('COM_JOOMLEAGUE_STATS_TOTAL'), 12);
     $line->set_colour($config['line3']);
     $line->on_show(new line_on_show($config['l_animation_3'], $config['l_cascade_3'], $config['l_delay_3']));
     $chart->add_element($line);
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_STATS_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(0, @max($matchDayGoalsCount) + 2, 1);
     $y->set_steps(round(@max($matchDayGoalsCount) / 8));
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_STATS_GOALS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->chartdata = $chart;
 }
Example #8
0
 $line_watt_default_dot->size(4)->colour('#f00000');
 $line_watt = new area();
 $line_watt->set_default_dot_style($line_watt_default_dot);
 $line_watt->set_values($data_watt);
 $line_watt->set_colour('#4D4D4D');
 $line_watt->set_fill_colour('#EFC01D');
 $line_watt->set_fill_alpha(0.75);
 $line_watt->set_width(2);
 $line_watt->set_key('Leistung (W)', 10);
 $line_watt->set_tooltip("#val# W");
 $line_tot_default_dot = new dot();
 $line_tot_default_dot->size(4)->halo_size(2);
 $line_tot = new line();
 $line_tot->set_default_dot_style($line_tot_default_dot);
 $line_tot->set_values($data_tot);
 $line_tot->set_colour('#A0A000');
 $line_tot->set_width(2);
 $line_tot->set_key('Gesamt (kWh)', 10);
 $line_tot->set_tooltip("#val# kWh");
 $max = max(max($data_watt), $max_val) * 1.15;
 $y = new y_axis();
 $y->set_range(0, $max, round($max * 0.1, -1));
 $x_labels = new x_axis_labels();
 $x_labels->set_vertical();
 $x_labels->set_steps(6);
 $x_labels->set_colour('#333333');
 $x_labels->set_labels($time_axis);
 $x = new x_axis();
 $x->set_colour('#333333');
 $x->set_grid_colour('#ffffff');
 $x->set_offset(false);
 function get_daily_entries($form, $colors = false, $type = "DATE")
 {
     global $wpdb, $frmdb;
     if (!$colors) {
         $colors = array('#EF8C08', '#21759B', '#1C9E05');
     }
     $type = strtoupper($type);
     //Chart for Entries Submitted
     $values = array();
     $labels = array();
     if ($type == 'HOUR') {
         $start_timestamp = strtotime('-48 hours');
     } else {
         if ($type == 'MONTH') {
             $start_timestamp = strtotime('-1 year');
         } else {
             if ($type == 'YEAR') {
                 $start_timestamp = strtotime('-10 years');
             } else {
                 $start_timestamp = strtotime('-1 month');
             }
         }
     }
     $end_timestamp = time();
     if ($type == 'HOUR') {
         $query = "SELECT en.created_at as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j H", $start_timestamp) . ":00:00' AND en.form_id={$form->id} GROUP BY endate";
     } else {
         $query = "SELECT DATE(en.created_at) as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j", $start_timestamp) . " 00:00:00' AND en.form_id={$form->id} GROUP BY {$type}(en.created_at)";
     }
     $entries_array = $wpdb->get_results($query);
     $temp_array = $counts_array = $dates_array = array();
     // Refactor Array for use later on
     foreach ($entries_array as $e) {
         $e_key = $e->endate;
         if ($type == 'HOUR') {
             $e_key = date('Y-m-d H', strtotime($e->endate)) . ':00:00';
         } else {
             if ($type == 'MONTH') {
                 $e_key = date('Y-m', strtotime($e->endate)) . '-01';
             } else {
                 if ($type == 'YEAR') {
                     $e_key = date('Y', strtotime($e->endate)) . '-01-01';
                 }
             }
         }
         $temp_array[$e_key] = $e->encount;
     }
     // Get the dates array
     if ($type == 'HOUR') {
         for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60) {
             if (!in_array(date('Y-m-d H', $e) . ':00:00', $dates_array)) {
                 $dates_array[] = date('Y-m-d H', $e) . ':00:00';
             }
         }
         $date_format = get_option('time_format');
     } else {
         if ($type == 'MONTH') {
             for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 25) {
                 if (!in_array(date('Y-m', $e) . '-01', $dates_array)) {
                     $dates_array[] = date('Y-m', $e) . '-01';
                 }
             }
             $date_format = 'F Y';
         } else {
             if ($type == 'YEAR') {
                 for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 364) {
                     if (!in_array(date('Y', $e) . '-01-01', $dates_array)) {
                         $dates_array[] = date('Y', $e) . '-01-01';
                     }
                 }
                 $date_format = 'Y';
             } else {
                 for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24) {
                     $dates_array[] = date("Y-m-d", $e);
                 }
                 $date_format = get_option('date_format');
             }
         }
     }
     // Make sure counts array is in order and includes zero click days
     foreach ($dates_array as $date_str) {
         if (isset($temp_array[$date_str])) {
             $counts_array[$date_str] = $temp_array[$date_str];
         } else {
             $counts_array[$date_str] = 0;
         }
     }
     foreach ($counts_array as $date => $count) {
         $labels[] = date_i18n($date_format, strtotime($date));
         $values[] = (int) $count;
     }
     if ($type == 'MONTH') {
         $title = __('Monthly Entries', 'formidable');
     } else {
         if ($type == 'YEAR') {
             $title = __('Yearly Entries', 'formidable');
         } else {
             if ($type == 'HOUR') {
                 $title = __('Hourly Entries', 'formidable');
             } else {
                 $title = __('Daily Entries', 'formidable');
             }
         }
     }
     $title = new title($title);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour($colors[0]);
     $line_1_default_dot->tooltip('#x_label#<br>#val# Entries');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($values);
     $line_1->set_colour($colors[1]);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->set_bg_colour('#FFFFFF');
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->rotate(340);
     $x_labels->set_labels($labels);
     if (count($labels) > 15) {
         $x_labels->visible_steps(2);
     }
     $x->set_labels($x_labels);
     $chart->set_x_axis($x);
     $y = new y_axis();
     if (!empty($values)) {
         $max = max($values) + 1;
         $step = ceil($max / 10);
         $y->set_range(0, $max, $step);
     }
     $chart->add_element($line_1);
     $chart->set_y_axis($y);
     return $chart->toPrettyString();
 }
Example #10
0
     }
 }
 sort($labellist);
 $title = new title($bank . " Retrospective");
 $cdot = new dot();
 $cdot->size(3)->colour("#0000FF")->tooltip('$#val#');
 $cline = new line();
 $cline->set_values($cdatalist);
 $cline->set_colour("#0000FF");
 $cline->set_default_dot_style($cdot);
 $cline->set_key("Checking", 12);
 $sdot = new dot();
 $sdot->size(3)->colour("#FF0000")->tooltip('$#val#');
 $sline = new line();
 $sline->set_values($sdatalist);
 $sline->set_colour("#FF0000");
 $sline->set_default_dot_style($sdot);
 $sline->set_key("Savings", 12);
 $x_labels = new x_axis_labels();
 $x_labels->rotate(45);
 $x_labels->set_labels($labellist);
 $x_labels->set_steps(3);
 $x = new x_axis();
 $x->set_labels($x_labels);
 $y = new y_axis();
 $y->set_range(round($min) * 1.1, round($max) * 1.1);
 $y->set_label_text("\$#val#");
 $chart = new open_flash_chart();
 $chart->set_title($title);
 $chart->add_element($cline);
 $chart->add_element($sline);
 function _setRankingChartdata($config)
 {
     require_once JLG_PATH_SITE . DS . "assets" . DS . "classes" . DS . "open-flash-chart" . DS . "open-flash-chart.php";
     //$data = $this->get('RankChartData');
     //some example data....fixme!!!
     $data_1 = array();
     $data_2 = array();
     for ($i = 0; $i < 6.2; $i += 0.2) {
         $data_1[] = sin($i) * 1.9 + 10;
     }
     for ($i = 0; $i < 6.2; $i += 0.2) {
         $data_2[] = sin($i) * 1.3 + 10;
     }
     $chart = new open_flash_chart();
     //***********
     //line 1
     $d = new $config['dotstyle_1']();
     $d->size((int) $config['line1_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line1']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($data_1);
     $line->set_width((int) $config['line1_strength']);
     ///$line->set_key($team->name, 12);
     $line->set_colour($config['line1']);
     $line->on_show(new line_on_show($config['l_animation_1'], $config['l_cascade_1'], $config['l_delay_1']));
     $chart->add_element($line);
     //Line 2
     $d = new $config['dotstyle_2']();
     $d->size((int) $config['line2_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line2']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($data_2);
     $line->set_width((int) $config['line2_strength']);
     //$line->set_key($team->name, 12);
     $line->set_colour($config['line2']);
     $line->on_show(new line_on_show($config['l_animation_2'], $config['l_cascade_2'], $config['l_delay_2']));
     $chart->add_element($line);
     //X-axis
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     //$x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     //Y-axis
     $y = new y_axis();
     $y->set_range(0, @max($data_1) + 2, 1);
     $y->set_steps(round(@max($data_1) / 8));
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_POINTS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->assignRef('rankingchartdata', $chart);
 }
Example #12
0
     $chart->set_y_axis($y);
     $chart->set_x_axis($x);
     //$posy=0;
     for ($j = 0; $j < sizeof($listeJoueurs); $j++) {
         $type = new dot();
         // if      ($posy==0)    $type = new dot();
         // else if ($posy==1)    $type = new solid_dot();
         // else if ($posy==2)    $type = new hollow_dot();
         // else if ($posy==3)    $type = new star();
         // else if ($posy==4)    $type = new anchor();
         // else if ($posy==5)    $type = new bow();
         $type->tooltip($listeJoueurs[$j]['nom'] . "<br>Jeu:#x_label#<br>Moy. #val#");
         $line = new line();
         $line->set_default_dot_style($type);
         $line->set_width(1);
         $line->set_colour($G_MesCouleurs[$j]);
         $line->set_values($data_val[$j]);
         $line->set_key($listeJoueurs[$j]["nom"], 10);
         $chart->add_element($line);
         //$posy=$posy+1;
         //if ($posy==6) $posy=0;
     }
     // Tooltip du graphe !
     $chart->set_tooltip($t);
     $fp = fopen($fichierImage, "w");
     // ouverture du fichier en écriture
     fputs($fp, $chart->toPrettyString());
     // on écrit les données
     fclose($fp);
 }
 echo "<div id=\"my_chart1\"> </div>";
Example #13
0
$line_sma15->set_key("SMA15", 12);
$line_sma10_default_dot = new dot();
$line_sma10_default_dot->colour('#DEA325');
$line_sma10 = new line();
$line_sma10->set_default_dot_style($line_sma10_default_dot);
$line_sma10->set_values($sma10);
$line_sma10->set_width(1);
$line_sma10->set_colour("#DEA325");
$line_sma10->set_key("SMA10", 12);
$line_sma5_default_dot = new dot();
$line_sma5_default_dot->colour('#16AAAF');
$line_sma5 = new line();
$line_sma5->set_default_dot_style($line_sma5_default_dot);
$line_sma5->set_values($sma5);
$line_sma5->set_width(1);
$line_sma5->set_colour("#16AAAF");
$line_sma5->set_key("SMA5", 12);
//print_r($data);
//echo "<br /><br />";
$data = array_reverse($data);
//print_r($data);
$candle = new candle('#134871');
//9933CC
$candle->set_values($data);
$candle->set_tooltip('#x_label#<br>High: #high#<br>Open: #open#<br>Close: #close#<br>Low: #low#');
$y = new y_axis();
$range = $highest - $lowest;
if ($range < 15) {
    $y->set_range(round($lowest - 1), round($highest + 1), 1);
} else {
    if ($range < 100) {
Example #14
0
 /**
  * Create a single line graph
  *
  * @param string $title Title of the graph
  * @param array $values Array of values
  * @param array $titles Array of titles
  * @return none 
  *
  */
 public static function create_line_graph($title)
 {
     self::init();
     $d = new solid_dot();
     $d->size(3)->halo_size(1)->colour('#3D5C56');
     $range_values = array();
     foreach (self::$data_set as $data) {
         if (!is_array($data['values'])) {
             continue;
         }
         $line = new line();
         $line->set_default_dot_style($d);
         $line->set_values($data['values']);
         $line->set_width(2);
         $line->set_key($data['line_title'], 10);
         $line->set_colour($data['color']);
         # Since there should be an even number on the xaxis for all sets
         $x_axis_titles = $data['titles'];
         # Add our values into a big bucket so we can get the highest and lowest
         $range_values = array_merge($range_values, $data['values']);
         self::$chart->add_element($line);
     }
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($x_axis_titles);
     $x_labels->set_vertical();
     self::$x_axis->set_labels($x_labels);
     $range = self::get_range($range_values);
     self::$y_axis->set_range($range['min'], $range['max']);
     self::show_chart($title);
 }
Example #15
0
    $bval = new bar_value($data_curr[$i]);
    $bval->{"on-click"} = "load_chart('day',{$ttime_axis[$i]})";
    if ($data_soll[$i] > 0) {
        $perc = round($data_curr[$i] / $data_soll[$i] * 100, 1);
    } else {
        $perc = 0;
    }
    $bval->set_tooltip($data_curr[$i] . ' kWh - ' . $perc . ' %');
    if ($data_curr[$i] == max($data_curr)) {
        $bval->set_colour('#ef4747');
    }
    $bars_curr->append_value($bval);
}
$line_soll = new line();
$line_soll->set_values($data_soll);
$line_soll->set_colour('#BFA447');
$line_soll->set_width(2);
$line_soll->set_key('Soll Tagesleistung (kWh)', 10);
$line_soll->set_tooltip("#val# kWh");
$max = max($data_curr) * 1.15;
$y = new y_axis();
$y->set_range(0, $max, round($max * 0.1, 0));
$x_labels = new x_axis_labels();
$x_labels->set_vertical();
$x_labels->set_colour('#333333');
$x_labels->set_labels($time_axis);
$x = new x_axis();
$x->set_colour('#333333');
$x->set_grid_colour('#ffffff');
$x->set_labels($x_labels);
$chart = new open_flash_chart();
Example #16
0
function render_service_reports()
{
    $content = "<h1>Service Reports</h1>";
    // Start Filter for  service type
    $allServiceTypes = ServiceType::get_service_types();
    #	$allServiceTypes = array('all' => 'all');
    #$allServiceTypes = array_merge($allServiceTypes, ServiceType::get_service_types());
    $allServiceTypes['all'] = 'all';
    $service_type = $_GET['service_type'];
    $service_filter = $_GET['service_type'];
    if ($service_type == '' || !isset($service_type) || !is_numeric($service_type)) {
        $service_type = 'all';
        $service_filter = '';
    }
    $filter = "\r\n\t\t<FORM>\r\n\t\t<DIV style=\" \">\r\n\t\t<SELECT name'=service_type_report'\r\n\t\t\tonChange=\"window.location='services.php?&action=serviceReports&service_type='+this.options[this.selectedIndex].value;\">";
    foreach ($allServiceTypes as $id => $name) {
        if ($service_type == $id) {
            $selected = "SELECTED";
        } else {
            $selected = '';
        }
        $filter .= "<OPTION value='{$id}' {$selected}>{$name}\n";
    }
    $filter .= "\r\n\t\t</SELECT>\r\n\t\t</DIV>\r\n\t\t</FORM>\r\n\t";
    // End filter
    $max_date = strtotime("2009-01-01");
    $start_date = date("Y-m") . "-01";
    // Get all months since start
    $workdate = strtotime($start_date);
    $now = strtotime("Now");
    $form = new Form(auto, 3);
    $headings = array("Period", "In production", "Out of Production");
    $data = array();
    $x_ax_data = array();
    $y_ax_data = array();
    $handlers = array();
    while ($workdate > $max_date) {
        $sql_enddate = date("Y-m-d", $workdate);
        $month_period = date("m-Y", $workdate);
        // This is for the chart
        $month_label = date("M\nY", $workdate);
        $graph_date = strtotime("-1 month", $workdate);
        $month_label = date("M\nY", $graph_date);
        $sql_startdate = date("Y-m-d", $workdate);
        array_push($x_ax_data, $month_label);
        array_push($y_ax_data, count(Service::get_inprod_services_at_date($sql_startdate, $service_filter)));
        // Add one month
        $workdate = strtotime("-1 month", $workdate);
        $sql_startdate = date("Y-m-d", $workdate);
        $out_of_prod = count(Service::get_outprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        $in_prod = count(Service::get_inprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        array_push($data, "{$sql_startdate} {$sql_enddate}");
        array_push($data, $in_prod);
        array_push($data, $out_of_prod);
        array_push($handlers, "handleEvent('services.php?action=detailedServiceReports&start_date={$sql_startdate}&end_date={$sql_enddate}&service_type={$service_type}')");
    }
    $form->setTableWidth("224px");
    $form->setData($data);
    $form->setEventHandler($handlers);
    $form->setHeadings($headings);
    $form->setSortable(true);
    $content .= "<div style=\"float: left; clear: both; margin-right:28px\">" . $form->showForm() . "</div>";
    // Chart
    //
    // This is the MODEL section:
    //
    include 'open-flash-chart/php-ofc-library/open-flash-chart.php';
    // create an X Axis object
    //
    $y_ax_data = array_reverse($y_ax_data);
    $x_ax_data = array_reverse($x_ax_data);
    $x = new x_axis();
    $x->set_steps(3);
    $x->set_labels_from_array($x_ax_data);
    $max = max($y_ax_data);
    $y = new y_axis();
    $y->set_range(0, $max);
    // Bar
    $bar = new bar();
    $bar->set_values($y_ax_data);
    // Bar
    // ------- LINE 2 -----
    $line_2_default_dot = new dot();
    $line_2_default_dot->size(3)->halo_size(1)->colour('#3D5C56');
    $line_2 = new line();
    $line_2->set_default_dot_style($line_2_default_dot);
    $line_2->set_values($y_ax_data);
    $line_2->set_width(3);
    $line_2->set_colour('#3D5C56');
    $chart = new open_flash_chart();
    $title = new title("In Production Services over Time");
    $title->set_style("{font-size: 10px; font-family: Times New Roman; font-weight: bold; color: #000; text-align: center;}");
    $chart->set_bg_colour('#FFFFFF');
    $chart->set_title($title);
    $chart->add_element($bar);
    //$chart->add_element( $line1 );
    $chart->add_element($line_2);
    $chart->set_x_axis($x);
    $chart->set_y_axis($y);
    //
    // This is the VIEW section:
    // Should print this first.
    //
    $heading = "\r\n\t<script type='text/javascript' src='open-flash-chart/js/json/json2.js'></script>\r\n\t<script type='text/javascript' src='open-flash-chart/js/swfobject.js'></script>\r\n\t<script type='text/javascript'>\r\n\tswfobject.embedSWF('open-flash-chart/open-flash-chart.swf', 'my_chart', '660', '350', '9.0.0');\r\n\t</script>\r\n\r\n\t<script type='text/javascript'>\r\n\r\n\tfunction open_flash_chart_data() {\r\n\t\treturn JSON.stringify(data);\r\n\t}\r\n\r\n\tfunction findSWF(movieName) {\r\n  \t\tif (navigator.appName.indexOf('Microsoft')!= -1) {\r\n    \t\t\treturn window[movieName];\r\n  \t\t} else {\r\n    \t\t\treturn document[movieName];\r\n  \t\t}\r\n\t}\r\n    \r\n\tvar data = " . $chart->toPrettyString() . "\r\n\r\n\t</script>\r\n\r\n\r\n\t<script type=\"text/javascript\">\r\n \r\n\tOFC = {};\r\n \r\n\tOFC.jquery = {\r\n    \tname: 'jQuery',\r\n    \tversion: function(src) { return \$('#'+ src)[0].get_version() },\r\n    \trasterize: function (src, dst) { \$('#'+ dst).replaceWith(OFC.jquery.image(src)) },\r\n    \timage: function(src) { return \"<img src='data:image/png;base64,\" + \$('#'+src)[0].get_img_binary() + \"' />\"},\r\n    \tpopup: function(src) {\r\n        var img_win = window.open('', 'Charts: Export as Image')\r\n        with(img_win.document) {\r\n            write('<html><head><title>Charts: Export as Image<\\/title><\\/head><body>' + OFC.jquery.image(src) + '<\\/body><\\/html>') }\r\n\t\t// stop the 'loading...' message\r\n\t\timg_win.document.close();\r\n     \t}\r\n\t}\r\n \r\n\t// Using_ an object as namespaces is JS Best Practice. I like the Control.XXX style.\r\n\t//if (!Control) {var Control = {}}\r\n\t//if (typeof(Control == \"undefined\")) {var Control = {}}\r\n\tif (typeof(Control == \"undefined\")) {var Control = {OFC: OFC.jquery}}\r\n \r\n \r\n\t// By default, right-clicking on OFC and choosing \"save image locally\" calls this function.\r\n\t// You are free to change the code in OFC and call my wrapper (Control.OFC.your_favorite_save_method)\r\n\t// function save_image() { alert(1); Control.OFC.popup('my_chart') }\r\n\tfunction save_image() { alert(\"Your image will be displayed in a new window\"); OFC.jquery.popup('my_chart') }\r\n\t</script>\r\n\t<div id='my_chart' style='float:left; margin-left:28px;'></div>\r\n\t";
    print " {$content}\n \r\n\t\t<div style=''<b>Select Service Type:</b>{$filter} <br></div>\n\r\n\t\t{$heading} ";
}
Example #17
0
 function getNewUsersByTime($timePhase, $fromDate = '', $toDate = '')
 {
     $this->load->library('ofc');
     $userId = $this->common->getUserId();
     $this->ofc->open_flash_chart();
     $this->ofc->set_bg_colour(CHART_BG_COLOR);
     $toTime = date("Y-m-d", strtotime("-1 day"));
     if ($timePhase == "7day") {
         $fromTime = date("Y-m-d", strtotime("-8 day"));
         $color = CHART_LINE_1;
         $key = "近7日新增用户";
         $title = new title("近7日新增用户统计");
     }
     if ($timePhase == "1month") {
         $title = new title("近30天新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-31 day"));
         $color = CHART_LINE_2;
         $key = "近30天新增用户统计";
     }
     if ($timePhase == "3month") {
         $title = new title("近三个月新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-92 day"));
         $color = CHART_LINE_3;
         $key = "近三个月新增用户统计";
     }
     if ($timePhase == "all") {
         $title = new title("所有新增用户统计");
         $fromTime = '1970-01-01';
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     if ($timePhase == "any") {
         $title = new title("所有新增用户统计");
         $fromTime = $fromDate;
         $toTime = $toDate;
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     $fromTime = $this->product->getUserStartDate($userId, $fromTime);
     $query = $this->newusermodel->getNewUsersByUserId($fromTime, $toTime, $userId);
     $data = array();
     $maxY = 0;
     $recordCount = $query->num_rows();
     $steps = $recordCount - 1 <= 10 ? 2 : (int) (((int) $recordCount - 1) / 10);
     $xlabelArray = array();
     if ($query != null && $query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $dot = new dot();
             $dot->size(3)->halo_size(1)->colour($color);
             $dot->tooltip($row->startdate . " 新增" . $row->totalusers . "用户");
             $dot->value((int) $row->totalusers);
             if ((int) $row->totalusers > $maxY) {
                 $maxY = (int) $row->totalusers;
             }
             array_push($xlabelArray, date('y-m-d', strtotime($row->startdate)));
             array_push($data, $dot);
         }
     }
     $y = new y_axis();
     $y->set_range(0, $this->common->getMaxY($maxY), $this->common->getStepY($maxY));
     $x = new x_axis();
     $x->set_range(0, $recordCount > 1 ? $recordCount - 1 : 1);
     $x_labels = new x_axis_labels();
     $x_labels->set_steps($steps);
     $x_labels->set_vertical();
     $x_labels->set_colour(CHART_LABEL_COLOR);
     $x_labels->set_size(13);
     $x_labels->set_labels($xlabelArray);
     $x_labels->rotate(-25);
     $x->set_labels($x_labels);
     $x->set_steps(1);
     $this->ofc->set_y_axis($y);
     $this->ofc->set_x_axis($x);
     $dot = new dot();
     $dot->size(3)->halo_size(1)->colour($color);
     $line = new line();
     $line->set_default_dot_style($dot);
     $line->set_values($data);
     $line->set_width(2);
     $line->set_colour($color);
     $line->colour($color);
     $line->set_key($key, 12);
     $this->ofc->add_element($line);
     $title->set_style("{font-size: 14px; color:#000000; font-family: Verdana; text-align: center;}");
     // 		$x_legend = new x_legend("<a href=\"javascript:changeChartName('chartNewUser')\">新增用户</a> <a href=\"javascript:changeChartName('chartActiveUser')\">活跃用户</a> <a href=\"javascript:changeChartName('chartStartUser')\">启动用户</a>");
     // 		$this->ofc->set_x_legend( $x_legend );
     // 		$x_legend->set_style( '{font-size: 14px; color: #778877}' );
     $this->ofc->set_title($title);
     echo $this->ofc->toPrettyString();
 }
 /**
  * assign the chartdata object for open flash chart library
  * @param $config
  * @return unknown_type
  */
 function _setChartdata($config)
 {
     require_once JLG_PATH_SITE . DS . "assets" . DS . "classes" . DS . "open-flash-chart" . DS . "open-flash-chart.php";
     $data = $this->get('ChartData');
     // Calculate Values for Chart Object
     $forSum = array();
     $againstSum = array();
     $matchDayGoalsCount = array();
     $matchDayGoalsCount[] = 0;
     $round_labels = array();
     $matchDayGoalsCountMax = 0;
     foreach ($data as $rw) {
         if (!$rw->goalsfor) {
             $rw->goalsfor = 0;
         }
         if (!$rw->goalsagainst) {
             $rw->goalsagainst = 0;
         }
         $forSum[] = intval($rw->goalsfor);
         $againstSum[] = intval($rw->goalsagainst);
         // check, if both results are missing and avoid drawing the flatline of "0" goals for not played games yet
         if (!$rw->goalsfor && !$rw->goalsagainst) {
             $matchDayGoalsCount[] = 0;
         } else {
             $matchDayGoalsCount[] = intval($rw->goalsfor + $rw->goalsagainst);
         }
         $round_labels[] = $rw->roundcode;
     }
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     $barfor = new $config['bartype_1']();
     $barfor->set_values($forSum);
     $barfor->set_tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_FOR') . ": #val#");
     $barfor->set_colour($config['bar1']);
     $barfor->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
     $barfor->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_FOR'), 12);
     $baragainst = new $config['bartype_2']();
     $baragainst->set_values($againstSum);
     $baragainst->set_tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_AGAINST') . ": #val#");
     $baragainst->set_colour($config['bar2']);
     $baragainst->set_on_show(new bar_on_show($config['animation_2'], $config['cascade_2'], $config['delay_2']));
     $baragainst->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS_AGAINST'), 12);
     $chart->add_element($barfor);
     $chart->add_element($baragainst);
     // total
     $d = new $config['dotstyle_3']();
     $d->size((int) $config['line3_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line3']);
     $d->tooltip(JText::_('COM_JOOMLEAGUE_TEAMSTATS_TOTAL2') . ' #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values(array_slice($matchDayGoalsCount, 1));
     $line->set_width((int) $config['line3_strength']);
     $line->set_key(JText::_('COM_JOOMLEAGUE_TEAMSTATS_TOTAL'), 12);
     $line->set_colour($config['line3']);
     $line->on_show(new line_on_show($config['l_animation_3'], $config['l_cascade_3'], $config['l_delay_3']));
     $chart->add_element($line);
     $x = new x_axis();
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $x->set_labels_from_array($round_labels);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_TEAMSTATS_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(0, max($matchDayGoalsCount) + 2, $config['y_axis_steps']);
     $y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_TEAMSTATS_GOALS'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     $this->assignRef('chartdata', $chart);
 }
Example #19
0
 function indexAction()
 {
     //		$this->_helper->layout->disableLayout();
     //		$login = "******";
     //		$password = "******";
     //		include_once 'sina.php';
     //		$resultarray = get_sinacontacts($login, $password);
     //		Zend_Debug::dump($resultarray);
     //		include_once '163.php';
     //		$login = '******';
     //		$password = '******';
     //		$resultarray = get_163contacts($login, $password);
     //		Zend_Debug::dump($resultarray);
     //		include_once 'yahoo.php';
     //		$obj = new GrabYahoo();
     //		$contacts = $obj->getAddressbook('*****@*****.**','19990402');
     //		Zend_Debug::dump($contacts);
     //		include_once "contacts_fn.php";
     //		$ret_array = get_msncontacts('*****@*****.**', '1999040211');
     //		Zend_Debug::dump($ret_array);
     //		$this->_helper->layout->setLayout("layout_admin");
     $this->_helper->layout->disableLayout();
     // get date from db
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('report', array('left(create_date,10) as date', 'accesscode'))->where('report.campaign_id = 3')->where("report.state = 'APPROVED'")->order('date');
     $results = $db->fetchAll($select);
     $accesscodeDbMatchArray = array();
     foreach ($results as $result) {
         $accesscodeDbMatchArray[$result['accesscode']] = $result['date'];
     }
     $accesscodeArray = array_keys($accesscodeDbMatchArray);
     //		Zend_Debug::Dump($accesscodematchArray);
     // get value from ws
     $indicate2Connect = new Indicate2_Connect();
     $response = $indicate2Connect->getAnswerSetForSurvey(385, null, array(array('ContextIndex' => 1, 'QuestionIndex' => 1), array('ContextIndex' => 1, 'QuestionIndex' => 4)), 0);
     //        Zend_Debug::Dump($response);
     $talkingdurationArray = array();
     $accesscodeResponseMathArray = array();
     if (isset($response->AnswerSetType)) {
         foreach ($response->AnswerSetType as $answerSet) {
             if (isset($answerSet->AnswerType) && is_array($answerSet->AnswerType) && !empty($answerSet->AnswerType)) {
                 foreach ($answerSet->AnswerType as $answer) {
                     if ($answer->QuestionId == 573) {
                         $accesscodeResponseMathArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answer->AnswerText)));
                     }
                     if ($answer->QuestionId == 576) {
                         $talkingdurationArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answer->AnswerText)));
                     }
                 }
             } else {
                 //get min value, like '11-15' = 11
                 $accesscodeResponseMathArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answerSet->AnswerType->AnswerText)));
             }
         }
     }
     //		Zend_Debug::Dump($accesscodeResponseMathArray);
     //		Zend_Debug::Dump($talkingdurationArray);
     $resultmatchArray = array();
     foreach ($accesscodeArray as $accesscode) {
         $resultmatchArray[$accesscodeDbMatchArray[$accesscode]] = 0;
     }
     foreach ($accesscodeArray as $accesscode) {
         if (array_key_exists($accesscode, $accesscodeResponseMathArray)) {
             $resultmatchArray[$accesscodeDbMatchArray[$accesscode]] += $accesscodeResponseMathArray[$accesscode];
         }
     }
     //		 Zend_Debug::Dump($resultmatchArray);
     $dateArray = array_keys($resultmatchArray);
     foreach ($dateArray as $date) {
         $resultmatchArray[$date] = floor($resultmatchArray[$date] * 1.65);
     }
     //        Zend_Debug::Dump($resultmatchArray);
     include 'open-flash-chart.php';
     $data_1 = array();
     $base = floor(1472 * 1.65);
     $temp = 0;
     $resultmatchArray[0] = 0;
     foreach ($dateArray as $date) {
         $resultmatchArray[$date] += $resultmatchArray[$temp];
         $data_1[] = $resultmatchArray[$date] + $base;
         $temp = $date;
     }
     //		Zend_Debug::Dump($data_1);
     $title = new title("Impressions of BugsLock by day");
     $y = new y_axis();
     $y->set_range(0, 40000, 10000);
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($dateArray);
     $x_labels->set_steps(2);
     $x_labels->rotate(40);
     $x->set_labels($x_labels);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour('#f00000')->tooltip('#x_label#: #val#');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($data_1);
     $line_1->set_width(1);
     $line_1->set_key('Impression', 10);
     $this->view->chart = new open_flash_chart();
     $this->view->chart->set_title($title);
     $this->view->chart->add_element($line_1);
     $this->view->chart->set_y_axis($y);
     $this->view->chart->set_x_axis($x);
     $this->view->chart->set_bg_colour('#FFFFFF');
     //
     include 'ofc_sugar.php';
     $this->view->chart2 = new open_flash_chart();
     $this->view->chart2->set_title(new title('Generation Chart'));
     $line_1 = new line();
     $array_1 = array();
     $f = 1.5;
     for ($i = 0; $i <= 50; $i++) {
         array_push($array_1, $f);
     }
     $line_1->set_values($array_1);
     //		$line_1->set_default_dot_style( new s_hollow_dot('#FBB829', 4) );
     $line_1->set_width(1);
     $line_1->set_colour('#FF0000');
     $line_1->set_tooltip("Gen0");
     $line_1->set_key('Gen0', 10);
     $line_1->loop();
     $area = new area();
     // set the circle line width:
     $area->set_width(1);
     //		$area->set_default_dot_style( new s_hollow_dot('#45909F', 5) );
     $area->set_colour('#FF0000');
     //		$area->set_fill_colour( '#FF0000' );
     //		$area->set_fill_alpha( 0.4 );
     $area->set_loop();
     $area->set_values($array_1);
     $line_2 = new line();
     $array_2 = array();
     $f = 2.8;
     for ($i = 0; $i <= 50; $i++) {
         array_push($array_2, $f);
     }
     $line_2->set_values($array_2);
     //		$line_2->set_default_dot_style( new s_hollow_dot('#FBB829', 4) );
     $line_2->set_width(1);
     $line_2->set_colour('#FBB829');
     $line_2->set_tooltip("Gold<br>#val#");
     $line_2->set_key('Gen1', 10);
     $line_2->loop();
     $line_4 = new line();
     $array_4 = array();
     $f = 5;
     for ($i = 0; $i <= 50; $i++) {
         array_push($array_4, $f);
     }
     $line_4->set_values($array_4);
     //		$line_2->set_default_dot_style( new s_star('#8000FF', 4) );
     $line_4->set_width(1);
     $line_4->set_colour('#3030D0');
     $line_4->set_tooltip("Purple<br>#val#");
     $line_4->set_key('Gen2', 10);
     $line_4->loop();
     // add the area object to the chart:
     $this->view->chart2->add_element($line_1);
     $this->view->chart2->add_element($line_2);
     $this->view->chart2->add_element($line_4);
     $r = new radar_axis(5);
     $r->set_colour('#FFFFFF');
     $r->set_grid_colour('#FFFFFF');
     $labels = new radar_axis_labels(array('G0', '', 'G1', '', 'G2'));
     $labels->set_colour('#9F819F');
     $r->set_labels($labels);
     $this->view->chart2->set_radar_axis($r);
     $tooltip = new tooltip();
     $tooltip->set_proximity();
     $this->view->chart2->set_tooltip($tooltip);
     $this->view->chart2->set_bg_colour('#ffffff');
     //		echo $this->view->chart2->toPrettyString();
 }
Example #20
0
     $hms[] = $line['Day'];
     $count = intval($line['value']);
     if (!is_int($count)) {
         $count = 0;
     }
     $array[] = $count;
     $v = intval($line['avg']);
     if (is_int($v)){
         $avg[] = $v;
     }
 }
 if (empty($array)) $array[] = 0;
 $bar->set_values( $array );
 $bar->set_tooltip("#val#<br>Average = ".commify($avg[0]));
 $bar2->set_values( ($avg) );
 $bar2->set_colour( "#40FF40" );
 $bar2->set_tooltip("#val#<br>Average [#x_label#]");
 //
 // create a Y Axis object
 //
 $y = new y_axis();
 // grid steps:
 $y->set_range( 0, max($array), round(max($array)/10));
 $chart->set_y_axis( $y );
 $x_labels = new x_axis_labels();
 $x_labels->set_vertical();
 $x_labels->set_labels( $hms );
 $x = new x_axis();
 $x->set_labels( $x_labels );
 $chart->set_x_axis( $x );
 echo $chart->toPrettyString();
Example #21
0
');
$deposits = array();
$withdrawals = array();
$weeks = array();
while ($row = mysql_fetch_assoc($result)) {
    $weeks[] = date('d.m.Y', $row['stamp']);
    $deposits[] = round($row['deposits'], 2);
    $withdrawals[] = -round($row['withdrawals'], 2);
}
//lines
$line1 = new line();
$line1->set_values($deposits);
$line1->set_colour('#00FF00');
$line2 = new line();
$line2->set_values($withdrawals);
$line2->set_colour('#FF0000');
//axises
$axis_x = new x_axis();
$axis_x_labels = new x_axis_labels();
$axis_x_labels->set_labels($weeks);
$axis_x->set_labels($axis_x_labels);
$axis_y = new y_axis();
$axis_y->range(0, max(max($deposits), max($withdrawals)), 1000);
//chart
$chart = new open_flash_chart();
$chart->set_y_axis($axis_y);
$chart->set_x_axis($axis_x);
$chart->add_element($line1);
$chart->add_element($line2);
$chart->set_bg_colour('#FFFFFF');
echo $chart->toPrettyString();
 public function clientimpressionAction()
 {
     ini_set('display_errors', 1);
     $frontController = Zend_Controller_Front::getInstance();
     $frontController->throwExceptions(true);
     // filter!
     if (!$this->clientdashboardfilter()) {
         return;
     }
     $this->view->activeTab = 'clientimpression';
     include 'open-flash-chart.php';
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $campaign_id = $formData['campaign_id'];
     } else {
         $campaign_id = $request->getParam('id');
     }
     $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign_id));
     $this->view->campaign_id = $campaign_id;
     // get date from db
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('report', array('left(create_date,10) as date', 'accesscode'))->where('report.campaign_id = ?', $campaign_id)->where('report.state = "APPROVED"')->order('date');
     $results = $db->fetchAll($select);
     $accesscodeDbMatchArray = array();
     foreach ($results as $result) {
         $accesscodeDbMatchArray[$result['accesscode']] = $result['date'];
     }
     $accesscodeArray = array_keys($accesscodeDbMatchArray);
     $campaignModel = new Campaign();
     $campaign = $campaignModel->fetchRow('id = ' . $campaign_id);
     // get impression value from ws
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('dashboard_mapping');
     $select->where('survey_id = ?', $campaign->i2_survey_id);
     $select->where('mark="FRIENDS"');
     $mappings = $db->fetchRow($select);
     $indicate2Connect = new Indicate2_Connect();
     $response = $indicate2Connect->getAnswerSetForSurvey(array($campaign->i2_survey_id, $campaign->i2_survey_id_en), null, array(array('ContextIndex' => $mappings['context_index'], 'QuestionIndex' => $mappings['question_index'])), 0);
     //        Zend_Debug::dump($mappings);die;
     $optionArray = array();
     if (isset($response->QuestionType) && is_array($response->QuestionType)) {
         foreach ($response->QuestionType as $questionType) {
             foreach ($questionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     } else {
         if (isset($response->QuestionType->SelectionQuestionOptionType)) {
             foreach ($response->QuestionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 if ($optionObject->OptionText == '>=10') {
                     $optionArray[$optionObject->OptionId] = 10;
                 }
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     }
     $answerArray = array();
     $i = 0;
     if (isset($response->AnswerSetType)) {
         foreach ($response->AnswerSetType as $answerObject) {
             $answerArray[$i++] = array($answerObject->AccessCode, iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answerObject->AnswerType->AnswerText))));
         }
     }
     // create x axis date value (endDate = expireDate/now + 10 days)
     $this->view->startDate = $startDate = date("Y-m-d", strtotime($campaign->create_date));
     if (strtotime($campaign->expire_date) > strtotime(date("Y-m-d"))) {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime(date("Y-m-d"))));
     } else {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime($campaign->expire_date)));
     }
     if ($request->isPost()) {
         $formData = $request->getPost();
         $this->view->xmax = $endDate = $formData['x_max'];
     }
     $resultArray = array();
     $xDateArrayLength = 0;
     while (1) {
         $resultArray[$startDate] = 0;
         $startDate = date("Y-m-d", strtotime("+1 days", strtotime($startDate)));
         $xDateArrayLength++;
         if ($startDate == $endDate) {
             $resultArray[$startDate] = 0;
             $xDateArrayLength++;
             break;
         }
     }
     //var_dump($resultArray);die;
     // set sparks initial impressions for each campaign, it should be added if a new campaign is lanuched!
     switch ($campaign_id) {
         case '1':
             $staticsparks = array(50, 110);
             break;
         case '2':
             $staticsparks = array(50, 150, 250, 400, 450);
             break;
         case '3':
             $staticsparks = array(100, 350, 750, 1200, 1500);
             break;
         case '4':
             $staticsparks = array(50, 200, 250);
             break;
         case '5':
             $staticsparks = array(50, 150);
             break;
         case '6':
             $staticsparks = array(50, 150, 350, 500, 900, 1700, 2300, 2500);
             break;
         case '7':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 150, 350, 500, 900, 1038);
             break;
         case '8':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '9':
             $staticsparks = array(0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '10':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '13':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 50, 100, 150, 300, 450, 600, 750, 900, 1200);
             break;
         default:
             break;
     }
     for ($temp = count($staticsparks); $temp < $xDateArrayLength; $temp++) {
         $staticsparks[$temp] = $staticsparks[$temp - 1];
     }
     // set everyday impression by using ws data
     foreach ($answerArray as $answer) {
         if (!isset($accesscodeDbMatchArray[$answer[0]])) {
             continue;
         }
         if (date("Y-m-d", strtotime($accesscodeDbMatchArray[$answer[0]])) > date("Y-m-d", strtotime($this->view->xmax))) {
             continue;
         }
         if (!array_key_exists($accesscodeDbMatchArray[$answer[0]], $resultArray)) {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] = $optionArray[$answer[1]];
         } else {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] += $optionArray[$answer[1]];
         }
     }
     //Zend_Debug::dump($optionArray);
     //Zend_Debug::dump($resultArray);
     //Zend_Debug::dump($answerArray);
     //Zend_Debug::dump($accesscodeDbMatchArray);
     // set line value
     $sparks = 0;
     $data_1 = array();
     $data_2min = array();
     $data_2max = array();
     $data_3min = array();
     $data_3max = array();
     $i = 0;
     $data_1[0] = $data_2max[0] = $data_2min[0] = $data_3min[0] = $data_3max[0] = $accumulate = 0;
     $temp = 0;
     foreach ($resultArray as $result) {
         if ($result != 0) {
             $xTodayLength = $temp;
         }
         $temp++;
     }
     foreach ($resultArray as $result) {
         if ($i == 0) {
             $i++;
             continue;
         }
         $accumulate = $result + $accumulate;
         $data_1[$i] = $accumulate + $staticsparks[$i];
         $data_2min[$i] = floor($accumulate * 2.5 + $staticsparks[$i]);
         $data_2max[$i] = $accumulate * 5 + $staticsparks[$i];
         $data_2avg[$i] = $accumulate * 3.75;
         $data_3min[$i] = floor($data_2avg[$i] * 3) + $data_2min[$i];
         $data_3max[$i] = floor($data_2avg[$i] * 4) + $data_2max[$i];
         $max = $data_3max[$i];
         if ($i == $xTodayLength) {
             break;
         }
         $i++;
     }
     // set max y axis value
     $dateArray = array_keys($resultArray);
     $y = new y_axis();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $max = $formData['y_max'];
     } else {
         if ($max < 10000) {
             $max = ceil($max / 100) * 100;
         } else {
             $max = ceil($max / 1000) * 1000;
         }
     }
     $y->set_range(0, $max, $max / 10);
     $this->view->ymax = $max;
     // draw lines
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($dateArray);
     $x_labels->set_steps(floor($xDateArrayLength / 42) + 1);
     $x_labels->rotate(40);
     $x->set_labels($x_labels);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour('#007DCD')->tooltip('#x_label#: #val#');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($data_1);
     $line_1->set_colour("#007DCD");
     $line_1->set_width(1);
     $line_2min_default_dot = new dot();
     $line_2min_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2min = new line();
     $line_2min->set_default_dot_style($line_2min_default_dot);
     $line_2min->set_values($data_2min);
     $line_2min->set_colour("#81C909");
     $line_2min->set_width(1);
     $line_2_default_dot = new dot();
     $line_2_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2 = new line();
     $line_2->set_default_dot_style($line_2_default_dot);
     $line_2->set_values($data_2max);
     $line_2->set_colour("#81C909");
     $line_2->set_width(1);
     $line_3_default_dot = new dot();
     $line_3_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3 = new line();
     $line_3->set_default_dot_style($line_3_default_dot);
     $line_3->set_values($data_3min);
     $line_3->set_colour("#FF0000");
     $line_3->set_width(1);
     $line_3max_default_dot = new dot();
     $line_3max_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3max = new line();
     $line_3max->set_default_dot_style($line_3max_default_dot);
     $line_3max->set_values($data_3max);
     $line_3max->set_colour("#FF0000");
     $line_3max->set_width(1);
     //tags
     $tags = new ofc_tags();
     $tags->font("Verdana", 10)->colour("#2F2F2F")->align_x_right();
     $this->view->chart = new open_flash_chart();
     // create event
     $campaignEventModel = new CampaignEvent();
     $campaignEvents = $campaignEventModel->fetchAll('campaign_id = ' . $campaign_id, 'event_date');
     $eventTotal = count($campaignEvents);
     $eventTemp = 0;
     foreach ($campaignEvents as $campaignEvent) {
         $eventDate = floor((strtotime($campaignEvent->event_date) - strtotime($campaign->create_date)) / 86400);
         $eventDescription = $campaignEvent->event_name;
         // event line
         $eventline = new scatter_line('#C5BE97', 1);
         $def = new hollow_dot();
         $def->size(0)->halo_size(0);
         $eventline->set_default_dot_style($def);
         $v = array(new scatter_value($eventDate, 0), new scatter_value($eventDate, $this->view->ymax));
         $eventline->set_values($v);
         $this->view->chart->add_element($eventline);
         // event description
         $tagAndArrow_Yvalue = 1 - ($eventTotal - $eventTemp++) / 10;
         if ($tagAndArrow_Yvalue == 0) {
             $tagAndArrow_Yvalue = 0.1;
         }
         $tag_xvalue = $eventDate + 2;
         $t = new ofc_tag($tag_xvalue, $this->view->ymax * $tagAndArrow_Yvalue);
         $t->text($eventDescription)->style(false, false, false, 1.0)->padding(0, 0);
         $tags->append_tag($t);
         // event arrow
         $arrowStart_x = $tag_xvalue;
         $arrowStart_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowEnd_x = $tag_xvalue - 1.5;
         $arrowEnd_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowColor = '#000000';
         $arrowBarbLength = 7;
         $a = new ofc_arrow($arrowStart_x, $arrowStart_y, $arrowEnd_x, $arrowEnd_y, $arrowColor, $arrowBarbLength);
         $this->view->chart->add_element($a);
     }
     $this->view->chart->add_element($line_1);
     $this->view->chart->add_element($line_2min);
     $this->view->chart->add_element($line_2);
     $this->view->chart->add_element($line_3);
     $this->view->chart->add_element($line_3max);
     $this->view->chart->add_element($tags);
     $this->view->chart->set_y_axis($y);
     $this->view->chart->set_x_axis($x);
     $this->view->chart->set_bg_colour('#FFFFFF');
 }