本文整理汇总了PHP中Piwik\DataTable\Row::addColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP Row::addColumn方法的具体用法?PHP Row::addColumn怎么用?PHP Row::addColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\DataTable\Row
的用法示例。
在下文中一共展示了Row::addColumn方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_getColumn_shouldPassRowToCallable
public function test_getColumn_shouldPassRowToCallable()
{
$callbackRow = null;
$this->row->addColumn('testClosure', function (Row $row) use(&$callbackRow) {
$callbackRow = $row;
return $row;
});
$returnedRow = $this->row->getColumn('testClosure');
$this->assertNotEmpty($callbackRow);
$this->assertSame($returnedRow, $callbackRow);
}
示例2: tryToAddColumn
private function tryToAddColumn(Row $row, $column, $callable)
{
try {
$row->addColumn($column, $callable);
} catch (\Exception $e) {
}
}
示例3: getMultiRowEvolution
/** Get row evolution for a multiple labels */
private function getMultiRowEvolution(DataTable\Map $dataTable, $metadata, $apiModule, $apiAction, $labels, $column, $legendAppendMetric = true, $labelUseAbsoluteUrl = true)
{
if (!isset($metadata['metrics'][$column])) {
// invalid column => use the first one that's available
$metrics = array_keys($metadata['metrics']);
$column = reset($metrics);
}
// get the processed label and logo (if any) for every requested label
$actualLabels = $logos = array();
foreach ($labels as $labelIdx => $label) {
foreach ($dataTable->getDataTables() as $table) {
$labelRow = $this->getRowEvolutionRowFromLabelIdx($table, $labelIdx);
if ($labelRow) {
$actualLabels[$labelIdx] = $this->getRowUrlForEvolutionLabel($labelRow, $apiModule, $apiAction, $labelUseAbsoluteUrl);
$logos[$labelIdx] = $labelRow->getMetadata('logo');
if (!empty($actualLabels[$labelIdx])) {
break;
}
}
}
if (empty($actualLabels[$labelIdx])) {
$actualLabels[$labelIdx] = $this->cleanOriginalLabel($label);
}
}
// convert rows to be array($column.'_'.$labelIdx => $value) as opposed to
// array('label' => $label, 'column' => $value).
$dataTableMulti = $dataTable->getEmptyClone();
foreach ($dataTable->getDataTables() as $tableLabel => $table) {
$newRow = new Row();
foreach ($labels as $labelIdx => $label) {
$row = $this->getRowEvolutionRowFromLabelIdx($table, $labelIdx);
$value = 0;
if ($row) {
$value = $row->getColumn($column);
$value = floatVal(str_replace(',', '.', $value));
}
if ($value == '') {
$value = 0;
}
$newLabel = $column . '_' . (int) $labelIdx;
$newRow->addColumn($newLabel, $value);
}
$newTable = $table->getEmptyClone();
if (!empty($labels)) {
// only add a row if the row has data (no labels === no data)
$newTable->addRow($newRow);
}
$dataTableMulti->addTable($newTable, $tableLabel);
}
// the available metrics for the report are returned as metadata / columns
$metadata['columns'] = $metadata['metrics'];
// metadata / metrics should document the rows that are compared
// this way, UI code can be reused
$metadata['metrics'] = array();
foreach ($actualLabels as $labelIndex => $label) {
if ($legendAppendMetric) {
$label .= ' (' . $metadata['columns'][$column] . ')';
}
$metricName = $column . '_' . $labelIndex;
$metadata['metrics'][$metricName] = SafeDecodeLabel::decodeLabelSafe($label);
if (!empty($logos[$labelIndex])) {
$metadata['logos'][$metricName] = $logos[$labelIndex];
}
}
$this->enhanceRowEvolutionMetaData($metadata, $dataTableMulti);
return array('column' => $column, 'reportData' => $dataTableMulti, 'metadata' => $metadata);
}
示例4: addColumn
private function addColumn(Row $row, $columnName, $callback)
{
$this->expectedColumns[$columnName] = true;
$row->addColumn($columnName, $callback);
}
示例5: processTableFormat
/**
* Convert a dimension-less report to a multi-row two-column data table
*
* @static
* @param $reportMetadata array
* @param $report DataTable
* @param $reportColumns array
* @return array DataTable $report & array $columns
*/
protected static function processTableFormat($reportMetadata, $report, $reportColumns)
{
$finalReport = $report;
if (empty($reportMetadata['dimension'])) {
$simpleReportMetrics = $report->getFirstRow();
if ($simpleReportMetrics) {
$finalReport = new Simple();
foreach ($simpleReportMetrics->getColumns() as $metricId => $metric) {
$newRow = new Row();
$newRow->addColumn("label", $reportColumns[$metricId]);
$newRow->addColumn("value", $metric);
$finalReport->addRow($newRow);
}
}
$reportColumns = array('label' => Piwik::translate('General_Name'), 'value' => Piwik::translate('General_Value'));
}
return array($finalReport, $reportColumns);
}