public function testChma() { $this->assertEquals($this->chart->computeChma(), ''); $this->assertEquals($this->chart->hasChma(), false); $this->chart->setLegendSize(500, 300); $this->assertEquals($this->chart->computeChma(), '|500,300'); }
public function __construct() { parent::__construct(); $this->type = new GoogleChartType(GoogleChartType::TWO_DIMENSIONAL_PIE); $this->color = GoogleChartColor::create(); $this->label = GoogleChartLabel::create(); $this->data = GoogleChartData::create()->addDataSet(GoogleChartDataSet::create())->setEncoding(GoogleChartDataTextEncoding::create()); }
protected function compute(array &$q) { if ($this->rotation) { $q['chp'] = $this->rotation; } parent::compute($q); // pie chart doesn't support data scaling. // however, i still want to compute a scale for encoding format unset($q['chds']); }
public function __construct($width, $height) { if ($width > self::MAX_WIDTH) { throw new InvalidArgumentException(sprintf('Max width for Map Chart is %d.', self::MAX_WIDTH)); } if ($height > self::MAX_HEIGHT) { throw new InvalidArgumentException(sprintf('Max height for Map Chart is %d.', self::MAX_HEIGHT)); } parent::__construct('t', $width, $height); }
/** * Prepare chart-specific options and generate URL via parent. * * @return string - fully qualified Google Charts URL * @access public */ public function getURL() { // if label arrow is missing then set it to the value if (empty($this->arrow_label)) { $this->arrow_label = $this->value; } // create options array $options = array("chd" => "t:{$this->value}", "chxt" => "x,y", "chxl" => "0:|{$this->arrow_label}|1:|" . implode("|", $this->meter_labels)); // call parent return parent::getURL($options); }
/** * Prepare chart-specific options and generate URL via parent. * * @return string - fully qualified Google Charts URL * @access public */ public function getURL() { // change the chart type if perspective is switched on if ($this->perspective) { $this->type = "p3"; } // create options array $options = array("chl" => implode("|", array_keys($this->segments)), "chd" => "t:" . implode(",", array_values($this->segments)), "chp" => $this->rotation); // call parent return parent::getURL($options); }
public function toString() { $string = parent::toString(); $string .= '&' . $this->axesCollection->toString(); if ($this->style->hasStyles()) { $string .= '&' . $this->style->toString(); } if ($this->labelStyle->hasStyles()) { $string .= '&' . $this->labelStyle->toString(); } return $string; }
/** * This function needs to do some funky stuffs with the data series, because * the chd parameter of scatter charts work quite differently. * chd=<x_values>|<y_values>[|<optional_point_sizes>] * * So basically each point must be split into 3 values, placed on 3 GoogleChartData objects. */ protected function compute(array &$q) { $old_data = $this->data; $colors = array(); // rebuild a set of 3 GoogleChartData $series_x = array(); $series_y = array(); $series_size = array(); $legends = array(); foreach ($this->data as $i => $data) { $colors[] = $data->computeChco(); $legends[] = $data->getLegend(); $data_x = array(); $data_y = array(); $data_size = array(); foreach ($data->getValues() as $d) { $data_x[] = $d[0]; $data_y[] = $d[1]; $data_size[] = isset($d[2]) ? $d[2] : 10; } $series_x[] = $data_x; $series_y[] = $data_y; $series_size[] = $data_size; } $series_x = self::interlace($series_x); $series_y = self::interlace($series_y); $series_size = self::interlace($series_size); $series_x = new GoogleChartData($series_x); $series_y = new GoogleChartData($series_y); $series_size = new GoogleChartData($series_size); $this->data = array($series_x, $series_y, $series_size); $this->setAutoScale(false); // rebuild the legends $series_x->setLegends($legends); // compute parent::compute($q); unset($q['chds']); // DEBUG $this->chco = implode('|', $colors); $this->data = $old_data; }
function display_chart($data) { //echo "data : "; var_dump($data); echo "<br />"; $i = 0; foreach ($data as $abs => $val) { //echo "$abs => $val <br />"; $abscissa[$i] = $abs; //$arr[month_to_string($res[0])] = $res[1]; $i++; } $maxval = max($data); $chart = new GoogleChart('lc', 600, 300); $chart->setScale(0, $maxval); $line = new GoogleChartData($data); $chart->addData($line); $y_axis = new GoogleChartAxis('y'); $y_axis->setDrawTickMarks(false); $y_axis->setRange(0, $maxval); // $y_axis->setLabels(array(0,10,20,30)); $chart->addAxis($y_axis); $x_axis = new GoogleChartAxis('x'); $x_axis->setTickMarks(5); $x_axis->setLabels($abscissa); $chart->addAxis($x_axis); // add a shape marker with a border $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); $shape_marker->setSize(6); $shape_marker->setBorder(2); $shape_marker->setData($line); $chart->addMarker($shape_marker); // add a value marker $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); $value_marker->setData($line); $chart->addMarker($value_marker); // var_dump($chart->getQuery()); // echo $chart->validate(); echo $chart->toHtml(); }
protected function compute(array &$q) { if (!$this->data[0]) { throw new Exception('Venn diagram needs one data series with 2 or 3 circles'); } $values = $this->data[0]->getValues(); if (!isset($values[2])) { // only 2 circles $values[2] = 0; } $values[] = $this->intersect_ab; if ($values[2] != 0) { $values[] = $this->intersect_ac; $values[] = $this->intersect_bc; $values[] = $this->intersect_abc; } $this->data[0]->setValues($values); parent::compute($q); if (isset($q['chco'])) { $q['chco'] = str_replace('|', ',', $q['chco']); } }
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(); }
/** * Create a Google Chart chart */ protected function GoogleChart() { $chart = new GoogleChart(null, $this->type); # Loop through every set data //foreach($this->data as $set) //{ $values = @implode(',', $this->data); $labels = @implode('|', $this->labels); $chart->loadData($values); $chart->setLabels($labels, 'bottom'); //} $chart->dimensions = $this->x . 'x' . $this->y; return $chart->draw(false); }
/** * Show pie chart for all of the aircraft flown * by a certain pilot. Outputs image, unless $ret == true, * then it returns the URL. */ public static function PilotAircraftFlownGraph($pilotid, $ret = false) { $stats = self::PilotAircraftFlownCounts($pilotid); if (!$stats) { return; } $data = ''; $labels = ''; foreach ($stats as $stat) { if ($stat->aircraft == '') { continue; } $data .= $stat->count . ','; $labels .= $stat->aircraft . '|'; } // remove that final lone char $data = substr($data, 0, strlen($data) - 1); $labels = substr($labels, 0, strlen($labels) - 1); $chart = new GoogleChart($data, 'pie'); $chart->dimensions = '350x200'; $chart->setLabels($labels); $url = $chart->draw(false); unset($chart); if ($ret == true) { return $url; } else { echo '<img src="' . $url . '" />'; } }
<?php // don't forget to update the path here require '../../lib/GoogleChart.php'; $chart = new GoogleChart('lc', 500, 200); // manually forcing the scale to [0,100] $chart->setScale(0, 100); // add one line $data = new GoogleChartData(array(49, 74, 78, 71, 40, 39, 35, 20, 50, 61, 45)); $chart->addData($data); // customize y axis $y_axis = new GoogleChartAxis('y'); $y_axis->setDrawTickMarks(false)->setLabels(array(0, 50, 100)); $chart->addAxis($y_axis); // customize x axis $x_axis = new GoogleChartAxis('x'); $x_axis->setTickMarks(5); $chart->addAxis($x_axis); header('Content-Type: image/png'); echo $chart;
<?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; }
<?php require '../lib/GoogleChart.php'; require '../lib/markers/GoogleChartTextMarker.php'; require '../lib/markers/GoogleChartShapeMarker.php'; $values = array(array(), array(), array()); $n = 10; for ($i = 0; $i <= $n; $i += 1) { $v = rand($i, $i * 10); $values[0][] = $v; $values[1][] = $v - $i; $values[2][] = rand(100 - ($i + 10), 100 - 10 * $i); } $chart = new GoogleChart('lc', 600, 300); $chart->setGridLines(10, 10); $chart->setLegendPosition('r'); //~ $chart->setMargin(50); $chart->setLegendSize(150, 20); $chart->setFill('ffffcc'); $chart->setGradientFill(45, array('cccccc', 'ffffff', 'cccccc'), GoogleChart::CHART_AREA); $chart->setTitle('Us versus the others.'); $chart->setTitleColor('999999')->setTitleSize(20); $line = new GoogleChartData($values[0]); $line->setLegend('Us'); $chart->addData($line); $marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::X); $marker->setData($line); $marker->setColor('6699cc'); $chart->addMarker($marker); $marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); $marker->setData($line);
$chart = new GoogleChart('lc', 180, 150); $data = new GoogleChartData(array(10, 15, 25, 30, 45, 55, 58)); $data->setLegend('Foobar'); $chart->addData($data); // no legend for this data serie $data = new GoogleChartData(array(5, 12, 28, 26, 30, 34, 32)); $data->setColor('FF0000'); $chart->addData($data); echo $chart->toHtml(); $chart = new GoogleChart('lc', 180, 150); $chart->setLegendPosition('b'); $data = new GoogleChartData(array(10, 15, 25, 30, 45, 55, 58)); $data->setLegend('Foo'); $chart->addData($data); $data = new GoogleChartData(array(5, 12, 28, 26, 30, 34, 32)); $data->setLegend('Bar'); $data->setColor('FF0000'); $chart->addData($data); echo $chart->toHtml(); $chart = new GoogleChart('lc', 180, 150); $chart->setLegendPosition('t'); $chart->setLegendSize(18); $chart->setLegendColor('336699'); $data = new GoogleChartData(array(10, 15, 25, 30, 45, 55, 58)); $data->setLegend('Foo'); $chart->addData($data); $data = new GoogleChartData(array(5, 12, 28, 26, 30, 34, 32)); $data->setLegend('Bar'); $data->setColor('FF0000'); $chart->addData($data); echo $chart->toHtml();
<?php require '../lib/GoogleChart.php'; $sin = array(); $cos = array(); for ($i = 0; $i <= 360; $i += 10) { $sin[] = round(sin($i * M_PI / 180), 2); $cos[] = round(cos($i * M_PI / 180), 2); } $chart = new GoogleChart('lc', 500, 200); $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);
<?php // don't forget to update the path here require '../../lib/GoogleChart.php'; $chart = new GoogleChart('lc', 500, 200); // add one line $data = new GoogleChartData(array(49, 74, 78, 71, 40, 39, 35, 20, 50, 61, 45)); $chart->addData($data); // we generate the image directly as a PNG header('Content-Type: image/png'); echo $chart;
<?php require '../lib/GoogleChart.php'; require '../lib/markers/GoogleChartTextMarker.php'; require '../lib/markers/GoogleChartShapeMarker.php'; $values = array(); for ($i = 0; $i <= 10; $i += 1) { $values[] = rand(20, 80); } $chart = new GoogleChart('bvs', 500, 200); $chart->setScale(0, 100); $data = new GoogleChartData($values); $chart->addData($data); $marker = new GoogleChartTextMarker(GoogleChartTextMarker::FLAG, 'Hello, world!'); $marker->setData($data); $marker->setStep(2); $chart->addMarker($marker); // a fixed position marker $marker = new GoogleChartTextMarker(GoogleChartTextMarker::TEXT, 'Here'); $marker->setFixedPosition(0.25, 1); $chart->addMarker($marker); header('Content-Type: image/png'); echo $chart;
<?php require '../lib/GoogleChart.php'; require '../lib/markers/GoogleChartShapeMarker.php'; $chart = new GoogleChart('lc', 800, 154); $chart->setAutoscale(GoogleChart::AUTOSCALE_VALUES); $chart->setGridLines(0, 50, 3, 2); $chart->setMargin(5); $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, null); $line = new GoogleChartData($values); $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);
<?php require '../lib/GoogleChart.php'; $values = array(); for ($i = 0; $i <= 10; $i += 1) { $values[] = rand(10, 100); } $chart = new GoogleChart('bvs', 500, 200); $chart->addData(new GoogleChartData($values)); $y_axis = new GoogleChartAxis('y'); $chart->addAxis($y_axis); header('Content-Type: image/png'); echo $chart;
echo "listData()"; } //listData(); //echo "<p>missing arg"; } echo "<p><a href='linechart_hour.php'>Stunden-Übersicht</a></p>"; echo "<p><a href='barchart_days.php'>Tages-Übersicht</a></p>"; echo "<p><a href='http://www.unwetterzentrale.de/uwz/getwarning_de.php?plz=41363&uwz=UWZ-DE&lang=de'>Unwetterwarnungen Jüchen</a></p>"; echo "<p><a href='bad2.php'>Bad Daten</a></p>"; echo showAllCharts(); //################################################################################# // see http://code.google.com/p/googlechartphplib/wiki/GettingStarted //################################################################################# // don't forget to update the path here require './lib/GoogleChart.php'; $chart = new GoogleChart('lc', 500, 200); // manually forcing the scale to [0,100] $chart->setScale(0, 100); // add one line $data = new GoogleChartData(array(49, 74, 78, 71, 40, 39, 35, 20, 50, 61, 45)); $chart->addData($data); // customize y axis $y_axis = new GoogleChartAxis('y'); $y_axis->setDrawTickMarks(false)->setLabels(array(0, 50, 100)); $chart->addAxis($y_axis); // customize x axis $x_axis = new GoogleChartAxis('x'); $x_axis->setTickMarks(5); $chart->addAxis($x_axis); echo $chart->toHtml(); //#################################################################################
protected function compute(array &$q) { $q['chbh'] = $this->computeChbh(); parent::compute($q); }
public function buildChart($oAnalytics) { require_once 'lib/google_chart.php'; // By Andrey Savchenko (Rarst), http://www.rarst.net/script/google-chart/ // Generating visit arrays for the date range. $visit_report = $oAnalytics->getData( array('dimensions'=>urlencode('ga:date'), 'metrics'=>urlencode('ga:visits'), )); $visits = array(); foreach($visit_report as $dimensions => $metric) { array_push($visits, $metric); } // Generating visit arrays for the date range. $views_report = $oAnalytics->getData( array('dimensions'=>urlencode('ga:date'), 'metrics'=>urlencode('ga:pageviews'), )); $page_views = array(); foreach($views_report as $dimensions => $metric) { array_push($page_views, $metric); } // Extract various dates from the report array keys in order to use them as variables for x-axis labels $days = array_keys($views_report); list($d0, $d1, $d2, $d3, $d4, $d5, $d6, $d7, $d8, $d9, $d10, $d11, $d12, $d13, $d14, $d15, $d16, $d17, $d18, $d19, $d20, $d21,$d22,$d23,$d24,$d25,$d26,$d27,$d28, $d29, $d30) = $days; // Get the keys for max. values of page views and visits if( !function_exists('max_key') ){ function max_key($array) { foreach ($array as $key => $val) { if ($val == max($array)) return $key; } } } $array = $page_views; $precord = max_key($array); $array = $visits; $vrecord = max_key($array); // Always use max. value recorded in array for y-axis $ymax = 1*(ceil(max($page_views))); // Devide it by six and round up to nearest whole number to set appropriate y-axis ticks $ytick = ceil((max($page_views))/6); // Chart settings $traffic = new GoogleChart; $traffic->type='lc'; $traffic->SetImageSize(700,200); $traffic->SetChartMargins(20,20,20,20); $traffic->SetEncode('simple'); $traffic->AddData($visits); $traffic->AddData($page_views); $traffic->AddChartColor('FF9900'); $traffic->AddChartColor('0077CC'); $traffic->AddLineStyle(3); $traffic->AddLineStyle(3); $traffic->AddFillArea('B','FF99007F',0); $traffic->AddFillArea('b','E6F2FA7F',0,1); $traffic->AddShapeMarker('o','FFFFFF',0,-1,9); $traffic->AddShapeMarker('o','FF9900',0,-1,7); $traffic->AddShapeMarker('o','FFFFFF',1,-1,9); $traffic->AddShapeMarker('o','0077CC',1,-1,7); $traffic->AddAxis('y,x'); $traffic->AddAxisRange(0,round($ymax,-3),round($ytick, -3)); $traffic->AddAxisLabel(extension_dashboard_analytics::formatDates(array($d0,$d10,$d20,$d30)),1); $traffic->SetGrid(round(100/30,2),round(100/6,2),1,3); $traffic->SetTitle('Visits and Page Views of last 30 days'); $traffic->AddLegend('visits'); $traffic->AddLegend('page views'); $traffic->SetLegendPosition('b'); // Generate chart URL $graph = new XMLElement('div', $traffic->GetImg()); $graph->setAttribute('class', 'graph'); return $graph; }
<?php require '../../lib/GoogleChart.php'; $chart = new GoogleChart('lc', 500, 200); echo $chart->toHtml();
<?php require '../lib/GoogleChart.php'; $chart = new GoogleChart('lc', 500, 200); $chart->setScale(0, 100); $line = new GoogleChartData(array(10, 12, 15, 20, 22, 50, 60, 63, 58, 75, 67, 80)); $chart->addData($line); $y_axis = new GoogleChartAxis('y'); $chart->addAxis($y_axis); $x_axis = new GoogleChartAxis('x'); $chart->addAxis($x_axis); if (isset($_GET['debug'])) { var_dump($chart->getQuery()); echo $chart->validate(); echo $chart->toHtml(); } else { header('Content-Type: image/png'); echo $chart; }
/** * Prepare chart-specific options and generate URL via parent. * * @return string - fully qualified Google Charts URL * @access public */ public function getURL() { // this chart type is pretty dependent on having some data present to do much at all if (count($this->data) == 0) { throw new Exception("No data present for scatter chart."); } // if either axis labels are absent then automatically generate them from the data if (!isset($this->x_labels)) { $this->x_labels = $this->generate_axis_labels("x"); } if (!isset($this->y_labels)) { $this->y_labels = $this->generate_axis_labels("y"); } // create options array $options = array("chxt" => "x,y", "chxl" => "0:|" . implode("|", $this->x_labels) . "|1:|" . implode("|", $this->y_labels)); // add grid? if ($this->grid) { $options["chg"] = round(100 / count($this->x_labels)) . "," . round(100 / count($this->y_labels)); } // add chart data $options["chd"] = "t:" . implode(",", $this->data["x"]) . "|" . implode(",", $this->data["y"]) . "|" . implode(",", $this->data["size"]); // use single colour? if ($this->single_colour) { if (preg_match("/[A-Fa-z0-9][A-Fa-z0-9][A-Fa-z0-9][A-Fa-z0-9][A-Fa-z0-9][A-Fa-z0-9]/", $this->single_colour)) { $this->palette = "{$this->single_colour},{$this->single_colour}"; } else { $colour = $this->colour_palettes[$this->palette][0]; $this->palette = "{$colour},{$colour}"; } } // call parent return parent::getURL($options); }
/** * Draws Chart for PDF Report. * * Draws the sales and earnings chart for the PDF report and then retrieves the * URL of that chart to display on the PDF Report. * * @since 1.1.4.0 * @uses GoogleChart * @uses GoogleChartData * @uses GoogleChartShapeMarker * @uses GoogleChartTextMarker * @uses GoogleChartAxis * @return string $chart->getUrl() URL for the Google Chart */ function give_draw_chart_image() { require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; $chart = new GoogleChart('lc', 900, 330); $i = 1; $earnings = ""; $sales = ""; while ($i <= 12) { $earnings .= give_get_earnings_by_date(null, $i, date('Y')) . ","; $sales .= give_get_sales_by_date(null, $i, date('Y')) . ","; $i++; } $earnings_array = explode(",", $earnings); $sales_array = explode(",", $sales); $i = 0; while ($i <= 11) { if (empty($sales_array[$i])) { $sales_array[$i] = 0; } $i++; } $min_earnings = 0; $max_earnings = max($earnings_array); $earnings_scale = round($max_earnings, -1); $data = new GoogleChartData(array($earnings_array[0], $earnings_array[1], $earnings_array[2], $earnings_array[3], $earnings_array[4], $earnings_array[5], $earnings_array[6], $earnings_array[7], $earnings_array[8], $earnings_array[9], $earnings_array[10], $earnings_array[11])); $data->setLegend(esc_html__('Income', 'give')); $data->setColor('1b58a3'); $chart->addData($data); $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); $shape_marker->setColor('000000'); $shape_marker->setSize(7); $shape_marker->setBorder(2); $shape_marker->setData($data); $chart->addMarker($shape_marker); $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); $value_marker->setColor('000000'); $value_marker->setData($data); $chart->addMarker($value_marker); $data = new GoogleChartData(array($sales_array[0], $sales_array[1], $sales_array[2], $sales_array[3], $sales_array[4], $sales_array[5], $sales_array[6], $sales_array[7], $sales_array[8], $sales_array[9], $sales_array[10], $sales_array[11])); $data->setLegend(esc_html__('Donations', 'give')); $data->setColor('ff6c1c'); $chart->addData($data); $chart->setTitle(esc_html__('Donations by Month for all Give Forms', 'give'), '336699', 18); $chart->setScale(0, $max_earnings); $y_axis = new GoogleChartAxis('y'); $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); $chart->addAxis($y_axis); $x_axis = new GoogleChartAxis('x'); $x_axis->setTickMarks(5); $x_axis->setLabels(array(esc_html__('Jan', 'give'), esc_html__('Feb', 'give'), esc_html__('Mar', 'give'), esc_html__('Apr', 'give'), esc_html__('May', 'give'), esc_html__('June', 'give'), esc_html__('July', 'give'), esc_html__('Aug', 'give'), esc_html__('Sept', 'give'), esc_html__('Oct', 'give'), esc_html__('Nov', 'give'), esc_html__('Dec', 'give'))); $chart->addAxis($x_axis); $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); $shape_marker->setSize(6); $shape_marker->setBorder(2); $shape_marker->setData($data); $chart->addMarker($shape_marker); $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); $value_marker->setData($data); $chart->addMarker($value_marker); return $chart->getUrl(); }
<?php require '../lib/GoogleChart.php'; require '../lib/markers/GoogleChartLineMarker.php'; require '../lib/markers/GoogleChartShapeMarker.php'; $values = array(array(), array(), array()); for ($i = 0; $i <= 10; $i += 1) { $v = rand(20, 80); $values[0][] = $v; $values[1][] = rand(0, 20); $values[2][] = $v + rand(-10, 10); } $chart = new GoogleChart('bvs', 500, 200); $chart->setScale(0, 100); $data0 = new GoogleChartData($values[0]); $chart->addData($data0); $data1 = new GoogleChartData($values[1]); $data1->setColor(array('FFC6A5', 'FFFF42', 'DEF3BD', '00A5C6', 'DEBDDE')); $chart->addData($data1); $marker = new GoogleChartLineMarker(); $marker->setData($data0); $marker->setSize(5); $marker->setPoints(5); $chart->addMarker($marker); $marker = new GoogleChartLineMarker(); $marker->setData($data0); $marker->setColor('6699cc'); $marker->setSize(5); $marker->setPoints(0, 5); $marker->setZOrder(-0.5); $chart->addMarker($marker);