Example #1
0
 /**
  * Get an instance of a SparklineBar object, always creating it
  *
  * @param	array	Configuration array
  * @return	object	KChartSparklineBar proxy object
  */
 public static function getInstance($config = array())
 {
     if (!isset($config['catch_errors'])) {
         $config['catch_errors'] = true;
     }
     $obj = new Sparkline_Bar($config['catch_errors']);
     $obj->SetDebugLevel(DEBUG_NONE);
     return new KChartSparklineBar($obj);
 }
Example #2
0
 * Sparkline is distributed under a BSD License.  See LICENSE for details.
 *
 * $Id: filled.php,v 1.1 2005/03/31 22:58:55 frabcus Exp $
 *
 * filled shows deficit data in a simulated filled-line mode
 *              
 */
// annual deficit data, 1983-2003
// source OMB, http://www.whitehouse.gov/omb/budget/fy2004/hist.html
//
$data = array(1983 => -207.802, 1984 => -185.367, 1985 => -212.308, 1986 => -221.215, 1987 => -149.728, 1988 => -155.152, 1989 => -152.456, 1990 => -221.195, 1991 => -269.328, 1992 => -290.376, 1993 => -255.087, 1994 => -203.25, 1995 => -163.972, 1996 => -107.473, 1997 => -21.958, 1998 => 69.21299999999999, 1999 => 125.563, 2000 => 236.445, 2001 => 127.299, 2002 => -157.802, 2003 => -304.159);
//////////////////////////////////////////////////////////////////////////////
// build sparkline using standard flow:
//   construct, set, render, output
//
require_once '../lib/Sparkline_Bar.php';
$sparkline = new Sparkline_Bar();
$sparkline->SetDebugLevel(DEBUG_ERROR | DEBUG_WARNING | DEBUG_STATS | DEBUG_CALLS, '../log.txt');
$sparkline->SetBarWidth(1);
$sparkline->SetBarSpacing(0);
$sparkline->SetBarColorDefault('blue');
$j = 0;
for ($i = 1983; $i < sizeof($data) + 1983; $i++) {
    $sparkline->SetData($j++, $data[$i]);
    if (isset($data[$i + 1])) {
        $sparkline->SetData($j++, ($data[$i] + $data[$i + 1]) / 2);
    }
}
$sparkline->Render(10);
// height only for Sparkline_Bar
$sparkline->Output();
Example #3
0
<?php

/********************************************************\
  | Activity Graph Maker 								   |
  | Renders a graph for topview                            |
  | ~~~~~~~~~~~~~                                          |
  \********************************************************/
