Thursday, July 2, 2026

LWC: Reusable Horizontal Bar Chart

📊 Reusable Horizontal Bar Chart for Salesforce LWC

A modern, reusable Lightning Web Component that renders responsive horizontal bar charts with smooth animations, adaptive labels, click-to-filter functionality, and zero third-party JavaScript libraries.

📖 Project Overview

horizontalBarChart is a fully reusable Salesforce Lightning Web Component designed for dashboards, Home Pages, App Pages, and Experience Cloud sites.

The component accepts a simple collection of { id, label, value } objects and automatically renders an attractive horizontal bar chart using native HTML, CSS and Lightning Web Components.

Built without Chart.js, D3.js, or any external dependency, the component offers excellent performance, smooth animations, accessibility, responsive layouts, configurable colors, interactive filtering, and App Builder support.

✨ Features

Feature Description
Animated EntryBars animate smoothly from 0% to their calculated width whenever data changes.
Adaptive LabelsAutomatically positions values inside or outside the bar based on available space.
Click-to-FilterClicking a bar selects it and fires a custom barclick event.
Toggle SelectionClick again to remove the active filter.
Clear Filter ButtonDisplays automatically whenever a filter is active.
External SelectionParent components can control selection using the selectedId property.
Automatic ScalingCalculates maximum value automatically or accepts a custom maxValue.
Large Number FormattingFormats values such as 45K, 1.2M, etc.
Custom ColorsSupports reusable color palettes that cycle automatically.
Legend SupportOptional color legend for dashboard visualization.
Responsive LayoutOptimized for desktop, tablet and mobile devices.
AccessibilityKeyboard navigation, ARIA labels and screen-reader support.

🏗 Component Architecture

Reusable Horizontal Bar Chart

📁 Project Structure

horizontalBarChart/
│
├── horizontalBarChart.html
├── horizontalBarChart.js
├── horizontalBarChart.css
├── horizontalBarChart.js-meta.xml
└── README.md

⚙️ Public API

Property Purpose
dataArray of { id, label, value } objects.
selectedIdExternally control selected bar.
maxValueOverride automatic scaling.
showLegendShow or hide legend.
colorsCustom color palette.

📦 Expected Data Structure

[
  {
    id: "A",
    label: "Prospecting",
    value: 120
  },
  {
    id: "B",
    label: "Qualification",
    value: 85
  },
  {
    id: "C",
    label: "Closed Won",
    value: 42
  }
]

🔄 Event Flow

Load Data
    │
    ▼
Calculate Maximum
    │
    ▼
Render Horizontal Bars
    │
    ▼
Animate Width
    │
    ▼
User Clicks Bar
    │
    ▼
Dispatch "barclick"
    │
    ▼
Parent Dashboard Filters

🎨 Styling Features

  • Salesforce Lightning Design System (SLDS) styling.
  • Uses Lightning Design Tokens.
  • Responsive layout.
  • Animated transitions.
  • Adaptive value labels.
  • Optional legend.
  • Empty state illustration.
  • Theme-friendly custom CSS variables.

♿ Accessibility

  • Keyboard accessible.
  • ARIA-compliant buttons.
  • Screen reader labels.
  • role="button" support.
  • aria-pressed state management.
  • Focus indicators.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

🎯 Ideal Business Use Cases

  • Opportunity Stage Dashboard
  • Lead Source Analytics
  • Case Status Distribution
  • Revenue Comparison
  • Sales Team Performance
  • Service Metrics
  • Executive KPI Dashboards
  • Experience Cloud Analytics
  • Marketing Campaign Performance
  • Custom Salesforce Reports

📌 Conclusion

The Horizontal Bar Chart component provides an elegant, lightweight, and highly reusable solution for visualizing Salesforce data. Built entirely with Lightning Web Components and native web technologies, it offers smooth animations, adaptive labels, interactive filtering, responsive layouts, accessibility support, and App Builder compatibility—making it an excellent choice for modern Salesforce dashboards and analytics applications.

