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
- Statistics Table
- Export to CSV
- Annotations
- Alerting
- Dashboard Variables
- Numeric X-axis
- 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
- Statistics table — an optional table below the chart summarizing each series, including process capability (Cp, Cpk, Pp, Ppk)

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 |
| Statistics table | Optional summary table with per-series stats and process capability (Cp, Cpk, Pp, Ppk) |
| Export to CSV | Download the statistics and control line values as a CSV file |
| Numeric X-axis | Use a numeric field (e.g., sample index) as the X-axis instead of a time field |
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.
Statistics Table
The SPC Chart can display a statistics table below the chart that summarizes key metrics for each data series. This gives you a quick numeric overview of your process alongside the control chart, without calculating anything by hand.

Enable it with the Show statistics table option in the panel editor. The table is off by default, so existing dashboards are unaffected until you turn it on. The chart and table share the panel space with a draggable splitter, so you can balance how much room each gets.
The descriptive statistics always describe your raw individual measurements, even when the chart plots subgroup means, ranges, or standard deviations. This means the statistics (and the capability indices) are the same whichever chart of a pair you display — for example the X-bar and R charts of an Xbar-R pair report identical numbers.
Descriptive Statistics
The table shows the following columns for each series:
| Column | Description |
|---|---|
| Series | The name of the data series |
| n | Number of measurements in the series |
| Mean | The average of all measurements |
| Std Dev | Standard deviation — how spread out the measurements are |
| Min | The smallest measurement in the series |
| Max | The largest measurement in the series |
Control Limits
When a control chart type is selected (XmR, Xbar-R, or Xbar-S), the table also shows:
| Column | Description |
|---|---|
| LCL | Lower Control Limit — the lower boundary calculated by the control chart |
| UCL | Upper Control Limit — the upper boundary calculated by the control chart |
These columns only appear when a chart type is selected (not None).
Process Capability Indices
Process capability indices tell you how well your process fits within specification limits. They answer the question: "Is my process producing results within the acceptable range?"
These columns only appear when you have defined both a Lower Specification Limit (LSL) and an Upper Specification Limit (USL) as control lines.
| Column | Description |
|---|---|
| Cp | Process capability — can the process fit within spec limits? |
| Cpk | Process capability adjusted for centering — is the process centered? |
| Pp | Process performance — similar to Cp but uses overall variation |
| Ppk | Process performance adjusted for centering — similar to Cpk using overall variation |
What are Cp and Cpk?
Cp measures whether the spread of your process is narrow enough to fit within the specification limits. It uses short-term, within-subgroup variation.
- Cp = 1.0 means the process spread exactly matches the spec width
- Cp > 1.33 is generally considered good — your process fits well within specs
- Cp < 1.0 means the process spread is wider than the spec limits
Cpk is like Cp, but also checks whether the process is centered between the spec limits. A high Cp with a low Cpk means your process is capable but shifted to one side.
What are Pp and Ppk?
Pp and Ppk are similar to Cp and Cpk, but they use the overall standard deviation instead of the within-subgroup estimate. This makes them better for evaluating long-term process performance.
- Use Cp/Cpk to understand short-term process capability
- Use Pp/Ppk to understand long-term process performance
- When Cp and Pp are similar, the process is stable over time
Setting up Specification Limits
To see capability indices in the table, add LSL and USL control lines:
- Go to Editor > SPC > Control Lines.
- Click Add Control Line and select LSL (Lower Specification Limit).
- Enter the lower specification value for your process (or pull it from a series — see Custom Control Lines).
- Add another control line and select USL (Upper Specification Limit).
- Enter the upper specification value.
Once both limits are defined, the Cp, Cpk, Pp, and Ppk columns appear in the table.
Editor Options
The statistics table is configured in the panel editor under the Statistics Table section:
| Option | Description | Default |
|---|---|---|
| Show statistics table | Toggle the entire table on or off. | Off |
| Visible columns | Choose which columns appear. Use this to simplify the table by hiding columns you don't need. Columns that don't apply (control limits with no chart type, or capability indices with no spec limits) are hidden automatically. | All columns |
Export to CSV
You can export the calculated SPC values to a CSV file. There are two ways to trigger the export:
- Download icon — Click the download icon in the top-right corner of the statistics table.
- Right-click menu — Right-click anywhere on the panel and select Download CSV.
The exported file contains two sections:
| Section | Contents |
|---|---|
| Statistics | One row per series with the same columns shown in the table (Series, n, Mean, Std Dev, Min, Max, LCL, UCL, Cp, Cpk, Pp, Ppk). Only the columns visible in the table are included. |
| Control Lines | Name, series, type, and resolved position for each configured control line. |
The exported file is named spc-statistics_YYYY-MM-DD_HHMMSS.csv.
This exports the calculated values from the SPC analysis, not the raw data from the data source. Grafana's built-in Download CSV in the panel Inspect menu exports the raw data source values instead.
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).