diff options
Diffstat (limited to 'plugins/CoreVisualizations')
4 files changed, 15 insertions, 3 deletions
diff --git a/plugins/CoreVisualizations/Visualizations/Sparklines.php b/plugins/CoreVisualizations/Visualizations/Sparklines.php index 0407259221..82cdf959cc 100644 --- a/plugins/CoreVisualizations/Visualizations/Sparklines.php +++ b/plugins/CoreVisualizations/Visualizations/Sparklines.php @@ -63,6 +63,8 @@ class Sparklines extends ViewDataTable } } + $view->allMetricsDocumentation = Metrics::getDefaultMetricsDocumentation(); + $this->requestConfig->request_parameters_to_modify['columns'] = $columnsList; $this->requestConfig->request_parameters_to_modify['format_metrics'] = '1'; diff --git a/plugins/CoreVisualizations/Visualizations/Sparklines/Config.php b/plugins/CoreVisualizations/Visualizations/Sparklines/Config.php index 70100f6896..6557abb44b 100644 --- a/plugins/CoreVisualizations/Visualizations/Sparklines/Config.php +++ b/plugins/CoreVisualizations/Visualizations/Sparklines/Config.php @@ -204,9 +204,17 @@ class Config extends \Piwik\ViewDataTable\Config $description = array($description); } + if (!empty($requestParamsForSparkline['columns']) + && count($requestParamsForSparkline['columns']) === count($values)) { + $columns = array_values($requestParamsForSparkline['columns']); + } else { + $columns = array(); + } + if (count($values) === count($description)) { foreach ($values as $index => $value) { $metrics[] = array( + 'column' => isset($columns[$index]) ? $columns[$index] : '', 'value' => $value, 'description' => $description[$index] ); diff --git a/plugins/CoreVisualizations/templates/_dataTableViz_sparklines.twig b/plugins/CoreVisualizations/templates/_dataTableViz_sparklines.twig index cf4c655fce..b0e29cc26a 100644 --- a/plugins/CoreVisualizations/templates/_dataTableViz_sparklines.twig +++ b/plugins/CoreVisualizations/templates/_dataTableViz_sparklines.twig @@ -13,7 +13,7 @@ {% for key, sparkline in sparklines %} {% if key is even %} - {{ macros.singleSparkline(sparkline) }} + {{ macros.singleSparkline(sparkline, allMetricsDocumentation) }} {% endif %} {% endfor %} @@ -25,7 +25,7 @@ {% for key, sparkline in sparklines %} {% if key is odd %} - {{ macros.singleSparkline(sparkline) }} + {{ macros.singleSparkline(sparkline, allMetricsDocumentation) }} {% endif %} {% endfor %} diff --git a/plugins/CoreVisualizations/templates/macros.twig b/plugins/CoreVisualizations/templates/macros.twig index ffd1885be1..43d8c2158e 100644 --- a/plugins/CoreVisualizations/templates/macros.twig +++ b/plugins/CoreVisualizations/templates/macros.twig @@ -1,12 +1,14 @@ -{% macro singleSparkline(sparkline) %} +{% macro singleSparkline(sparkline, allMetricsDocumentation) %} <div class="sparkline"> {% if sparkline.url %}{{ sparkline(sparkline.url)|raw }}{% endif %} {% for metric in sparkline.metrics %} + <span {% if allMetricsDocumentation[metric.column] is defined and allMetricsDocumentation[metric.column] %}title="{{ allMetricsDocumentation[metric.column] }}"{% endif %}> {% if '%s' in metric.description -%} {{ metric.description|translate("<strong>"~metric.value~"</strong>")|raw }} {%- else %} <strong>{{ metric.value }}</strong> {{ metric.description }} {%- endif %}{% if not loop.last %}, {% endif %} + </span> {% endfor %} {% if sparkline.evolution is defined %} |