matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.85k stars 2.65k forks source link

pdf report: Render unique visitors graph in Visits Summary #8424

Open Fensterbank opened 9 years ago

Fensterbank commented 9 years ago

In the statistics section "Visits Summary" of a generated pdf report the unique visits are displayed in the table, but not in the graph. Only the amount of visits are contained in the graph.

It would be great, if the unique visits will be included in the graph as a particular line, like in my example picture:

piwik_pdf_report

kiber-io commented 3 years ago

Hello. I don't know why no one has done this for so many years, but I found a method for adding this indicator to the chart (and any other available ones). This is most likely the wrong approach, but it works :) Actually, you only need to add one line

$response['metadata']['imageGraphUrl'] .= '&columns=nb_visits,nb_uniq_visitors';

at the end of the method

enrichProcessedReportIfVisitsSummaryExtendGet(&$response, $infos)

in file

../plugins/VisitsSummary/VisitsSummary.php

You can see what it looks like in my mini-plugin

diosmosis commented 3 years ago

Hi @kiber-io, thanks for figuring this out! If this works correctly (I haven't actually tested it), would you be willing to create a pull request for it? I believe the proper place to change the imageGraphUrl property would be in the plugins/VisitsSummary/Reports/Get.php file by adding the following method:

protected function buildReportMetadata()
{
    $reportMetadata = parent::buildReportMetadata();
    $reportMetadata['imageGraphUrl'] = // ...
    return $reportMetadata;
}

That should have the same effect (again, I haven't tested, just looked at the code a bit).

kiber-io commented 3 years ago

That should have the same effect

Unfortunately, no, at this stage the required key is not in the array изображение

kiber-io commented 3 years ago

would you be willing to create a pull request for it?

I didn't do this, because it's hardcore and not everyone needs this indicator in the report