Plugins 〉Plotly
Plotly
Plotly Panel for Grafana
Create advanced, interactive charts in Grafana using Plotly.js.
Key Features
- Flexible chart creation with full Plotly.js capabilities
- YAML/JSON support for easy configuration
- Dark/light theme compatibility
- Automatic and manual timezone adjustment
- Cross-trace data application
- Expandable code editors for customization
- Grafana variable integration
- Comprehensive error handling
- High-resolution image export in multiple formats (SVG, PNG, JPEG, WebP)
For a complete list of recent updates, please refer to our changelog.
Getting Started
The Plotly Panel, developed by nLine, offers enhanced control over data visualization in Grafana. It uses a component-based approach, allowing you to modify chart elements independently without complex JavaScript interactions.
Panel Structure
The panel configuration consists of five main components:
- allData: Applied across all traces on the Plotly chart
- data: Defines the chart's data series (traces)
- layout: Controls the chart's appearance and axes
- config: Sets chart-wide options
- frames: (Optional) For animated charts
These components follow the Plotly.js schema. You can configure them using YAML or JSON in the panel options.
Data Transformation
You can transform your data before rendering using a custom script. The script has access to:
data
: Raw data from your Grafana data sourcevariables
: Grafana dashboard and system variablesoptions
: Current panel configurationutils
: Helper functions (e.g., timezone conversion, dayjs for date manipulation)
Context Variables
The script has access to several context variables that provide useful information and functionality:
variables
This object contains Grafana's dashboard variables and native Grafana variables. Native variables take precedence over dashboard variables with the same name.
Key native variables include:
__from
and__to
: Start and end timestamps of the current time range__interval
and__interval_ms
: The interval in string format (e.g., "1h") and in milliseconds__timezone
: The current dashboard timezone__timeFilter
: A function to generate time range filter expressions__dashboard
: The current dashboard object
utils
The utils
object provides several utility functions and services to assist with data manipulation and panel interactions:
timeZone
: The dashboard timezonedayjs
: A lightweight date manipulation librarymatchTimezone
: A convenience function to convert timeseries data to the user's timezonelocationService
: Grafana's location service for URL manipulationgetTemplateSrv
: Grafana's template service for variable substitutionreplaceVariables
: A function to substitute Grafana variables in strings
Processing Script
The script must return an object that defines the chart configuration. This object can include one or more of the following properties:
data
: An array of trace objects defining the chart's data serieslayout
: An object controlling the chart's appearance and axesconfig
: An object setting chart-wide optionsframes
: An array of frame objects for animated charts
Note: The data
and frames
properties should be arrays of objects. The "Cross-trace Data" field can be an object, which will apply the parameters to all returned traces in the Script section. Objects are merged with script objects given priority (e.g., data
from script > allData
> data
).
The script is defined in the "Processing Script" editor.
// Example: Basic timeseries plot
const { data, variables, options, utils } = arguments;
let series = data.series[0];
let x = series.fields[0];
let y = series.fields[1];
return {
data: [
{
x: x.values || x.values.buffer,
y: y.values || y.values.buffer,
type: ‘scatter’,
mode: ’lines’,
name: x.name,
},
],
layout: {
xaxis: { title: x.name },
yaxis: { title: y.name },
},
};
On-click Event Handling
The panel supports click, select, and zoom events. You can define custom behavior for these events using the "On-event Trigger" editor.
// Event handling
const { type: eventType, data: eventData } = event;
const { timeZone, dayjs, locationService, getTemplateSrv } = utils;
switch (eventType) {
case ‘click’:
console.log(‘Click event:’, eventData.points);
break;
case ‘select’:
console.log(‘Selection event:’, eventData.range);
break;
case ‘zoom’:
console.log(‘Zoom event:’, eventData);
break;
}
Screenshots
For screenshots, please see the src/img
folder.
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
.h4 . .mb-0 }
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Grafana Cloud Free
- Free tier: Limited to 3 users
- Paid plans: $55 / user / month above included usage
- Access to all Enterprise Plugins
- Fully managed service (not available to self-manage)
Self-hosted Grafana Enterprise
- Access to all Enterprise plugins
- All Grafana Enterprise features
- Self-manage on your own infrastructure
Installing Plotly on Grafana Cloud:
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
Installing plugins on a Grafana Cloud instance is a one-click install; same with updates. Cool, right?
Note that it could take up to 1 minute to see the plugin show up in your Grafana.
For more information, visit the docs on plugin installation.
Installing on a local Grafana:
For local instances, plugins are installed and updated via a simple CLI command. Plugins are not updated automatically, however you will be notified when updates are available right within your Grafana.
1. Install the Panel
Use the grafana-cli tool to install Plotly from the commandline:
grafana-cli plugins install
The plugin will be installed into your grafana plugins directory; the default is /var/lib/grafana/plugins. More information on the cli tool.
Alternatively, you can manually download the .zip file for your architecture below and unpack it into your grafana plugins directory.
Alternatively, you can manually download the .zip file and unpack it into your grafana plugins directory.
2. Add the Panel to a Dashboard
Installed panels are available immediately in the Dashboards section in your Grafana main menu, and can be added like any other core panel in Grafana.
To see a list of installed panels, click the Plugins item in the main menu. Both core panels and installed panels will appear.
Changelog
All notable changes to this project will be documented in this file.
[1.8.1] - 2024-09-30
Changed
- Added proper replaceVariables function to utils (works with scoped variables)
Fixed
- Bad empty dataframe detection
[1.8.0] - 2024-08-27
Changed
- Add support for click, select, and zoom events
- Implement dashboard time range synchronization with chart zoom
- Expand script context with more Grafana variables and utilities
- Update README with detailed usage instructions and examples
- Improve error handling and code organization
- Add migration script for compatibility with older versions
Fixed
- Titles substitute vars properly
[1.7.0] - 2024-08-07
Changed
- Major refactor with multiple fixes and improvements
- Image export reflects all config options
- Light/dark theme that matches Grafana
- Updated theme colors
- Better error display
- Clearer message when there's no data in source
- Updated margins (default to 0 for all)
- More memoziation to reduce rerendering
- Fixed workflow and updated Node version
- Updated with grafana/create-plugin
- Updated license
- Added a changelog
Fixed
- Bug fix for height/width resize
- Fixed potential crashes with script validation
[1.6.7] - 2024-04-08
Fixed
- Small fix for 1.6.7
[1.6.6] - 2024-03-27
Changed
- Moved image render function out of panel
- Improved error handling
- Updated to create-plugin
[1.6.5] - 2024-01-08
Changed
- Updated README.md
- Fixed resizable issue
[1.6.4] - 2023-11-16
Fixed
- Fixed timezone matcher
[1.6.3] - 2023-11-16
Added
- Added ability to select column for time correction
[1.6.2] - 2023-10-26
Improved
- Enhanced matchTimezone logic
[1.6.1] - 2023-10-06
Added
- Added image export format selector
Changed
- Now passing the entire variable object
[1.6.0] - 2023-09-25
Fixed
- Fixed "browser" timezone issue
Changed
- Removed forced defaults
- Added matchTimezone function