/** * Line style */ public function testChls() { $data = new GoogleChartData(array()); $this->assertEquals($data->computeChls(), $data->getThickness()); $data->setThickness(5); $this->assertEquals($data->getThickness(), '5'); $this->assertEquals($data->computeChls(), '5'); $data->setDash(2); $this->assertEquals($data->computeChls(), '5,2'); $data->setDash(2, 3); $this->assertEquals($data->computeChls(), '5,2,3'); $data->setDash(null, 3); $this->assertEquals($data->computeChls(), '5'); $data = new GoogleChartData(array()); $data->setDash(2, 3); $this->assertEquals($data->computeChls(), '2,2,3'); }
static function renderChart(&$params) { // get data $db = JFactory::getDBO(); $value_data = array(); $history = intval($params->get('history', 7)); // currently active users $query = 'select count(tdate) as unique_visitors, tdate from (SELECT date(timestamp) as tdate from #__rokuserstats WHERE timestamp >= date_sub(curdate(),interval ' . $history . ' day) group by ip, user_id, tdate order by tdate) as foo group by tdate'; $db->setQuery($query); $data = $db->loadObjectList(); if (is_array($data)) { foreach ($data as $row) { $value_data[] = $row->unique_visitors; } } if (empty($value_data)) { $value_data[] = 0; } $max = max($value_data); require_once 'googlechartlib/GoogleChart.php'; $chart = new GoogleChart('lc', $params->get('width', 285), $params->get('height', 120)); $chart->setTitle(JTEXT::sprintf('MC_RUC_TITLE', intval($history))); $chart->setTitleColor('666666')->setTitleSize(13); $data = new GoogleChartData($value_data); $data->setColor('4F9BD8'); $data->setThickness(2); $chart->addData($data); $y_axis = new GoogleChartAxis('y'); $y_axis->setRange(0, $max); $y_axis->setTickMarks(2); $x_axis = new GoogleChartAxis('x'); $x_axis->setRange(0, count($value_data) - 1); $x_axis->setTickMarks(2); $chart->addAxis($y_axis); $chart->addAxis($x_axis); return $chart->toHtml(); }
$line->setColor('000000'); $line->setThickness(3); $line->setFill('eeeeee'); $chart->addData($line); $m = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); $m->setData($line); $m->setColor('000000'); $m->setSize(7); $m->setBorder(2); $chart->addMarker($m); $values = array_fill(0, sizeof($values) - 2, null); $values[] = 44; $values[] = 34; $line2 = new GoogleChartData($values); $line2->setColor('000000'); $line2->setThickness(3); $line2->setDash(4, 2); $line2->setFill('eeeeee'); $chart->addData($line2); $m = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); $m->setData($line2); $m->setColor('ffffff'); $m->setSize(4); $m->setBorder(4, '000000'); $m->setPoints(-1); $chart->addMarker($m); $y_axis = new GoogleChartAxis('y'); $y_axis->setDrawLine(false); $y_axis->setDrawTickMarks(false); $y_axis->setLabels(array(null, 35, 70)); $y_axis->setFontSize(9);
$chart->setGridLines(25, 50, 1, 1); $chart->setMargin(30, 50); $chart->setLegendSize(100, 10); $chart->setFill('333333'); $chart->setFill('444444', GoogleChart::CHART_AREA); $chart->setTitle('Sinus & Cosinus'); $chart->setTitleColor('FFFFFF'); $chart->setTitleSize(18); $sin = new GoogleChartData($sin); $sin->setLegend('Sinus'); $sin->setThickness(2); $sin->setColor('D1F2A5'); $chart->addData($sin); $cos = new GoogleChartData($cos); $cos->setLegend('Cosinus'); $cos->setThickness(2); $cos->setColor('F56991'); $chart->addData($cos); $y_axis = new GoogleChartAxis('y'); $y_axis->setDrawLine(false); $y_axis->setRange(-1, 1); $y_axis->setLabelColor('ffffff'); $chart->addAxis($y_axis); $x_axis = new GoogleChartAxis('x'); $x_axis->setDrawLine(false); $x_axis->setRange(0, 360); $x_axis->setLabels(array(0, 90, 180, 270, 360)); $x_axis->setLabelColor('ffffff'); $chart->addAxis($x_axis); if (isset($_GET['debug'])) { var_dump($chart->getQuery());
<?php /** * This chart could use the undocumented parameter "lfi". * See http://cse-mjmcl.cse.bris.ac.uk/blog/2007/12/23/1198436217875.html */ require '../lib/GoogleChart.php'; $values = array(34, 18, 21, 70, 53, 39, 39, 30, 13, 15, 4, 8, 5, 8, 4, 8, 44, 16, 16, 3, 10, 7, 5, 20, 20, 28, 44); $chart = new GoogleChart('ls', 75, 30); $data = new GoogleChartData($values); $data->setThickness(1); $data->setColor('0077CC'); $data->setFill('E6F2FA'); $chart->addData($data); if (isset($_GET['debug'])) { var_dump($chart->getQuery()); echo $chart->validate(); echo $chart->toHtml(); } else { header('Content-Type: image/png'); echo $chart; }
function sparklines() { $values = array(34, 18, 21, 70, 53, 39, 39, 30, 13, 15, 24, 78, 85, 88, 74, 98, 44, 16, 16, 33, 50, 47, 55, 20, 20, 28, 44); $chart = new GoogleChart('ls', 75, 30); $chart->setFill('73A2BD'); $data = new GoogleChartData($values); $data->setThickness(1); $data->setColor('C02942'); $data->setFill('D95B43'); $chart->addData($data); return $chart->getUrl(); }