Tuesday, June 30, 2026

LWC: Reusable Donut / Pie Chart Component

🍩 Reusable Donut / Pie Chart Component for Salesforce LWC

A fully reusable SVG-based Lightning Web Component that renders beautiful, interactive Donut and Pie Charts using pure SVG with zero external JavaScript libraries.

📖 Project Overview

The Donut / Pie Chart Component is a reusable Lightning Web Component built entirely with native Salesforce technologies. It renders interactive charts using pure SVG, supports Apex-powered dynamic data as well as static datasets, and provides configurable legends, animated slices, hover tooltips, accessibility support, and responsive layouts.

Unlike third-party charting libraries, this solution requires zero external dependencies, making deployment simple while maintaining excellent performance and Lightning compatibility.

✨ Key Features

Feature Description
Pure SVG RenderingNo Canvas or third-party chart libraries required.
Donut & Pie ModesSwitch between Donut and Pie using a single property.
Animated SlicesHovered slices expand while remaining slices fade.
Interactive TooltipsDisplays label, value, and percentage on hover.
Configurable LegendSupports stacked and side-by-side layouts.
Dynamic Apex DataAutomatically loads data using Apex Wire.
Static Data SupportAccepts custom chart data from parent components.
Responsive LayoutAutomatically adapts to desktop and mobile screens.
AccessibilityKeyboard navigation, ARIA labels and focus support.
Loading & Error StatesBuilt-in loading, empty data and error handling.

🏗 Component Architecture

Donut Chart - LWC Component Architecture

📁 Project Structure

force-app
└── main
    └── default
        ├── classes
        │   └── DonutChartController.cls
        │
        └── lwc
            └── donutChart
                ├── donutChart.html
                ├── donutChart.js
                ├── donutChart.css
                └── donutChart.js-meta.xml

⚙️ Public API Properties

Property Purpose
titleChart title displayed above the component.
chartTypeChoose between donut or pie.
chartDataStatic chart data supplied by parent LWC.
recordIdAutomatically loads Apex data.
colorPaletteCustom array of chart colors.
showLegendDisplay chart legend.
legendPositionStacked or Side-by-Side layout.
showCenterTextDisplay total value inside the donut.
valuePrefix / valueSuffixFormat displayed values.

💻 Usage Example

<c-donut-chart
    title="Revenue by Stage"
    chart-type="donut"
    show-legend
    legend-position="side-by-side"
    show-center-text
    center-label="Total"
    value-prefix="$"
    chart-data={opportunityData}>
</c-donut-chart>

📊 Supported Features

  • Donut Charts
  • Pie Charts
  • Static Data
  • Apex Wire Data
  • Hover Animation
  • Keyboard Navigation
  • ARIA Accessibility
  • Responsive Layout
  • Custom Color Palette
  • Legend Totals
  • Loading State
  • Error State
  • Empty Data State

🎨 Customisation Options

✔ Custom Color Palette

✔ Legend Title

✔ Legend Position

✔ Center Label

✔ Value Prefix

✔ Value Suffix

✔ Label Field Mapping

✔ Value Field Mapping

✔ Donut / Pie Mode

♿ Accessibility

  • Keyboard accessible slices.
  • Tab navigation support.
  • Meaningful ARIA labels.
  • Screen reader friendly.
  • High contrast compatible.
  • Mobile responsive layout.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

🎯 Business Use Cases

  • Sales Pipeline Distribution
  • Opportunity Stage Analysis
  • Case Status Dashboard
  • Lead Source Analytics
  • Revenue Breakdown
  • Account Segmentation
  • Executive Dashboards
  • Service Performance Reports
  • Custom CRM Analytics

📌 Conclusion

The Reusable Donut / Pie Chart Component provides a lightweight, modern, and highly configurable visualization solution for Salesforce Lightning applications. Built entirely with native SVG, Lightning Web Components, and Apex, it delivers interactive charts without relying on external JavaScript libraries, making it ideal for enterprise Salesforce projects that require performance, accessibility, and easy customization.

