GeezerVison is showing github.com — Treemap visualization when the Treemap Visualization plugin is active… · openmost/DataExplorer@e38da02
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: API.php +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 | use Piwik\NoAccessException; | 25 | 25 | use Piwik\Period; | 26 | 26 | use Piwik\Period\Factory as PeriodFactory; | | 27 | +use Piwik\Period\Range; | 27 | 28 | use Piwik\Piwik; | 28 | 29 | use Piwik\Plugin\Manager as PluginManager; | 29 | 30 | use Piwik\Plugins\DataExplorer\Access\ReportPermissions; | @@ -147,6 +148,20 @@ public function runVisual(int $idSite, string $period, string $date, string $def | 147 | 148 | return (new VisualQueryRunner())->runEvolution($validated, $idSite, $period, $date, $segment); | 148 | 149 | } | 149 | 150 |
| | 151 | + // a table over several periods, such as the previous and current period of a treemap's evolution colors | | 152 | + if (Period::isMultiplePeriod($date, $period)) { | | 153 | + $site = new Site($idSite); | | 154 | + $subPeriods = (new Range($period, $date, $site->getTimezone()))->getSubperiods(); | | 155 | + $map = new DataTable\Map(); | | 156 | + $map->setKeyName('date'); | | 157 | + foreach (array_slice($subPeriods, -Configuration::getRawSqlMaxPoints()) as $subPeriod) { | | 158 | + $table = $this->runVisual($idSite, $subPeriod->getLabel(), $subPeriod->getDateStart()->toString(), $definition, $segment, $idSubtable, $flat); | | 159 | + $map->addTable($table, $subPeriod->getPrettyString()); | | 160 | + } | | 161 | + | | 162 | + return $map; | | 163 | + } | | 164 | + | 150 | 165 | // the native data table of the canvas asks again on every sort, page or opened row: one run serves them | 151 | 166 | $cache = Cache::getLazyCache(); | 152 | 167 | $cacheId = 'DataExplorer_preview_' . md5(implode('|', [$idSite, $period, $date, $segment, json_encode($validated->toArray())])); | |
Collapse file Copy file name to clipboardExpand all lines: CHANGELOG.md +5Lines changed: 5 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | ## Changelog | 2 | 2 |
| | 3 | +## 6.3.0 | | 4 | + | | 5 | +- Treemap visualization when the Treemap Visualization plugin is active, for explorations, raw SQL results and saved reports. On a day, week, month or year its rectangles are colored by their evolution against the previous period. | | 6 | +- New icons for the treemap and the line chart. | | 7 | + | 3 | 8 | ## 6.2.1 | 4 | 9 |
| 5 | 10 | - A filter on a dimension stored as a code (country, device type, browser...) also matches the English name, so a report filtered by one user keeps its rows for a user reading Matomo in another language. | |
Collapse file Copy file name to clipboardExpand all lines: Configuration.php +16-3Lines changed: 16 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,12 +47,25 @@ class Configuration | 47 | 47 | * as one of its reports. Activated alone only reads the config, which keeps a plugin whose files were removed. | 48 | 48 | */ | 49 | 49 | public static function isCustomReportsAvailable(): bool | | 50 | + { | | 51 | + return self::isPluginAvailable('CustomReports'); | | 52 | + } | | 53 | + | | 54 | + /** | | 55 | + * The Treemap Visualization plugin is available: explorations and reports can be drawn as a treemap. | | 56 | + */ | | 57 | + public static function isTreemapAvailable(): bool | | 58 | + { | | 59 | + return self::isPluginAvailable('TreemapVisualization'); | | 60 | + } | | 61 | + | | 62 | + private static function isPluginAvailable(string $plugin): bool | 50 | 63 | { | 51 | 64 | $manager = \Piwik\Plugin\Manager::getInstance(); | 52 | 65 |
| 53 | | - return $manager->isPluginInstalled('CustomReports', true) | 54 | | - && $manager->isPluginActivated('CustomReports') | 55 | | - && $manager->isPluginLoaded('CustomReports'); | | 66 | + return $manager->isPluginInstalled($plugin, true) | | 67 | + && $manager->isPluginActivated($plugin) | | 68 | + && $manager->isPluginLoaded($plugin); | 56 | 69 | } | 57 | 70 |
| 58 | 71 | /** | |
Collapse file Copy file name to clipboardExpand all lines: DataExplorer.php +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -94,6 +94,7 @@ class DataExplorer extends \Piwik\Plugin | 94 | 94 | 'DataExplorer_Visualization_pie', | 95 | 95 | 'DataExplorer_Visualization_line', | 96 | 96 | 'DataExplorer_Visualization_kpicard', | | 97 | + 'DataExplorer_Visualization_treemap', | 97 | 98 | 'DataExplorer_SegmentComparison', | 98 | 99 | 'DataExplorer_Rows', | 99 | 100 | 'DataExplorer_Columns', | @@ -109,6 +110,7 @@ class DataExplorer extends \Piwik\Plugin | 109 | 110 | 'DataExplorer_RowsNotUsedByVisualization', | 110 | 111 | 'DataExplorer_KpiFirstMetricOnly', | 111 | 112 | 'DataExplorer_PieFirstMetricOnly', | | 113 | + 'DataExplorer_TreemapFirstMetricOnly', | 112 | 114 | 'DataExplorer_PanelNoSegments', | 113 | 115 | 'DataExplorer_FilterOperatorLabel', | 114 | 116 | 'DataExplorer_FilterOperator_equals', | |
Collapse file Copy file name to clipboardExpand all lines: Model/ReportDefinition.php +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,7 @@ class ReportDefinition | 32 | 32 | public const REPORT_TYPE_KPICARD = 'kpicard'; | 33 | 33 |
| 34 | 34 | // how a table report opens, its footer still offers the other views | 35 | | - public const CHARTS = ['', 'bar', 'pie']; | | 35 | + public const CHARTS = ['', 'bar', 'pie', 'treemap']; | 36 | 36 |
| 37 | 37 | // definitions saved before filter groups: every filter applies (AND) or any of them is enough (OR) | 38 | 38 | public const FILTER_MATCH_ALL = 'all'; | |
Collapse file Copy file name to clipboardExpand all lines: Reports/GetSavedReport.php +13-2Lines changed: 13 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 28 | 28 | use Piwik\ViewDataTable\Manager as ViewDataTableManager; | 29 | 29 | use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable; | 30 | 30 | use Piwik\Plugins\DataExplorer\Catalog\SiteContext; | | 31 | +use Piwik\Plugins\DataExplorer\Configuration; | 31 | 32 | use Piwik\Plugins\DataExplorer\Categories\ExploreSubcategory; | 32 | 33 | use Piwik\Plugins\DataExplorer\Categories\ManageSubcategory; | 33 | 34 | use Piwik\Plugins\DataExplorer\Dao\ReportsDao; | @@ -61,6 +62,9 @@ class GetSavedReport extends Report | 61 | 62 | /** rows of a bar or pie chart of a metric that does not add up across rows, which gets no "Others" slice */ | 62 | 63 | public const GRAPH_ROWS = 6; | 63 | 64 |
| | 65 | + /** id of the visualization of the Treemap Visualization plugin, which may not be installed */ | | 66 | + public const TREEMAP_VIEW = 'infoviz-treemap'; | | 67 | + | 64 | 68 | /** page id prefix of a report shown on a page of its own outside the Data Explorer category */ | 65 | 69 | public const OWN_PAGE_PREFIX = 'dataexplorer-report-'; | 66 | 70 |
| @@ -292,6 +296,8 @@ public function getDefaultTypeViewDataTable() | 292 | 296 | return Bar::ID; | 293 | 297 | case 'pie': | 294 | 298 | return Pie::ID; | | 299 | + case 'treemap': | | 300 | + return Configuration::isTreemapAvailable() ? self::TREEMAP_VIEW : HtmlTable::ID; | 295 | 301 | default: | 296 | 302 | return HtmlTable::ID; | 297 | 303 | } | @@ -440,15 +446,20 @@ public function configureView(ViewDataTable $view) | 440 | 446 | $view->config->show_goals = false; | 441 | 447 | $view->config->show_insights = false; | 442 | 448 | $view->config->show_table_all_columns = false; | 443 | | - $view->config->footer_icons = $this->allowedFooterIcons($view, [HtmlTable::ID, Bar::ID, Pie::ID]); | | 449 | + $views = [HtmlTable::ID, Bar::ID, Pie::ID]; | | 450 | + if (Configuration::isTreemapAvailable()) { | | 451 | + $views[] = self::TREEMAP_VIEW; | | 452 | + } | | 453 | + $view->config->footer_icons = $this->allowedFooterIcons($view, $views); | 444 | 454 |
| 445 | 455 | if ($this->isSql()) { | 446 | 456 | // the rows keep the order of the query | 447 | 457 | $view->config->enable_sort = false; | 448 | 458 | } | 449 | 459 |
| 450 | 460 | $definition = is_array($this->row['definition'] ?? null) ? $this->row['definition'] : []; | 451 | | - if (!$this->isSql() && count((array) ($definition['rows'] ?? [])) > 1) { | | 461 | + // the treemap draws the first level and opens a rectangle into the next one, a flat table has no levels | | 462 | + if (!$this->isSql() && count((array) ($definition['rows'] ?? [])) > 1 && $view::getViewDataTableId() !== self::TREEMAP_VIEW) { | 452 | 463 | $view->config->show_flatten_table = true; | 453 | 464 | // the view the report was saved with, unless the URL asks for the other one | 454 | 465 | $request = Request::fromRequest(); | |
Collapse file Copy file name to clipboardExpand all lines: Widgets/ExplorerWidget.php +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,6 +60,7 @@ public function render() | 60 | 60 | 'writable-sites' => $writableSites, | 61 | 61 | 'custom-reports' => Piwik::isUserHasWriteAccess($idSite) | 62 | 62 | && Configuration::isCustomReportsAvailable(), | | 63 | + 'treemap' => Configuration::isTreemapAvailable(), | 63 | 64 | 'setup-url' => $isSuperUser ? 'index.php?' . Url::getQueryStringFromParameters([ | 64 | 65 | 'module' => 'DataExplorer', | 65 | 66 | 'action' => 'setup', | |
Collapse file Copy file name to clipboardExpand all lines: lang/ar.json +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 85 | 85 | "Visualization_table": "جدول", | 86 | 86 | "Visualization_bar": "مخطط أعمدة", | 87 | 87 | "Visualization_pie": "مخطط دائري", | | 88 | + "Visualization_treemap": "مخطط شجري", | 88 | 89 | "Visualization_line": "مخطط خطي عبر الزمن", | 89 | 90 | "Visualization_kpicard": "بطاقة مؤشر أداء", | 90 | 91 | "SegmentComparison": "الشريحة", | | 191 | 192 | "Export": "تصدير البيانات", | 192 | 193 | "EditReport": "تعديل التقرير", | 193 | 194 | "PieFirstMetricOnly": "يعرض المخطط الدائري المقياس الأول فقط.", | | 195 | + "TreemapFirstMetricOnly": "يعرض المخطط الشجري المقياس الأول فقط.", | 194 | 196 | "PanelNoSegments": "لا يوجد مقطع محفوظ بعد. أنشئ واحدًا باستخدام محرر المقاطع في Matomo.", | 195 | 197 | "FilterOperator_ends_with": "ينتهي بـ", | 196 | 198 | "FilterConditions": "الشرط", | |
Collapse file Copy file name to clipboardExpand all lines: lang/de.json +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 85 | 85 | "Visualization_table": "Tabelle", | 86 | 86 | "Visualization_bar": "Balkendiagramm", | 87 | 87 | "Visualization_pie": "Kreisdiagramm", | | 88 | + "Visualization_treemap": "Treemap", | 88 | 89 | "Visualization_line": "Liniendiagramm über die Zeit", | 89 | 90 | "Visualization_kpicard": "KPI-Karte", | 90 | 91 | "SegmentComparison": "Segment", | | 191 | 192 | "Export": "Daten exportieren", | 192 | 193 | "EditReport": "Bericht bearbeiten", | 193 | 194 | "PieFirstMetricOnly": "Das Kreisdiagramm zeigt nur die erste Metrik.", | | 195 | + "TreemapFirstMetricOnly": "Die Treemap zeigt nur die erste Metrik.", | 194 | 196 | "PanelNoSegments": "Noch kein gespeichertes Segment. Erstellen Sie eines mit dem Segment-Editor von Matomo.", | 195 | 197 | "FilterOperator_ends_with": "endet mit", | 196 | 198 | "FilterConditions": "Bedingung", | |
Collapse file Copy file name to clipboardExpand all lines: lang/en.json +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 85 | 85 | "Visualization_table": "Table", | 86 | 86 | "Visualization_bar": "Bar chart", | 87 | 87 | "Visualization_pie": "Pie chart", | | 88 | + "Visualization_treemap": "Treemap", | 88 | 89 | "Visualization_line": "Line chart over time", | 89 | 90 | "Visualization_kpicard": "KPI card", | 90 | 91 | "SegmentComparison": "Segment", | | 191 | 192 | "Export": "Export data", | 192 | 193 | "EditReport": "Edit report", | 193 | 194 | "PieFirstMetricOnly": "The pie chart shows the first metric only.", | | 195 | + "TreemapFirstMetricOnly": "The treemap shows the first metric only.", | 194 | 196 | "PanelNoSegments": "No saved segment yet. Create one with the Matomo segment editor.", | 195 | 197 | "FilterOperator_ends_with": "ends with", | 196 | 198 | "FilterConditions": "Condition", | |
|