コード例 #1
0
 /**
  * Build The Bar Gharph.
  *
  * @param  array  $params  assoc array of name/value pairs          
  *
  * @return object $chart   object of open flash chart.
  * @static
  */
 static function &barChart(&$params)
 {
     $chart = null;
     if (empty($params)) {
         return $chart;
     }
     $values = CRM_Utils_Array::value('values', $params);
     if (!is_array($values) || empty($values)) {
         return $chart;
     }
     // get the required data.
     $xValues = $yValues = array();
     foreach ($values as $xVal => $yVal) {
         $yValues[] = (double) $yVal;
         // we has to have x values as string.
         $xValues[] = (string) $xVal;
     }
     $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
     //set y axis parameters.
     $yMin = 0;
     // calculate max scale for graph.
     $yMax = ceil(max($yValues));
     if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
         $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
     }
     $ySteps = $yMax / 5;
     // $bar = new bar( );
     // glass seem to be more cool
     $bar = new bar_glass();
     //set values.
     $bar->set_values($yValues);
     // call user define function to handle on click event.
     if ($onClickFunName = CRM_Utils_Array::value('on_click_fun_name', $params)) {
         $bar->set_on_click($onClickFunName);
     }
     // get the currency.
     require_once 'CRM/Utils/Money.php';
     $config = CRM_Core_Config::singleton();
     $symbol = $config->defaultCurrencySymbol;
     // set the tooltip.
     $tooltip = CRM_Utils_Array::value('tip', $params, "{$symbol} #val#");
     $bar->set_tooltip($tooltip);
     // create x axis label obj.
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($xValues);
     // set angle for labels.
     if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
         $xLabels->rotate($xLabelAngle);
     }
     // create x axis obj.
     $xAxis = new x_axis();
     $xAxis->set_labels($xLabels);
     //create y axis and set range.
     $yAxis = new y_axis();
     $yAxis->set_range($yMin, $yMax, $ySteps);
     // create chart title obj.
     $title = new title($chartTitle);
     // create chart.
     $chart = new open_flash_chart();
     // add x axis w/ labels to chart.
     $chart->set_x_axis($xAxis);
     // add y axis values to chart.
     $chart->add_y_axis($yAxis);
     // set title to chart.
     $chart->set_title($title);
     // add bar element to chart.
     $chart->add_element($bar);
     // add x axis legend.
     if ($xName = CRM_Utils_Array::value('xname', $params)) {
         $xLegend = new x_legend($xName);
         $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_x_legend($xLegend);
     }
     // add y axis legend.
     if ($yName = CRM_Utils_Array::value('yname', $params)) {
         $yLegend = new y_legend($yName);
         $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_y_legend($yLegend);
     }
     return $chart;
 }
コード例 #2
0
ファイル: solardata_day.php プロジェクト: ragchuck/pv
 $sline = new scatter_line('#3D3D3D', 3);
 $def = new hollow_dot();
 $def->size(0)->halo_size(0);
 $sline->set_default_dot_style($def);
 $sline->set_key('Leistung (W)', 11);
 $v = array();
 foreach ($data_watt as $key => $val) {
     $v[] = new scatter_value($key, $val);
     $v[] = new scatter_value($key + 1, $val);
 }
 $sline->set_values($v);
 $bars_curr = new bar_glass();
 $bars_curr->set_key('Leistung (W)', 10);
 $bars_curr->set_colour('#EFC01D');
 $bars_curr->set_alpha(0.8);
 $bars_curr->set_tooltip('#val# W');
 for ($i = 0; $i < count($data_watt); $i++) {
     $bval = new bar_value($data_watt[$i]);
     if ($data_watt[$i] == max($data_watt)) {
         $bval->set_tooltip("Tages-Spitzenwert:<br>#val# W um {$time_axis[$i]} Uhr");
         $bval->set_colour('#ef4747');
     }
     $bars_curr->append_value($bval);
 }
 // PEAK
 $max_val = max($data_watt);
 $i = array_search($max_val, $data_watt);
 $s = new star($data_watt[$i]);
 $s->tooltip("Tages-Spitzenwert:<br>#val# W um #x_label# Uhr");
 $data_watt[$i] = $s->size(6)->halo_size(3)->colour('#ff0000');
 /*		
コード例 #3
0
ファイル: solardata_month.php プロジェクト: ragchuck/pv
    print_r($data_curr);
    print_r($data_soll);
}
if ($i == 0) {
    echo 0;
    exit;
}
$title = new title("\n" . date('F Y', $time) . " (" . round($MaxETotal - $MinETotal, 2) . " kWh)");
$title->set_style('{font-size: 20px; color: #778877}');
$tooltip = new tooltip();
$tooltip->set_hover();
$bars_curr = new bar_glass();
$bars_curr->set_key('Ist Tagesleistung (kWh)', 10);
$bars_curr->set_colour('#EFC01D');
$bars_curr->set_alpha(0.8);
$bars_curr->set_tooltip('#val# kWh');
for ($i = 0; $i < count($data_curr); $i++) {
    $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();