SPC Chart
The SPC Chart panel automatically calculates and displays control limits for XmR, Xbar-R, and Xbar-S charts — so you can monitor process stability, detect special cause variation, and make data-driven decisions in real time.

Table of Contents
- Why SPC Chart?
- Built for Grafana
- Features
- Use Cases
- Requirements
- Getting Started
- Panel Options
- Control Lines
- Chart Types
- Control Limit Formulas
- Feature Queries
- Annotations
- Alerting
- Dashboard Variables
- Graph Styling
- Part of the KensoBI SPC Suite
- Getting Help
- License
Why SPC Chart?
Control charts are the foundation of statistical process control. They separate common cause variation (normal process behavior) from special cause variation (signals that something has changed). This plugin makes that analysis effortless:
- Automatic control limits — LCL, UCL, and Mean are calculated and displayed automatically based on the selected chart type
- Multiple chart types — XmR for individual measurements, Xbar-R for small subgroups, Xbar-S for larger subgroups
- Custom control lines — add Nominal, LSL, USL, or any custom reference line with static values or dynamic series lookup
- Fill regions — visually highlight zones between control lines to show acceptable process ranges

Built for Grafana
SPC Chart is built using Grafana's native visualization components. This means it inherits the look, feel, and behavior you already know:
- Native theming — automatically adapts to light and dark mode
- Standard panel options — legend placement, tooltip behavior, and field overrides work just like any other Grafana panel
- Works with any data source — use it with SQL databases, Prometheus, InfluxDB, CSV files, or any other Grafana data source
Features
| Feature | Description |
|---|---|
| XmR charts | Individual (X) and Moving Range (mR) charts for single measurements |
| Xbar-R charts | Subgroup mean (X-bar) and Range (R) charts for small subgroups |
| Xbar-S charts | Subgroup mean (X-bar) and Standard Deviation (S) charts for larger subgroups |
| Automatic control limits | LCL, UCL, and Mean calculated from the data using standard SPC formulas |
| Custom control lines | Add Nominal, LSL, USL, or custom lines with static values or dynamic series lookup |
| Subgrouping | Group consecutive measurements into subgroups of size 2-25 |
| Aggregation | Aggregate raw data by moving range, range, mean, or standard deviation |
| Fill regions | Color-fill areas between control lines to highlight process zones |
| Alerting support | Grafana alerting integration with alert state annotations on the chart |
| Custom annotations | Create, edit, and delete annotations directly on the chart |
| Threshold visualization | Display alert thresholds alongside SPC control limits |
| Dashboard variables | Control subgroup size across multiple panels with a single subgroupSize variable |
| Feature queries | Exclude reference queries from SPC calculations |
Use Cases
- Manufacturing quality — monitor process parameters and detect shifts before they produce defects
- IT operations — track response times, error rates, or throughput to distinguish real incidents from normal variation
- Laboratory analysis — control measurement systems and reagent performance over time
- Supply chain — monitor delivery times, fill rates, or inventory levels for process stability
- Healthcare — track clinical metrics and patient outcomes with statistical rigor
Requirements
- Grafana 11.6.10 or later
Getting Started
- Install the SPC Chart plugin from the Grafana plugin catalog or build it from source.
- Add a new panel to your dashboard and select SPC Chart as the visualization type.
- Configure a data source query that returns time series data (a time field and one or more numeric value fields).
- Select a Chart Type from the SPC options to automatically calculate control limits, or leave it as None to use manual aggregation and custom control lines.

