icons
8 years ago
markers
8 years ago
GoogleChart.php
8 years ago
GoogleChartApi.php
8 years ago
GoogleChartAxis.php
8 years ago
GoogleChartData.php
8 years ago
GoogleChartIcon.php
8 years ago
GoogleChartMarker.php
8 years ago
LICENSE
8 years ago
GoogleChartMarker.php
100 lines
| 1 | <?php |
| 2 | |
| 3 | /** @file |
| 4 | * This file is part of Google Chart PHP library. |
| 5 | * |
| 6 | * Copyright (c) 2010 Rémi Lanvin <remi@cloudconnected.fr> |
| 7 | * |
| 8 | * Licensed under the MIT license. |
| 9 | * |
| 10 | * For the full copyright and license information, please view the LICENSE file. |
| 11 | */ |
| 12 | |
| 13 | /** |
| 14 | * A Marker. |
| 15 | * |
| 16 | * This in an abstract class that is used by all the Markers type. |
| 17 | * |
| 18 | * Marker implementation in Google Chart API is quite complex. There are many types |
| 19 | * of markers (value, line, shape, candlestick and range) and each has a |
| 20 | * different set of parameter and a slightly different logic. So each type has |
| 21 | * its own class, that extends GoogleChartMarker. |
| 22 | * |
| 23 | * To display a marker, you need to set a data serie using setData() function. |
| 24 | * A data serie is a GoogleChartData object. It contains points used by the |
| 25 | * marker. You can provides an existing data serie (i.e. a data serie that has been |
| 26 | * or will be added to the chart with GoogleChart::addData()) or a new data serie. |
| 27 | * In this case, the data serie will be hidden. Please refer to Google Chart API |
| 28 | * documentation about compound chart for further information. |
| 29 | */ |
| 30 | abstract class GoogleChartMarker |
| 31 | { |
| 32 | /** |
| 33 | * @var GoogleChartData Will hold the data serie. |
| 34 | */ |
| 35 | protected $data = null; |
| 36 | |
| 37 | /** |
| 38 | * @name Common parameters to every markers |
| 39 | */ |
| 40 | //@{ |
| 41 | /** |
| 42 | * @var string Color of the marker |
| 43 | */ |
| 44 | protected $color = '4D89F9'; |
| 45 | |
| 46 | /** |
| 47 | * @var float Z-order of the marker |
| 48 | */ |
| 49 | protected $z_order = null; |
| 50 | //@} |
| 51 | |
| 52 | /** |
| 53 | * Set the color of the marker. |
| 54 | * |
| 55 | * @param $color (string) |
| 56 | */ |
| 57 | public function setColor($color) |
| 58 | { |
| 59 | $this->color = $color; |
| 60 | return $this; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Return the color. |
| 65 | * |
| 66 | * @return string |
| 67 | */ |
| 68 | public function getColor() |
| 69 | { |
| 70 | return $this->color; |
| 71 | } |
| 72 | |
| 73 | public function setZOrder($z_order) |
| 74 | { |
| 75 | if ( $z_order < -1 || $z_order > 1 ) |
| 76 | throw new InvalidArgumentException('Invalid Z-order (must be between -1.0 and 1.0)'); |
| 77 | |
| 78 | $this->z_order = $z_order; |
| 79 | return $this; |
| 80 | } |
| 81 | |
| 82 | public function getZOrder($z_order) |
| 83 | { |
| 84 | return $this->z_order; |
| 85 | } |
| 86 | |
| 87 | public function setData(GoogleChartData $data) |
| 88 | { |
| 89 | $this->data = $data; |
| 90 | return $this; |
| 91 | } |
| 92 | |
| 93 | public function getData() |
| 94 | { |
| 95 | return $this->data; |
| 96 | } |
| 97 | |
| 98 | abstract public function compute($index, $chart_type = null); |
| 99 | } |
| 100 |