diff --git a/core/ViewDataTable/GenerateGraphData.php b/core/ViewDataTable/GenerateGraphData.php index 094225869ca0bb842d7d913bb3b1d09f5e1f14e5..55400aa3f78bd1c168b4da0e6f4d11427f6a7e7d 100644 --- a/core/ViewDataTable/GenerateGraphData.php +++ b/core/ViewDataTable/GenerateGraphData.php @@ -137,7 +137,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable { // derive units from column names $idSite = Piwik_Common::getRequestVar('idSite', null, 'int'); - $units = $this->guessUnitFromRequestedColumnNames($this->getColumnsToDisplay(), $idSite); + $units = $this->deriveUnitsFromRequestedColumnNames($this->getColumnsToDisplay(), $idSite); if(!empty($this->yAxisUnit)) { // force unit to the value set via $this->setAxisYUnit() @@ -150,26 +150,13 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable return $units; } - protected function guessUnitFromRequestedColumnNames($requestedColumnNames, $idSite) + protected function deriveUnitsFromRequestedColumnNames($requestedColumnNames, $idSite) { - $nameToUnit = array( - '_rate' => '%', - 'revenue' => Piwik::getCurrency($idSite), - '_time_' => 's' - ); - $units = array(); foreach($requestedColumnNames as $columnName) { - $units[$columnName] = false; - foreach($nameToUnit as $pattern => $type) - { - if(strpos($columnName, $pattern) !== false) - { - $units[$columnName] = $type; - break; - } - } + $derivedUnit = Piwik_API_API::getUnit($columnName, $idSite); + $units[$columnName] = empty($derivedUnit) ? false : $derivedUnit; } return $units; } diff --git a/lang/en.php b/lang/en.php index aa1111304ac026473e60f08b03e1e34d26e00f16..60a4ca59dd06f33c35f0d47c1dc64bd843065fb0 100644 --- a/lang/en.php +++ b/lang/en.php @@ -1528,7 +1528,8 @@ Note: this token will expire in 24 hrs.', 'PDFReports_ReportIncludeNWebsites' => 'The report will include main metrics for all websites that have at least one visit (from the %s websites currently available).', 'ImageGraph_PluginDescription' => 'Generate beautiful static PNG Graph images for any Piwik report.', 'ImageGraph_ColumnOrdinateMissing' => 'The column \'%s\' was not found in this report.', - 'RowEvolution_AvailableMetrics' => 'Metrics for', + 'RowEvolution_MetricsFor' => 'Metrics for %s', + 'RowEvolution_AvailableMetrics' => 'Available metrics', 'RowEvolution_MetricDetailsText' => 'between %s and %s, %s over the period', 'RowEvolution_Documentation' => 'Click the metrics to display them in the large evolution graph. Use shift-click to display multiple metrics at once.', 'RowEvolution_CompareRows' => 'Compare records', diff --git a/plugins/API/API.php b/plugins/API/API.php index fd635a97688f19cc945c8dec5a6f2b550c745c16..10bac75905204b4dae50c323973b168743b23f02 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -91,6 +91,48 @@ class Piwik_API_API return self::$instance; } + /** + * Derive the unit name from a column name + */ + static public function getUnit($columnName, $idSite) + { + $nameToUnit = array( + '_rate' => '%', + 'revenue' => Piwik::getCurrency($idSite), + '_time_' => 's' + ); + + foreach ($nameToUnit as $pattern => $type) + { + if (strpos($columnName, $pattern) !== false) + { + return $type; + } + } + + return ''; + } + + /** + * Is a lower value for a given column better? + */ + static public function isLowerValueBetter($columnName) + { + $lowerIsBetterPatterns = array( + 'bounce', 'exit' + ); + + foreach ($lowerIsBetterPatterns as $pattern) + { + if (strpos($columnName, $pattern) !== false) + { + return true; + } + } + + return false; + } + /** * Default translations for many core metrics. * This is used for exports with translated labels. The exports contain columns that diff --git a/plugins/CoreHome/DataTableRowAction/RowEvolution.php b/plugins/CoreHome/DataTableRowAction/RowEvolution.php index 1854c8fe21e9d6420b7e71be7eb9e77f7d7bcad2..e2a60cbb118dd99b85b4bf0f96c726752aac48da 100644 --- a/plugins/CoreHome/DataTableRowAction/RowEvolution.php +++ b/plugins/CoreHome/DataTableRowAction/RowEvolution.php @@ -120,7 +120,7 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution { $icon = $this->rowIcon ? '<img src="'.$this->rowIcon.'" alt="">' : ''; $rowLabel = str_replace('/', '<wbr>/', str_replace('&', '<wbr>&', $this->rowLabel)); - $metricsText .= ' '.$this->dimension.': '.$icon.' '.$rowLabel; + $metricsText = sprintf(Piwik_Translate('RowEvolution_MetricsFor'), $this->dimension.': '.$icon.' '.$rowLabel); $popoverTitle = $icon.' '.$rowLabel; } @@ -219,25 +219,25 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution $min = $metricData['min']; $change = $metricData['change']; - if ($max == 0 && !($this instanceof Piwik_CoreHome_DataTableAction_MultiRowEvolution)) + if ($max == 0 && !($this instanceof Piwik_CoreHome_DataTableRowAction_MultiRowEvolution)) { - // series with only 0 cause trouble in js continue; } + $lowerIsBetter = Piwik_API_API::isLowerValueBetter($metric); if (substr($change, 0, 1) == '+') { - $changeClass = 'up'; - $changeImage = 'arrow_up'; + $changeClass = $lowerIsBetter ? 'bad' : 'good'; + $changeImage = $lowerIsBetter ? 'arrow_up_red' : 'arrow_up'; } else if (substr($change, 0, 1) == '-') { - $changeClass = 'down'; - $changeImage = 'arrow_down'; + $changeClass = $lowerIsBetter ? 'good' : 'bad'; + $changeImage = $lowerIsBetter ? 'arrow_down_green' : 'arrow_down'; } else { - $changeClass = 'nochange'; + $changeClass = 'neutral'; $changeImage = false; } @@ -245,6 +245,10 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution .($changeImage ? '<img src="plugins/MultiSites/images/'.$changeImage.'.png" /> ' : '') .$change.'</span>'; + $unit = Piwik_API_API::getUnit($metric, $this->idSite); + $min .= $unit; + $max .= $unit; + $details = Piwik_Translate('RowEvolution_MetricDetailsText', array($min, $max, $change)); $color = $colors[ $i % count($colors) ]; diff --git a/plugins/CoreHome/templates/datatable.js b/plugins/CoreHome/templates/datatable.js index c4545e7e7f8c19cb881dbddfcb13b75522b88101..078185c4aa22508c50d91ce83162f4cc0d00772a 100644 --- a/plugins/CoreHome/templates/datatable.js +++ b/plugins/CoreHome/templates/datatable.js @@ -1053,7 +1053,7 @@ dataTable.prototype = { $(this).blur(); actions.hide(); - action.onActionClick(tr, e); + action.trigger(tr, e); return false; }); } diff --git a/plugins/CoreHome/templates/datatable_cell.tpl b/plugins/CoreHome/templates/datatable_cell.tpl index 53fcc68a913c87fc05b992261fcc512b0a5a56a2..453f03d1eb10540d2bc32f8dcb2a82819a72790c 100644 --- a/plugins/CoreHome/templates/datatable_cell.tpl +++ b/plugins/CoreHome/templates/datatable_cell.tpl @@ -1,3 +1,11 @@ +{if $column=='label'} + <div class="dataTableRowActions"> + {if !isset($properties.disable_row_evolution) || $properties.disable_row_evolution === false} + <a href="#" class="actionRowEvolution"><img src="themes/default/images/row_evolution.png" alt="" /></a> + {/if} + </div> +{/if} + {if !$row.idsubdatatable && $column=='label' && !empty($row.metadata.url)} <a target="_blank" href='{if !in_array(substr($row.metadata.url,0,4), array('http','ftp:'))}http://{/if}{$row.metadata.url|escape:'html'}'> {if empty($row.metadata.logo)} diff --git a/plugins/CoreHome/templates/jqplot.css b/plugins/CoreHome/templates/jqplot.css index 5942991248728e4e38e1755bbfa41d2f097823f4..81a8612558257b6e95859e05b5833c2a935bc439 100644 --- a/plugins/CoreHome/templates/jqplot.css +++ b/plugins/CoreHome/templates/jqplot.css @@ -182,11 +182,11 @@ padding-left: 15px; } -.rowevolution table.metrics td.text span.up { +.rowevolution table.metrics td.text span.good { color: green; } -.rowevolution table.metrics td.text span.down { +.rowevolution table.metrics td.text span.bad { color: red; } diff --git a/plugins/MultiSites/images/arrow_down_green.png b/plugins/MultiSites/images/arrow_down_green.png new file mode 100644 index 0000000000000000000000000000000000000000..a8d0f695d0df0d6908ddcfd2909d11353618b7f9 Binary files /dev/null and b/plugins/MultiSites/images/arrow_down_green.png differ diff --git a/plugins/MultiSites/images/arrow_up_red.png b/plugins/MultiSites/images/arrow_up_red.png new file mode 100644 index 0000000000000000000000000000000000000000..8135545c32cae0c571e754e42de1bc3622d5da5d Binary files /dev/null and b/plugins/MultiSites/images/arrow_up_red.png differ