Requirements: Grafana 11.6.10 or later.
Panel Options
All SPC-specific options are found in the SPC section of the panel editor.
Chart Type
The chart type determines which SPC calculations are applied to your data. Available options:
| Option | Description |
|---|---|
| None | No SPC calculations. Use this for manual aggregation or to display raw data with custom control lines. |
| X (XmR) | Individual values chart from an XmR control chart. Subgroup size is fixed at 1. |
| mR (XmR) | Moving range chart from an XmR control chart. Subgroup size is fixed at 1. |
| X-bar (Xbar-R) | Subgroup means chart with range-based control limits. Requires subgroup size 2-25. |
| R (Xbar-R) | Subgroup ranges chart. Requires subgroup size 2-25. |
| X-bar (Xbar-S) | Subgroup means chart with standard deviation-based control limits. Requires subgroup size 2-25. |
| S (Xbar-S) | Subgroup standard deviations chart. Requires subgroup size 2-25. |
When you select a chart type other than None, the panel automatically adds LCL, UCL, and Mean control lines.
Subgroup Size
The subgroup size determines how consecutive data points are grouped before calculations are applied.
- XmR charts: Subgroup size is locked to 1 (individual measurements).
- Xbar-R and Xbar-S charts: Subgroup size must be between 2 and 25.
- None chart type: Subgroup size can be any value from 1 to 25.
The subgroup size can also be controlled dynamically using a dashboard variable.
Aggregation
When the Chart Type is set to None, you can select an Aggregation Type to transform the raw data before display. The available aggregation types depend on the subgroup size:
Subgroup Size = 1:
| Aggregation | Description |
|---|---|
| None | Display raw values without transformation. |
| Moving Range | Compute the absolute difference between each consecutive pair of values. |
Subgroup Size >= 2:
| Aggregation | Description |
|---|---|
| Mean | Compute the average of each subgroup. |
| Range | Compute the difference between the maximum and minimum of each subgroup. |
| Standard Deviation | Compute the sample standard deviation of each subgroup (using Bessel's correction). |
Control Lines
A control line is a horizontal reference line on the chart. Control lines can represent calculated statistical limits, manually entered values, or values pulled dynamically from a data series.

Calculated Control Lines
These control lines are computed automatically from the data:
| Line | Description | Availability |
|---|---|---|
| LCL | Lower Control Limit | Only when a chart type is selected (not None) |
| UCL | Upper Control Limit | Only when a chart type is selected (not None) |
| Mean | Average of all sample values | Always available |
| Min | Minimum sample value | Always available |
| Max | Maximum sample value | Always available |
| Range | Difference between maximum and minimum values | Always available |
LCL and UCL are calculated using the standard SPC formulas for the selected chart type (see Control Limit Formulas). The Mean, Min, Max, and Range lines are computed using standard descriptive statistics.
When you select a chart type, LCL, UCL, and Mean are added automatically. Each calculated line can only appear once per data series.
Custom Control Lines
In addition to calculated lines, you can add custom control lines with manually defined positions:
| Line Type | Description |
|---|---|
| Custom | A general-purpose custom line. |
| Nominal | The target or nominal value for the process. |
| LSL | Lower Specification Limit. |
| USL | Upper Specification Limit. |
Each custom control line supports two position modes:
- Static - Enter a fixed numeric value directly.
- Series - Pull the value dynamically from a field in one of your query results. When the field contains multiple values, the last value is used.
How to add a custom control line with a dynamic value from a series:

-
Set up your queries. Create at least two queries: one for the time series data and another for the reference values (e.g., specification limits).
-
Exclude the reference query from SPC calculations. By default, the SPC Chart uses all time series data for calculations. To exclude a reference query:
- Go to Overrides > Add Field Override.
- Select the reference query fields.
- Add the Hide in Area override property and select Tooltip, Viz, and Legend.
-
Add the control line. Click Add Control Line, select a custom type (e.g., USL), and choose the query containing your reference data from the Series dropdown.
-
Select the field. Set Position Input to Series, then choose the numeric field from the Position dropdown.
You can also mark queries as Feature Queries to exclude them from SPC calculations without using overrides.
Control Line Appearance
Each control line can be customized with the following properties:
| Property | Description |
|---|---|
| Name | Display name shown in the legend and tooltip. |
| Position | The Y-axis value where the line is drawn (for static lines). |
| Series | Which data series to associate the control line with. |
| Line Width | Line thickness, from 1 to 10 pixels. |
| Color | Line color. Calculated lines use default colors (red for LCL/UCL, blue for Min/Max, dark blue for Mean, purple for Range, green for Custom/Nominal/LSL/USL). |
| Fill Direction | Below (-1), None (0), or Above (1). Creates a shaded region extending from the line to the adjacent control line. |
| Fill Opacity | Opacity of the filled region, from 0 to 100%. |
Fill regions are useful for visually highlighting zones between control lines. For example, you can fill the area between LCL and UCL to show the acceptable process range.
Chart Types
The SPC Chart supports three families of control charts, each consisting of a pair of charts: one for monitoring central tendency and one for monitoring variability.
XmR Control Chart
The XmR chart (also known as the Individuals and Moving Range chart, Shewhart's Control Chart, or I-MR) is used when measurements are taken one at a time and rational subgrouping is impractical. This is common in automated or continuous processes where individual readings are recorded sequentially.
The subgroup size is fixed at 1.
Individual (X) Chart
The X chart plots each individual measurement over time. It monitors the central location of the process, revealing whether values remain centered around the process mean.
- Center line: Mean of all values (X̅)
- UCL: X̅ + 2.66 × mR̅
- LCL: X̅ - 2.66 × mR̅
Where mR̅ is the mean of the moving ranges.
Moving Range (mR) Chart
The mR chart plots the absolute difference between consecutive measurements, showing the short-term variability of the process.
- Center line: mR̅ (mean of moving ranges)
- UCL: 3.267 × mR̅
- LCL: 0 (the lower control limit for the mR chart is always zero for n=2)
Xbar-R Control Chart
The Xbar-R chart is used when data can be collected in small subgroups (typically 2 to 10 samples). It uses the range within subgroups to estimate process variability.
The subgroup size must be between 2 and 25.
X-bar Chart for Xbar-R
The X-bar chart plots the mean of each subgroup over time, monitoring the central tendency of the process.
- Center line: X̅̅ (grand mean, the mean of all subgroup means)
- UCL: X̅̅ + A2 × R̅
- LCL: X̅̅ - A2 × R̅
Where R̅ is the average range across all subgroups and A2 is a constant that depends on the subgroup size.
R Chart for Xbar-R
The R chart plots the range (max - min) of each subgroup over time, monitoring the within-subgroup variability.
- Center line: R̅ (average range)
- UCL: D4 × R̅
- LCL: D3 × R̅
Where D3 and D4 are constants that depend on the subgroup size. For subgroup sizes of 6 or fewer, D3 = 0 and the LCL is zero.
Xbar-S Control Chart
The Xbar-S chart is similar to Xbar-R but uses the standard deviation instead of the range to measure variability. It is generally preferred for larger subgroup sizes (typically more than 10), where the range becomes a less efficient estimator of process spread.
The subgroup size must be between 2 and 25.
X-bar Chart for Xbar-S
The X-bar chart plots the mean of each subgroup over time, identical in purpose to the X-bar chart for Xbar-R. However, the control limits are based on the average standard deviation rather than the average range.
- Center line: X̅̅ (grand mean)
- UCL: X̅̅ + A3 × S̅
- LCL: X̅̅ - A3 × S̅
Where S̅ is the average sample standard deviation and A3 is a constant that depends on the subgroup size.
S Chart for Xbar-S
The S chart plots the sample standard deviation of each subgroup over time, monitoring within-subgroup variability.
- Center line: S̅ (average standard deviation)
- UCL: B4 × S̅
- LCL: B3 × S̅
Where B3 and B4 are constants that depend on the subgroup size.
Choosing the Right Chart
| Scenario | Recommended Chart | Subgroup Size |
|---|---|---|
| Individual measurements, no rational subgroups | XmR | 1 |
| Small subgroups (2-10 samples) | Xbar-R | 2-10 |
| Larger subgroups (10+ samples) | Xbar-S | 10-25 |
| Standard deviation is a better variability estimate | Xbar-S | 2-25 |
| Simple variability monitoring with small samples | Xbar-R | 2-10 |
Control Limit Formulas
The following table summarizes the control limit formulas used for each chart type. All constants (A2, A3, B3, B4, D3, D4) are standard SPC constants that vary by subgroup size and are tabulated for sizes 2 through 25.
| Chart | Center Line | UCL | LCL |
|---|---|---|---|
| X (XmR) | X̅ | X̅ + 2.66 × mR̅ | X̅ - 2.66 × mR̅ |
| mR (XmR) | mR̅ | D4 × mR̅ | D3 × mR̅ |
| X-bar (Xbar-R) | X̅̅ | X̅̅ + A2 × R̅ | X̅̅ - A2 × R̅ |
| R (Xbar-R) | R̅ | D4 × R̅ | D3 × R̅ |
| X-bar (Xbar-S) | X̅̅ | X̅̅ + A3 × S̅ | X̅̅ - A3 × S̅ |
| S (Xbar-S) | S̅ | B4 × S̅ | B3 × S̅ |
Notation:
- X̅ = mean of individual values
- X̅̅ = grand mean (mean of subgroup means)
- mR̅ = mean of moving ranges
- R̅ = mean of subgroup ranges
- S̅ = mean of subgroup standard deviations
Feature Queries
When you have multiple queries configured in a panel, the SPC Chart will by default include all time series data in its calculations. If some queries are used only to supply reference values (such as specification limits for custom control lines), you can mark them as Feature Queries to exclude them from SPC calculations.
To configure feature queries, use the Feature Query option in the SPC panel settings and select the query reference IDs that should be excluded.

This is an alternative to using the Hide in Area override to exclude reference queries.
Annotations
The SPC Chart supports both custom user annotations and Grafana alert annotations.
Custom Annotations
You can create annotations directly on the chart to mark events, notes, or observations at specific points in time.
To create an annotation:
- Hover over a data point on the chart and click to pin the tooltip.
- Click the Add annotation button in the pinned tooltip.
- Enter a Description (required) and optionally add Tags.
- Click Save.
To edit an annotation:
- Click on an existing annotation marker on the chart.
- Click the Edit button in the annotation tooltip.
- Modify the description or tags.
- Click Save.
To delete an annotation:
- Click on an existing annotation marker on the chart.
- Click the Remove button in the annotation tooltip.
- Confirm the deletion.
Annotations are stored in Grafana and are associated with the dashboard and panel.
Alert Annotations
When Grafana alerting is configured, alert state changes are displayed as vertical dashed lines on the chart. Each annotation is color-coded by alert status:
| Status | Color |
|---|---|
| Alerting | Red |
| OK | Green |
| Pending | Orange |
| No Data | Blue |
| Error | Red |
Hovering over an alert annotation shows details including the timestamp, alert name, labels, and status.
Alerting
The SPC Chart panel supports Grafana's built-in alerting system. You can create alert rules based on SPC control limits to automatically detect when your process goes out of statistical control.
Examples of SPC-based alert rules:
- Alert when a value exceeds the Upper Control Limit (UCL).
- Alert when a value falls below the Lower Control Limit (LCL).
- Alert on trends or patterns that indicate special cause variation.
To set up alerting:
- Configure an alert rule in Grafana that uses the same data source query as your SPC Chart.
- Set threshold conditions based on your calculated control limits.
- Alert state annotations and threshold lines will be displayed on the chart automatically.
Threshold visualization: You can configure alert thresholds in the panel's field configuration. Thresholds are rendered alongside SPC control limits on the chart. The threshold display style can be set to Off, Line, or Area in the graph styling options.
Dashboard Variables
Subgroup Size Variable
The SPC Chart has built-in support for a dashboard variable named subgroupSize. When this variable exists, it overrides the panel's subgroup size setting, allowing you to control the subgroup size for multiple SPC Chart panels from a single variable.
To use it:
- Go to Dashboard Settings > Variables.
- Create a new variable named
subgroupSize. - Set the variable type (e.g., Custom with a comma-separated list of sizes like
1,2,3,5,10). - All SPC Chart panels on the dashboard will use this variable's value for the subgroup size.

When the dashboard variable is active, the subgroup size input in the panel editor is disabled and shows the variable's current value.
The variable name is case-insensitive (subgroupSize, subgroupsize, and SUBGROUPSIZE all work).
Graph Styling
The SPC Chart inherits all standard Grafana time series graph styling options. These are available in the panel editor under the field configuration section.
Draw Styles
| Option | Values |
|---|---|
| Draw style | Line, Bars, Points |
| Line interpolation | Linear, Smooth, Step Before, Step After |
| Line width | 0-10 pixels |
| Line style | Solid, Dash, Dots (with configurable dash patterns) |
| Fill opacity | 0-100% |
| Gradient mode | None, Opacity, Hue, Scheme |
| Show points | Auto, Always, Never |
| Point size | 1-40 pixels |
Bar Options
| Option | Description |
|---|---|
| Bar alignment | Before, Center, After |
| Bar width factor | Width of bars relative to available space (0-1) |
Null Values
| Option | Description |
|---|---|
| Connect null values | Never, Always, or Threshold (connect gaps smaller than a time threshold) |
| Disconnect values | Never, or Threshold (insert gaps when consecutive points are farther apart than a time threshold) |
Stacking and Transform
- Stacking: None, Normal, or 100%
- Transform: None, Constant, or Negative Y
Axis
Standard Grafana axis configuration including placement, label, scale, grid lines, and soft min/max.
Time Zones
You can display the chart in one or more time zones. Use the Time zones option in the Axis category to add additional time zone displays.
Legend and Tooltip
Standard Grafana legend and tooltip options are available, including display mode, placement, tooltip mode, and sort order.
Part of the KensoBI SPC Suite
SPC Chart is part of a growing family of Statistical Process Control plugins for Grafana by Kenso Software:
SPC Pareto Panel — Identify the most significant factors contributing to defects, downtime, or any categorical issue — so you can focus improvement efforts where they matter most.
SPC Histogram Panel — Distribution analysis with histograms, bell curves, and a built-in statistics table showing Cp, Cpk, Pp, and Ppk. Use it to understand process capability: is your process producing results within specification limits?
SPC CAD Panel — Brings 3D geometry into the picture, letting you bind the data from control charts and histograms to physical features on your parts.
Getting Help
- Report bugs and suggest features on GitHub Issues.
- Join the KensoBI Discord for questions and discussion.
License
This software is distributed under the Apache License 2.0.