Documentation Index
Fetch the complete documentation index at: https://mintlify.com/grafana/grafana/llms.txt
Use this file to discover all available pages before exploring further.
Panel Plugin Development
Panel plugins create custom visualizations for displaying data in Grafana dashboards. This guide covers building panel plugins using React and TypeScript.Overview
Panel plugins are frontend-only and consist of:- Visualization component: React component that renders the data
- Options editor: UI for configuring panel options
- Field config: Configuration for individual data fields
- Migrations: Handle changes between plugin versions
Creating a Panel Plugin
Plugin Entry Point
Panel plugins extend thePanelPlugin class from @grafana/data:
Panel Component
The main visualization component receives props with data and options:Type Definitions
Define types for panel options and field config:Panel Options
Panel options are configured using the options builder:Field Configuration
Field config allows per-field customization:Working with Data
Accessing Data Frames
Data is provided as data frames:Field Display Values
Use field display values for formatted output:Styling with Emotion
UseuseStyles2 hook for theming:
Real-World Example: Time Series Panel
The Time Series panel (public/app/plugins/panel/timeseries/) is a comprehensive example:
Entry Point
Plugin Metadata
Advanced Features
Panel Migrations
Handle option changes between versions:Suggestions
Provide visualization suggestions:Annotations Support
Enable annotation display:Event Handling
Handle user interactions:Testing Panel Plugins
Unit Tests
Plugin.json Configuration
Key Configuration Options
skipDataQuery: Set totrueif panel doesn’t need query datasuggestions: Enable visualization suggestionsstate: Plugin release state (alpha,beta, or omit for stable)
Best Practices
- Use Grafana UI components: Leverage
@grafana/uifor consistent styling - Handle empty data: Always check for missing or empty data
- Responsive design: Use width/height props for proper sizing
- Theme support: Use
useTheme2for light/dark theme compatibility - Performance: Memoize expensive calculations with
useMemo - Accessibility: Add proper ARIA labels and keyboard navigation
- Error boundaries: Handle rendering errors gracefully
- Documentation: Provide clear option descriptions
Common Patterns
Data Transformation
Color Handling
Value Formatting
Resources
- Build a panel plugin tutorial
- @grafana/ui Storybook
- Panel plugin examples
- Source:
packages/grafana-data/src/panel/andpublic/app/plugins/panel/