rekalogika / analytics-frontend
Transforms analytical query results into pivot tables, charts, and spreadsheets.
Package info
github.com/rekalogika/analytics-frontend
Type:package
pkg:composer/rekalogika/analytics-frontend
Fund package maintenance!
Requires
- php: ^8.2
- doctrine/collections: ^2.2 || ^3.0
- ozdemirburak/iris: ^3.1
- phpoffice/phpspreadsheet: ^4.0 || ^5.0
- rekalogika/analytics-core: ^0.40
- symfony/translation: ^6.4 || ^7.0 || ^8.0
- symfony/translation-contracts: ^3
- symfony/ux-chartjs: ^2.23 || ^3.0
- twig/twig: ^3.15 || ^4.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-04 12:01:54 UTC
README
Renders the query results of Rekalogika Analytics as pivot tables, charts, and spreadsheets.
Warning
This package is still in development and not yet ready for production use. The API is subject to change.
What's Inside
TableRenderer. Renders a result as an HTML pivot table or a flat table, using a customizable Twig theme. A plain theme and a Bootstrap 5 theme are included.ChartGenerator. Creates a Symfony UX Chart.js chart from a result, choosing a suitable chart type automatically, or using the one you specify.SpreadsheetRenderer. Converts a result into a PhpSpreadsheetSpreadsheet, which you can save as XLSX or other formats.PredicateRenderer. Renders the active filters of a query in a human-readable form.- Formatters. Extensible
Stringifier,Htmlifier,Numberifier, andCellifierservices that convert dimension members and measure values into their output representations, plus theanalytics_to_htmlandanalytics_to_stringTwig filters.
Installation
composer require rekalogika/analytics-frontend
If rekalogika/analytics-bundle
is installed, the services are registered automatically.
Usage
use Rekalogika\Analytics\Contracts\SummaryManager; use Rekalogika\Analytics\Frontend\Chart\ChartGenerator; use Rekalogika\Analytics\Frontend\Html\TableRenderer; use Rekalogika\Analytics\Frontend\Spreadsheet\SpreadsheetRenderer; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; /** * @var SummaryManager $summaryManager * @var TableRenderer $tableRenderer * @var ChartGenerator $chartGenerator * @var SpreadsheetRenderer $spreadsheetRenderer */ $cube = $summaryManager ->createQuery() ->from(OrderSummary::class) ->withDimensions('time.civil.year', 'customerCountry') ->getResult(); // HTML pivot table, with years as rows, and countries and measures as columns $html = $tableRenderer->renderPivotTable( cube: $cube, measures: ['price', 'count'], rows: ['time.civil.year'], columns: ['customerCountry', '@values'], ); // Chart.js chart, render it in Twig using render_chart() $chart = $chartGenerator->createChart( cube: $cube, dimensions: ['time.civil.year', 'customerCountry'], measures: ['price'], ); // spreadsheet $spreadsheet = $spreadsheetRenderer->render( cell: $cube, dimensions: ['time.civil.year', 'customerCountry'], measures: ['price', 'count'], ); (new Xlsx($spreadsheet))->save('orders.xlsx');
@values is a pseudo-dimension representing the measures. Its position
determines where the measures are laid out in the pivot table.
Documentation
License
MIT
Contributing
This framework consists of multiple repositories split from a monorepo. Be
sure to submit issues and pull requests to the
rekalogika/analytics monorepo.