/** * Sets the baseline for the axis. * * This option is only supported for a continuous axis. * * @param mixed Must match type defined for the column, [ number | jsDate ]. * @return \Axis */ public function baseline($baseline) { if (Helpers::is_jsDate($baseline)) { $this->baseline = $baseline->toString(); } else { if (is_int($baseline)) { $this->baseline = $baseline; } else { $this->type_error(__FUNCTION__, 'int | jsDate', '; int if column is "number", jsDate if column is "date"'); } } return $this; }
/** * Add a row to the DataTable * * Each cell in the table is described by an array with the following properties: * * v [Optional] The cell value. The data type should match the column data type. * If null, the whole object should be empty and have neither v nor f properties. * * f [Optional] A string version of the v value, formatted for display. The * values should match, so if you specify Date(2008, 0, 1) for v, you should * specify "January 1, 2008" or some such string for this property. This value * is not checked against the v value. The visualization will not use this value * for calculation, only as a label for display. If omitted, a string version * of v will be used. * * p [Optional] An object that is a map of custom values applied to the cell. * These values can be of any JavaScript type. If your visualization supports * any cell-level properties, it will describe them; otherwise, this property * will be ignored. Example: p:{style: 'border: 1px solid green;'}. * * * Cells in the row array should be in the same order as their column descriptions * in cols. To indicate a null cell, you can specify null, leave a blank for * a cell in an array, or omit trailing array members. So, to indicate a row * with null for the first two cells, you would specify [null, null, {cell_val}]. * * @see \DataCell * @param mixed $opt_cell Array of values or DataCells. * @return \DataTable */ public function addRow($opt_cellArray = NULL) { $props = array('v', 'f', 'p'); if (is_null($opt_cellArray)) { for ($a = 0; $a < count($this->cols); $a++) { $tmp[] = array('v' => NULL); } $this->rows[] = array('c' => $tmp); } else { if (is_array($opt_cellArray)) { if (Helpers::array_is_multi($opt_cellArray)) { foreach ($opt_cellArray as $prop => $value) { if (in_array($prop, $props)) { $rowVals[] = array($prop => $value); } else { $this->error('Invalid row property, array with keys type (string) with values [ v | f | p ] '); } } $this->rows[] = array('c' => $rowVals); } else { if (count($opt_cellArray) <= count($this->cols)) { for ($b = 0; $b < count($this->cols); $b++) { if (isset($opt_cellArray[$b])) { if (Helpers::is_jsDate($opt_cellArray[$b])) { $rowVals[] = array('v' => $opt_cellArray[$b]->toString()); } else { $rowVals[] = array('v' => $opt_cellArray[$b]); } } else { $rowVals[] = array('v' => NULL); } } $this->rows[] = array('c' => $rowVals); } else { $msg = 'Invalid number of cells, must be equal or less than number of columns. '; $msg .= '(cells ' . count($opt_cellArray) . ' > cols ' . count($this->cols) . ')'; $this->error($msg); } } } else { $this->error('Invalid row definition, must be type (array)'); } } return $this; }