Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2020-01-03 05:30:23 +0300
committerGitHub <noreply@github.com>2020-01-03 05:30:23 +0300
commit3f760fec68332962b3647167df18317fc759482d (patch)
tree64c1991fb81590a7aa12bf7f5843416e191b227d /plugins/CoreVisualizations/templates
parent7a371a057a46f4fc0ec3ead1c4c9b394aa542a40 (diff)
Compute row percentages in PHP before metrics are formatted to avoid percentage formatting WARNINGS. (#15304)
* Compute row percentages in PHP before metrics are formatted to avoid percentage formatting WARNINGS. * do not fail if site summary is not available * Make sure siteSummary requests total data without segment. * Make sure proper precision is used. * try to fix tests * update expected screenshots
Diffstat (limited to 'plugins/CoreVisualizations/templates')
-rw-r--r--plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_comparisons.twig1
-rw-r--r--plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_ratio.twig29
2 files changed, 22 insertions, 8 deletions
diff --git a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_comparisons.twig b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_comparisons.twig
index 3ad571d9aa..b8f9356bc8 100644
--- a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_comparisons.twig
+++ b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_comparisons.twig
@@ -67,7 +67,6 @@
'totals': rowComparisonTotals,
'label': comparedRow.getColumn('label'),
'labelColumn': properties.columns_to_display|first,
- 'changePercantage': columnChange,
'forceZero': true,
'tooltipSuffix': comparisonTooltipSuffix,
'translations': properties.translations,
diff --git a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_ratio.twig b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_ratio.twig
index 8d14bb126d..a478c23bf8 100644
--- a/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_ratio.twig
+++ b/plugins/CoreVisualizations/templates/_dataTableViz_htmlTable_ratio.twig
@@ -1,20 +1,35 @@
{% if column in properties.report_ratio_columns and (column in totals|keys or forceZero|default) -%}
{% set reportTotal = totals[column]|default(0) %}
- {% if siteTotalRow|default is not empty %}
+
+ {% if siteTotalRow is defined and siteTotalRow is not empty %}
{% set siteTotal = siteTotalRow.getColumn(column) %}
- {% elseif siteSummary is defined and siteSummary is not empty and siteSummary.getFirstRow %}
- {% set siteTotal = siteSummary.getFirstRow.getColumn(column) %}
{% else %}
{% set siteTotal = 0 %}
{% endif %}
- {% set rowPercentage = row.getColumn(column)|percentage(reportTotal, 1) %}
+ {% if rowPercentage|default is empty %}
+ {% if row.getMetadata(column ~ '_row_percentage') != false %}
+ {% set rowPercentage = row.getMetadata(column ~ '_row_percentage') %}
+ {% elseif row.getColumn(column)|default(0) is numeric and reportTotal is numeric %}
+ {% set rowPercentage = row.getColumn(column)|percentage(reportTotal, 1) %}
+ {% else %}
+ {% set rowPercentage = '' %} {# should not happen #}
+ {% endif %}
+ {% endif %}
+
{% set metricTitle = translations[column]|default(column) %}
{% set reportRatioTooltip = 'General_ReportRatioTooltip'|translate(label, rowPercentage|e('html_attr'), reportTotal|e('html_attr'), metricTitle|e('html_attr'), '"' ~ segmentTitlePretty ~ '"', translations[labelColumn]|default(labelColumn)|e('html_attr')) %}
- {% if siteTotal and siteTotal > reportTotal %}
- {% set totalPercentage = row.getColumn(column)|percentage(siteTotal, 1) %}
+ {% if totalPercentage|default is empty %}
+ {% if row.getMetadata(column ~ '_site_total_percentage') != false %}
+ {% set totalPercentage = row.getMetadata(column ~ '_site_total_percentage') %}
+ {% elseif row.getColumn(column)|default(0) is numeric and siteTotal is numeric %}
+ {% set totalPercentage = row.getColumn(column)|percentage(siteTotal, 1) %}
+ {% endif %}
+ {% endif %}
+
+ {% if totalPercentage|default is not empty %}
{% set totalRatioTooltip = 'General_TotalRatioTooltip'|translate(totalPercentage, siteTotal|number(2,0), metricTitle, periodTitlePretty) %}
{% else %}
{% set totalRatioTooltip = '' %}
@@ -22,5 +37,5 @@
<span class="ratio"
title="{{ reportRatioTooltip|rawSafeDecoded|raw }} {{ totalRatioTooltip|rawSafeDecoded|e('html_attr') }}{% if tooltipSuffix|default is not empty %}<br/><br/> {{ tooltipSuffix|rawSafeDecoded|e('html_attr') }}{% endif %}"
- >&nbsp;{{ rowPercentage }} {% if changePercantage|default is not empty %}({{ changePercentage }}){% endif %}</span>
+ >&nbsp;{{ rowPercentage }} {% if changePercentage|default is not empty %}({{ changePercentage }}){% endif %}</span>
{%- endif %}