Monday, June 29, 2026

LWC: Scheduled Job Monitor

⏰ Scheduled Job Monitor for Salesforce LWC

Monitor, manage, and analyze Salesforce Scheduled Apex Jobs directly from Lightning Experience with a modern reusable Lightning Web Component.

📖 Project Overview

Scheduled Job Monitor is a reusable Lightning Web Component that provides administrators and developers with a centralized dashboard for monitoring Salesforce Scheduled Apex Jobs.

Instead of navigating through Salesforce Setup pages, users can view scheduled jobs, inspect execution details, monitor upcoming schedules, abort running jobs, refresh data, search jobs, and analyze execution status directly from Lightning Experience.

The solution is built using Lightning Web Components, Apex, and Salesforce CronTrigger APIs while following Salesforce security best practices.

✨ Key Features

Feature Description
Scheduled Job Dashboard View all scheduled Apex jobs from a single Lightning page.
Real-Time Refresh Reload latest job information without leaving the page.
Search Jobs Quickly locate scheduled jobs by name.
Status Monitoring Track Waiting, Acquired, Executing, Complete, Error and Deleted jobs.
Abort Scheduled Jobs Cancel scheduled jobs directly from Lightning.
Execution Details Display next execution time, previous execution and schedule information.
Toast Notifications Success and error messages for all operations.
Responsive Design Works across desktop and tablet Lightning Experience.

🏗 Solution Architecture

Scheduled Job Monitor Architecture

📁 Project Structure

force-app
└── main
    └── default
        ├── classes
        │   ├── ScheduledJobMonitorController.cls
        │   └── ScheduledJobMonitorControllerTest.cls
        │
        ├── lwc
        │   └── scheduledJobMonitor
        │       ├── scheduledJobMonitor.html
        │       ├── scheduledJobMonitor.js
        │       ├── scheduledJobMonitor.css
        │       └── scheduledJobMonitor.js-meta.xml
        │
        └── permissionsets
            └── ScheduledJobMonitor.permissionset-meta.xml

⚙️ Dashboard Information

Column Description
Job NameScheduled Apex class name.
StateCurrent execution status.
Cron ExpressionComplete scheduling expression.
Next Fire TimeNext scheduled execution.
Previous Fire TimeLast successful execution.
Times TriggeredExecution count.
ActionsAbort and refresh operations.

🔄 Monitoring Workflow

Load Dashboard
      │
      ▼
Retrieve CronTrigger Records
      │
      ▼
Display Scheduled Jobs
      │
      ▼
Search / Filter Jobs
      │
      ▼
Review Execution Details
      │
      ▼
Abort Job (Optional)
      │
      ▼
Refresh Dashboard

📊 Supported Job States

WAITING
ACQUIRED
EXECUTING
COMPLETE
ERROR
DELETED

🔒 Security

  • Uses with sharing Apex controllers.
  • Supports Salesforce CRUD and Field-Level Security.
  • Respects user permissions while displaying scheduled jobs.
  • Permission Set included for easy deployment.
  • Native Salesforce scheduler APIs used without external integrations.

🚀 Deployment

sf org login web --alias myOrg

sf project deploy start \
--source-dir force-app \
--target-org myOrg

sf org assign permset \
--name ScheduledJobMonitor

sf apex run test \
--class-names ScheduledJobMonitorControllerTest

🎯 Business Benefits

  • Eliminates navigation to Salesforce Setup.
  • Provides centralized scheduled job monitoring.
  • Improves administrator productivity.
  • Quickly identifies failed or inactive jobs.
  • Supports one-click job cancellation.
  • Reusable across multiple Salesforce organizations.
  • Modern Lightning user experience.

📌 Conclusion

The Scheduled Job Monitor provides Salesforce administrators and developers with a simple yet powerful interface for managing Scheduled Apex Jobs. By combining Lightning Web Components, Apex, and Salesforce scheduling APIs, the solution delivers real-time visibility into scheduled processes while simplifying monitoring and administration from within Lightning Experience.