Search by

rekalogika / analytics-ux-panel

priyadi

User interface for modifying the parameters of a pivot table.

Package info

github.com/rekalogika/analytics-ux-panel

Homepage

Type:symfony-bundle

pkg:composer/rekalogika/analytics-ux-panel

Fund package maintenance!

priyadi

Statistics

Installs: 778

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.40.0 2026-11-04 12:00 UTC

README

A Symfony UX user interface for Rekalogika Analytics. Lets users modify the parameters of a pivot table interactively: choosing the dimensions for the rows and columns, the measures to show, and the filters to apply.

Warning

This package is still in development and not yet ready for production use. The API is subject to change.

What's Inside

  • PivotAwareQueryFactory. Creates a PivotAwareQuery from a query and the parameters submitted by the panel. A PivotAwareQuery knows which dimensions go to the rows and columns, and which measures are selected.
  • The analytics_render_control() Twig function. Renders the panel.
  • Filters. Choice, date range, and number ranges filters. The filter for each dimension is determined by FilterResolver services. Enum dimensions get a choice filter out of the box, and you can implement your own FilterResolver for other types.
  • Stimulus controllers. Drag and drop for arranging dimensions and measures, and controllers for the filters, built on SortableJS, Tom Select, flatpickr, and Tippy.js.

Requirements

  • rekalogika/analytics-bundle
  • Symfony StimulusBundle, with AssetMapper or Webpack Encore
  • Turbo, as the panel uses Turbo Frames and Turbo Streams to update the output

Installation

composer require rekalogika/analytics-ux-panel

If you don't use Symfony Flex, register the bundle manually:

// config/bundles.php
return [
    // ...
    Rekalogika\Analytics\UX\PanelBundle\RekalogikaPanelBundle::class => ['all' => true],
];

With AssetMapper, install the JavaScript dependencies:

php bin/console importmap:install

Usage

In the controller, create a PivotAwareQuery from the parameters sent by the panel, then execute it and render the result, for example using rekalogika/analytics-frontend:

use Rekalogika\Analytics\Contracts\SummaryManager;
use Rekalogika\Analytics\Frontend\Html\TableRenderer;
use Rekalogika\Analytics\UX\PanelBundle\PivotAwareQueryFactory;
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;

#[Route('/orders')]
public function orders(
    #[MapQueryParameter()] ?string $parameters,
    SummaryManager $summaryManager,
    PivotAwareQueryFactory $pivotAwareQueryFactory,
    TableRenderer $tableRenderer,
): Response {
    $parameters = json_decode($parameters ?? '[]', true);

    $query = $summaryManager->createQuery()->from(OrderSummary::class);
    $query = $pivotAwareQueryFactory->createFromParameters($query, $parameters);

    $pivotTable = $tableRenderer->renderPivotTable(
        cube: $query->getResult(),
        measures: $query->getValues(),
        rows: $query->getRows(),
        columns: $query->getColumns(),
    );

    return $this->render('orders.html.twig', [
        'query' => $query,
        'pivotTable' => $pivotTable,
    ]);
}

In the template, render the panel and a target element for the output:

{{ analytics_render_control(
    query: query,
    output: pivotTable,
    target: 'pivottable',
    urlParameter: 'parameters',
) }}

<turbo-frame id="pivottable"></turbo-frame>

When the user changes the panel, the parameters are stored in the parameters URL query parameter, and the output is updated in the pivottable element.

Documentation

rekalogika.dev/analytics

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.