Search by

badpixxel / widgets-d3js-bundle

BadPixxel

BadPixxel Widgets D3.js Charts Integration

Package info

gitlab.com/badpixxel-public/widgets-d3-bundle

Homepage

Issues

Type:symfony-bundle

pkg:composer/badpixxel/widgets-d3js-bundle

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

3.0.x-dev 2026-11-17 12:21 UTC

This package is auto-updated.

Last update: 2026-11-17 11:21:29 UTC


README

D3.js diagrams for BadPixxel Widgets: bubble charts, force diagrams and sync flow diagrams, as widget blocks.

Features

  • Bubble Chart - Values as packed bubbles, with images & legend - docs
  • Force Diagram - Interactive networks, draggable nodes - docs
  • Sync Flow Diagram - Data exchanges between servers & a central hub, animated objects - docs
  • Shared Building Blocks - Nodes, Links Animations, Tooltips and legacy Link Presets
  • Theme Colors - Diagrams follow the Bootstrap theme & color mode, colors accept theme roles - docs
  • Translations - Controllers default labels (sync flow modes, statuses, volumes, bubble values) in English, French, Spanish, Italian, German & Dutch (BadPixxelWidgetsD3Js domain); labels set on blocks always win
  • Live Updates - Diagrams are drawn again when their widget is compiled again (e.g. new parameters)

Requirements

  • PHP 8.1+
  • Symfony 6.4, 7.4 or 8.0
  • badpixxel/widgets-bundle ^3.0
  • D3.js ^7 (installed with importmap)

Installation

composer require badpixxel/widgets-d3js-bundle
php bin/console importmap:install

The bundle is a Symfony UX package (assets/package.json): Symfony Flex declares its Stimulus controllers (bubble, force, sync-flow) in your assets/controllers.json, and its JavaScript API in your importmap.php (@badpixxel/ux-widgets-d3). No import is required to use the diagrams.

Quick Start

use BadPixxel\Widgets\Attribute\AsStaticWidget;
use BadPixxel\Widgets\D3Js\Blocks\D3SyncFlow\D3SyncFlowBlock;
use BadPixxel\Widgets\D3Js\Dictionary\D3SyncModes;
use BadPixxel\Widgets\D3Js\Model\D3SyncNode;
use BadPixxel\Widgets\Dictionary\ChartColors;
use BadPixxel\Widgets\Models\AbstractWidget;
use BadPixxel\Widgets\Widgets\Descriptor\SimpleDescriptor;

#[AsStaticWidget(channels: array("dashboard"))]
class SyncWidget extends AbstractWidget
{
    public function getDescriptor(): SimpleDescriptor
    {
        return new SimpleDescriptor(title: "Sync", description: "Data exchanges", icon: "fa fa-sync", origin: "App");
    }

    public function build(): void
    {
        $this->addBlock(
            (new D3SyncFlowBlock())
                ->setHub("Hub", "Processing")
                ->addNode(
                    (new D3SyncNode("erp", "ERP"))
                        ->setColor(ChartColors::ACCENT)
                        ->setMode(D3SyncModes::BOTH)
                        ->setVolumes(3600, 2900)
                )
        );
    }
}

Render it as any other widget: <twig:Widget :configurator="configurator" />.

JavaScript API

The Stimulus controllers are registered by StimulusBundle. @badpixxel/ux-widgets-d3 exports building blocks for custom diagrams, drawn with the same nodes, links, tooltips & theme colors:

import { FlowLink, NodeView, Tooltip, resolveTheme, watchTheme } from '@badpixxel/ux-widgets-d3';

Exports: resolveTheme, watchTheme, FlowLink, LINK_ANIMATIONS, LINK_DEFAULTS, LINK_SHAPES, NodeView, NODE_STATUSES, Tooltip, TOOLTIP_DEFAULTS, Legend, ChartConfig.

Demo Application

The bundle reuses the demo application of the Widgets Bundle (Bootstrap 3 / 4 / 5, Bootswatch themes, color mode), with its own homepage, configured in tests/config/packages/widgets_demo.yaml: a D3.js dashboard and the D3.js icon. Demo widgets are in tests/Widgets:

  • SyncFlowOverview - Servers exchanging data with a processing hub
  • ServicesMesh - Force diagram, one link per animation
  • TechStack - Bubble chart, theme series palette
  • EtlPipeline - Configurable: 0 to 3 servers per sync mode, lanes shape & animation
  • LinksCatalog - One sync flow server per links animation
make up                     # Start containers: app, sf6, sf7, sf8

Then open http://app.d3js.widgets.local (see docker-compose.yml for hosts).

Testing

make verify                 # Quality checks + PHPUnit in all containers (Symfony 6.4, 7.4 & 8.0)
make quality                # Quality checks (lint, code style, PHPStan), current container
php vendor/bin/phpunit      # PHPUnit, current container

Test suites: tests/Core (theme colors, renderer), tests/Integration (generic blocks & widgets test cases of the Widgets Bundle, on D3.js blocks & demo widgets) and tests/Operational (demo homepage, ETL parameters).

Links

License

This bundle is licensed under the MIT License. See the LICENSE file for details.