Skip to content

Commit

Permalink
refs #1816 display tooltip which explains percentage value in detail
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Nov 20, 2013
1 parent 4793bc7 commit bb0e02d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugins/CoreHome/templates/_dataTableCell.twig
Expand Up @@ -21,7 +21,16 @@
{% endif %}
{% if row.getMetadata(tooltipIndex) %}</span>{% endif %}
{% set totals = dataTable.getMetadata('totals') %}
{% if column in totals|keys and totals[column] -%}
<span class="ratio">&nbsp;{{ row.getColumn(column)|percentage(totals[column], 1) }}</span>
{% if column in totals|keys -%}
{% set rowPercentage = row.getColumn(column)|percentage(totals[column], 1) %}
{% set totalValue = siteSummary.getFirstRow.getColumn(column) %}

{% if totalValue %}
{% set totalPercentage = row.getColumn(column)|percentage(totalValue, 1) %}
{% set secondPartOfTooltip = ['This is ', totalPercentage, ' of all ', totalValue, ' ', translations[column]|default(column)]|join %}
{% else %}
{% set secondPartOfTooltip = '' %}
{% endif %}
<span class="ratio" title="'{{ row.getColumn(columns_to_display|first)|e('html_attr') }}' represents {{ rowPercentage|e('html_attr') }} of {{ totals[column]|e('html_attr') }} with {{ translations[columns_to_display|first]|default(columns_to_display|first)|e('html_attr') }}. {{ secondPartOfTooltip }}">&nbsp;{{ rowPercentage }}</span>
{%- endif %}
{% endspaceless %}
13 changes: 13 additions & 0 deletions plugins/CoreVisualizations/Visualizations/HtmlTable.php
Expand Up @@ -12,6 +12,9 @@

use Piwik\Plugin\Visualization;
use Piwik\View;
use Piwik\Common;
use Piwik\Period;
use Piwik\API\Request as ApiRequest;

/**
* DataTable visualization that shows DataTable data in an HTML table.
Expand Down Expand Up @@ -42,6 +45,16 @@ public function beforeRender()

$this->config->show_visualization_only = true;
}

// we do not want to get a datatable\map
$period = Common::getRequestVar('period', 'day', 'string');
if (Period\Range::parseDateRange($period)) {
$period = 'range';
}

$request = new ApiRequest(array('method' => 'API.get', 'module' => 'API', 'format' => 'original', 'period' => $period));

$this->assignTemplateVar('siteSummary', $request->process());
}

}

0 comments on commit bb0e02d

Please sign in to comment.