if (!defined('IN_FS')) {
    die('Do not access this file directly.');
}
require_once BASEDIR . '/includes/external/sparkline/Sparkline_Bar.php';
$sparkline = new Sparkline_Bar();
$sparkline->SetBarColorDefault("CleanFS");
$sparkline->SetBarWidth(4);
$sparkline->SetBarSpacing(1);
//PROJECT GRAPH
//Anonymous
if (Get::has('project_id') && !Get::has('graph')) {
    $thirtyDays = array();
    $today = date('m/j/Y');
    $daythirtyone = '';
    for ($i = 1; $i < 31; $i++) {
        $newday = date('m/j/Y', strtotime("-{$i} day", strtotime($today)));
        $val = Project::getDayActivityByProject($newday, Get::num('project_id'));
        $sparkline->SetData($i, $val[0]);
        $daythirtyone = $newday;
    }
    $daythirtyone = date('m/j/Y', strtotime("-2 day", strtotime($daythirtyone)));
    $daysixtyone = date('m/j/Y', strtotime("-32 day", strtotime($daythirtyone)));
    //look 30 days more and if found scale
    $projectCheck = Project::getActivityProjectCount($daysixtyone, $daythirtyone, Get::num('project_id'));
Example #4
0
// win/loss, home, shutout
// 2004 postseason, source MLB.com
// if anyone has full season data in a workable format, please let me know
//  - jbyers@users.sf.net
//
$data['yankees'] = array(0 => array(0, 1, 1), 1 => array(1, 1, 0), 2 => array(1, 0, 0), 3 => array(1, 0, 0), 4 => array(1, 1, 0), 5 => array(1, 1, 0), 6 => array(1, 0, 0), 7 => array(0, 0, 0), 8 => array(0, 0, 0), 9 => array(0, 1, 0), 10 => array(0, 1, 0));
$data['redsox'] = array(0 => array(1, 0, 0), 1 => array(1, 0, 0), 2 => array(1, 1, 0), 3 => array(0, 0, 0), 4 => array(0, 0, 0), 5 => array(0, 1, 0), 6 => array(1, 1, 0), 7 => array(1, 1, 0), 8 => array(1, 0, 0), 9 => array(1, 0, 0));
if (!isset($_GET['t']) || $_GET['t'] != 'yankees' && $_GET['t'] != 'redsox') {
    die('bad team name; need ?t=yankees or ?t=redsox');
}
//////////////////////////////////////////////////////////////////////////////
// build sparkline using standard flow:
//   construct, set, render, output
//
require_once '../lib/Sparkline_Bar.php';
$sparkline = new Sparkline_Bar();
$sparkline->SetDebugLevel(DEBUG_NONE);
//$sparkline->SetDebugLevel(DEBUG_ERROR | DEBUG_WARNING | DEBUG_STATS | DEBUG_CALLS, '../log.txt');
$sparkline->SetBarWidth(1);
$sparkline->SetBarSpacing(2);
$i = 0;
while (list(, $v) = each($data[$_GET['t']])) {
    // set bar color red if shutout
    //
    $color = 'black';
    if ($v[2]) {
        $color = 'red';
    }
    // set bar underscore boolean if home game
    //
    $underscore = false;
Example #5
0
        $sparkline->SetColorBackground('mintOdd');
    } else {
        $sparkline->SetColorBackground('white');
    }
    $sparkline->SetYMin(0);
    $sparkline->SetPadding(0);
    $sparkline->SetColorHtml("sparkLine", $graphColor);
    $j = 0;
    for ($i = sizeof($values); $i >= 0; $i--) {
        $sparkline->SetData($j++, $values[$i]);
    }
    $sparkline->Render(75, 25);
    $sparkline->Output();
} else {
    require_once dirname(__FILE__) . '/lib/Sparkline_Bar.php';
    $sparkline = new Sparkline_Bar();
    if ($isDebug) {
        $sparkline->SetDebugLevel(DEBUG_ERROR | DEBUG_WARNING | DEBUG_STATS | DEBUG_CALLS | DEBUG_SET, 'log.txt');
    } else {
        $sparkline->SetDebugLevel(DEBUG_NONE);
    }
    if ($is_odd) {
        $sparkline->SetColorHtml('mintOdd', '#F0F7E2');
        $sparkline->SetColorBackground('mintOdd');
    } else {
        $sparkline->SetColorBackground('white');
    }
    $sparkline->SetBarWidth($bar_width);
    $sparkline->SetBarSpacing(1);
    $sparkline->SetColorHtml("shaungreen", $graphColor);
    $sparkline->SetBarColorDefault('shaungreen');
Example #6
0
        $score = 0.5;
    } elseif ($vote == $whip) {
        $score = 0;
    } elseif ($vote != $whip) {
        $score = 1;
    }
    #    print $score . "-";
    #    print_r($row);
    #    print "<br>";
    $data[] = $score;
    #    $personid = $row['person'];
    #    $division = intval($row['distance_a'] * floatval($divisions));
    #    if ($division == $divisions)
    #        $division--;
    #    $data[$division]++;
}
#print_r($data);
// Draw bar
header("Content-Type: image/png");
require_once 'sparkline/lib/Sparkline_Bar.php';
$sparkline = new Sparkline_Bar();
$sparkline->SetDebugLevel(DEBUG_NONE);
//$sparkline->SetDebugLevel(DEBUG_ERROR | DEBUG_WARNING | DEBUG_STATS | DEBUG_CALLS, '../log.txt');
$sparkline->SetBarWidth(2);
$sparkline->SetBarSpacing(1);
while (list($k, $v) = each($data)) {
    $sparkline->SetData($k, $v, 'black');
}
$sparkline->Render(16);
// height only for Sparkline_Bar
$sparkline->Output();