/** * Builds the configOptions object. * * Passing an array of key value pairs will set the configuration for each * child object created from this master object. * * @param array Array of options. * @return \configOptions */ public function __construct($config) { $this->className = Helpers::get_real_class($this); if (is_array($config)) { foreach ($config as $option => $value) { if (in_array($option, $this->options)) { $this->{$option}($value); } else { $this->error('Ignoring "' . $option . '", not a valid configuration option.'); } } } else { $this->type_error($this->className . '()', 'array', 'with valid keys as ' . Helpers::array_string($this->options)); } return $this; }
/** * Position of the axis text, relative to the chart area. * Supported values: 'out', 'in', 'none'. * * @param string Setting the position of the text. * @return \Axis */ public function textPosition($position) { $values = array('out', 'in', 'none'); if (in_array($position, $values)) { $this->textPosition = $position; } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . Helpers::array_string($values)); } return $this; }
/** * Adds a column to the DataTable * * First signature has the following parameters: * type - A string with the data type of the values of the column. * The type can be one of the following: 'string' 'number' 'boolean' 'date' * 'datetime' 'timeofday'. * * opt_label - [Optional] A string with the label of the column. The column * label is typically displayed as part of the visualization, for example as * a column header in a table, or as a legend label in a pie chart. If not * value is specified, an empty string is assigned. * opt_id - [Optional] A string with a unique identifier for the column. If * not value is specified, an empty string is assigned. * * * @param string Describing the column data type * @param string A label for the column. (Optional) * @param string An ID for the column. (Optinal) * @return \DataTable */ public function addColumn($typeOrDescriptionArray, $opt_label = '', $opt_id = '') { $types = array('string', 'number', 'boolean', 'date', 'datetime', 'timeofday'); $descriptions = array('type', 'label', 'id', 'role', 'pattern'); switch (gettype($typeOrDescriptionArray)) { case 'array': foreach ($typeOrDescriptionArray as $key => $value) { if (array_key_exists('type', $typeOrDescriptionArray)) { if (in_array($typeOrDescriptionArray['type'], $types)) { $descArray['type'] = $typeOrDescriptionArray['type']; if (in_array($key, $descriptions)) { if ($key != 'type') { if (is_string($value)) { $descArray[$key] = $value; } else { $this->error('Invalid description array value, must be type (string).'); } } } else { $this->error('Invalid description array key value, must be type (string) with any key value ' . Helpers::array_string($descriptions)); } } else { $this->error('Invalid type, must be type (string) with the value ' . Helpers::array_string($types)); } } else { $this->error('Invalid description array, must contain (array) with at least one key type (string) value [ type ]'); } } $this->cols[] = $descArray; break; case 'string': if (in_array($typeOrDescriptionArray, $types)) { $descArray['type'] = $typeOrDescriptionArray; if (is_string($opt_label)) { $descArray['label'] = $opt_label; } else { $this->error('Invalid opt_label, must be type (string).'); } if (is_string($opt_id)) { $descArray['id'] = $opt_id; } else { $this->error('Invalid opt_id, must be type (string).'); } } else { $this->error('Invalid type, must be type (string) with the value ' . Helpers::array_string($types)); } $this->cols[] = $descArray; break; default: $this->error('Invalid type or description array, must be type (string) or (array).'); break; } return $this; }
/** * Where to place the axis titles, compared to the chart area. Supported values: * * in - Draw the axis titles inside the the chart area. * out - Draw the axis titles outside the chart area. * none - Omit the axis titles. * * @param string $position * @return \AreaChart */ public function axisTitlesPosition($position) { $values = array('in', 'out', 'none'); if (in_array($position, $values)) { $this->addOption(array('axisTitlesPosition' => $position)); } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . Helpers::array_string($values)); } return $this; }
/** * Sets The user interaction that causes the tooltip to be displayed. * * 'focus' - The tooltip will be displayed when the user hovers over an element. * 'none' - The tooltip will not be displayed. * * @param string Type of trigger, [ focus | none ]. * @return \tooltip */ public function trigger($trigger) { $values = array('focus', 'none'); if (in_array($trigger, $values)) { $this->trigger = $trigger; } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . Helpers::array_string($values)); } return $this; }
/** * Controls the curve of the lines when the line width is not zero. Can be one of the following: * * 'none' - Straight lines without curve. * 'function' - The angles of the line will be smoothed. * * @param string $curveType * @return \LineChart */ public function curveType($curveType) { $values = array('none', 'function'); if (in_array($curveType, $values)) { $this->addOption(array('curveType' => (string) $curveType)); } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . Helpers::array_string($values)); } return $this; }
/** * Sets the alignment of the legend. * * Can be one of the following: * 'start' - Aligned to the start of the area allocated for the legend. * 'center' - Centered in the area allocated for the legend. * 'end' - Aligned to the end of the area allocated for the legend. * * Start, center, and end are relative to the style -- vertical or horizontal -- of the legend. * For example, in a 'right' legend, 'start' and 'end' are at the top and bottom, respectively; * for a 'top' legend, 'start' and 'end' would be at the left and right of the area, respectively. * * The default value depends on the legend's position. For 'bottom' legends, * the default is 'center'; other legends default to 'start'. * * @param string Alignment of the legend * @return \legend */ public function alignment($alignment) { $values = array('start', 'center', 'end'); if (in_array($alignment, $values)) { $this->alignment = $alignment; } else { $this->type_error(__FUNCTION__, 'string', 'with a value of ' . Helpers::array_string($values)); } return $this; }