/** * 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); }
/** * 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); }
/** * Prepare chart-specific options and generate URL via parent. * * @return string - fully qualified Google Charts URL * @access public */ public function getURL() { // determine minimum and maximum from series arrays $maximum = 0; $minimum = 0; foreach ($this->values as $series) { foreach ($series as $value) { if ($value > $maximum && $value != "_") { $maximum = $value; } if ($value < $minimum) { $minimum = $value; } } } // if there are no Y labels then make them from the values if (!isset($this->y_labels)) { foreach ($this->values as $series) { foreach ($series as $value) { $this->y_labels[] = $value; } } $this->y_labels = array_unique($this->y_labels); if (!in_array($minimum, $this->y_labels)) { $this->y_labels[] = $minimum; } sort($this->y_labels); } // axis information if (isset($this->x_axis) && isset($this->y_axis)) { // using axis information labels $chxl = "0:|" . implode("|", $this->x_labels) . "|2:|" . implode("|", $this->y_labels); if (isset($this->x_axis)) { $chxl .= "|1:|{$this->x_axis}"; } if (isset($this->y_axis)) { $chxl .= "|3:|{$this->y_axis}"; } $chxt = "x,x,y,y"; $chxp = "1,50|3,50"; $chxl = urlencode($chxl); } else { // no axis information labels $chxl = "0:|" . implode("|", $this->x_labels) . "|1:|" . implode("|", $this->y_labels); $chxt = "x,y"; $chxp = ""; } // create options array $options = array("chxl" => $chxl, "chxt" => $chxt, "chxp" => $chxp, "chds" => "{$minimum},{$maximum}"); // add series $options["chd"] = "t:"; foreach ($this->values as $series) { $options["chd"] .= implode(",", $series); $options["chd"] .= "|"; } $options["chd"] = rtrim($options["chd"], "|"); // add grid? if ($this->grid) { $options["chg"] = round(100 / count($this->x_labels)) . "," . round(100 / count($this->y_labels)); } // add fill? if ($this->fill) { $chm = array(); foreach ($this->values as $id => $series) { $chm[] = "B,{$this->colour_palettes[$this->palette][$id]},0,0,0"; } $options["chm"] = implode("|", $chm); $this->randomise_colours = false; } // add point markers? if ($this->markers) { $shapes = array("o", "s", "d"); $s = 0; for ($i = 0; $i < count($this->values); $i++) { $tmp[] = "{$shapes[$s]},404040,{$i},-1,5"; $s++; if ($s >= count($shapes)) { $s = 0; } } $options["chm"] = implode("|", $tmp); } // 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 horizontal is switched on if ($this->horizontal) { $this->type = "bhs"; } // set scale minimum if (min($this->values) < 0) { $minimum = min($this->values); } else { $minimum = 0; } // if there are no Y labels then make them from the values if (!isset($this->y_labels)) { $this->y_labels = array($minimum, max($this->values)); $step = ($this->y_labels[1] - $this->y_labels[0]) / 8; for ($i = $this->y_labels[0] + $step; $i < $this->y_labels[1]; $i = $i + $step) { $this->y_labels[] = round($i); } $this->y_labels = array_unique($this->y_labels); sort($this->y_labels); } // create options array $options = array("chxt" => "x,y", "chbh" => $this->barwidth, "chd" => "t:" . implode(",", $this->values), "chds" => "{$minimum}," . max($this->values)); // add data switch ($this->type) { case "bvs": $options["chxl"] = "0:|" . implode("|", $this->x_labels) . "|1:|" . implode("|", $this->y_labels); break; case "bhs": $options["chxl"] = "0:|" . implode("|", $this->y_labels) . "|1:|" . implode("|", $this->x_labels); break; } // call parent return parent::getURL($options); }