Enhancing Data Visualization in Filament with PostgreSQL Functions

Introduction

This post explores how the Reimpact/platform project enhanced its Filament-based dashboard by leveraging PostgreSQL functions to improve data visualization. The focus was on creating a more insightful and efficient packaging dashboard.

From MySQL to PostgreSQL: A Performance Shift

The initial implementation relied on MySQL stored procedures. To optimize performance and leverage PostgreSQL's capabilities, these procedures were converted into PostgreSQL functions. This migration facilitates better data processing and reporting within the Filament dashboard. Think of it like upgrading from a standard car engine to a high-performance one, resulting in a smoother and faster ride.

Dual-Driver Support for Data Queries

To ensure compatibility during the transition, a DashboardQueryService with dual-driver support (MySQL/PostgreSQL) was implemented. This allows the application to seamlessly switch between the two database systems. It's similar to having a universal adapter for different power outlets, ensuring your device works regardless of the socket type.

Filament Dashboard: Visualizing Packaging Data

A new Filament dashboard page was created, incorporating six chart widgets:

  • Cost in UF per material category (stacked bar)
  • Tons per material category (stacked bar)
  • Top products by cost (horizontal stacked bar)
  • Top products by tons (horizontal stacked bar)
  • Top products by domiciliary cost (grouped bar)
  • Tons per material category over time (line chart)

These widgets provide a comprehensive overview of packaging data, enabling informed decision-making. Imagine these charts as the control panel of a complex machine, providing real-time feedback on its performance.

Global Filter Widget: Tailoring the View

A global filter widget was added, allowing users to filter data by periodicity, month, year, and warehouse. This provides flexibility in analyzing specific data segments. This is like having a zoom lens on a camera, allowing you to focus on specific details or get a broader view.

Results

The new dashboard offers a more efficient and insightful way to visualize packaging data, empowering users to make data-driven decisions.

Next Steps

Explore additional data visualization options within Filament to further enhance the dashboard's capabilities. Consider implementing caching strategies to optimize query performance, especially for large datasets. You could also explore adding more granular filtering options to provide even more customized views.

Enhancing Data Visualization in Filament with PostgreSQL Functions
GERARDO RUIZ

GERARDO RUIZ

Author

Share: