Skip to main content

SPC Chart

Dynamic JSON Badge Grafana

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.

SPC Charts

Table of Contents


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

SPC Chart dashboard showing all chart types

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

FeatureDescription
XmR chartsIndividual (X) and Moving Range (mR) charts for single measurements
Xbar-R chartsSubgroup mean (X-bar) and Range (R) charts for small subgroups
Xbar-S chartsSubgroup mean (X-bar) and Standard Deviation (S) charts for larger subgroups
Automatic control limitsLCL, UCL, and Mean calculated from the data using standard SPC formulas
Custom control linesAdd Nominal, LSL, USL, or custom lines with static values or dynamic series lookup
SubgroupingGroup consecutive measurements into subgroups of size 2-25
AggregationAggregate raw data by moving range, range, mean, or standard deviation
Fill regionsColor-fill areas between control lines to highlight process zones
Alerting supportGrafana alerting integration with alert state annotations on the chart
Custom annotationsCreate, edit, and delete annotations directly on the chart
Threshold visualizationDisplay alert thresholds alongside SPC control limits
Dashboard variablesControl subgroup size across multiple panels with a single subgroupSize variable
Feature queriesExclude 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

  1. Install the SPC Chart plugin from the Grafana plugin catalog or build it from source.
  2. Add a new panel to your dashboard and select SPC Chart as the visualization type.
  3. Configure a data source query that returns time series data (a time field and one or more numeric value fields).
  4. 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.

SPC Chart panel editor showing an XmR chart with 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:

OptionDescription
NoneNo 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:

AggregationDescription
NoneDisplay raw values without transformation.
Moving RangeCompute the absolute difference between each consecutive pair of values.

Subgroup Size >= 2:

AggregationDescription
MeanCompute the average of each subgroup.
RangeCompute the difference between the maximum and minimum of each subgroup.
Standard DeviationCompute 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.

Control lines on an X-Bar chart with LCL, UCL, Mean, LSL, USL, and Nominal lines with fill regions

Calculated Control Lines

These control lines are computed automatically from the data:

LineDescriptionAvailability
LCLLower Control LimitOnly when a chart type is selected (not None)
UCLUpper Control LimitOnly when a chart type is selected (not None)
MeanAverage of all sample valuesAlways available
MinMinimum sample valueAlways available
MaxMaximum sample valueAlways available
RangeDifference between maximum and minimum valuesAlways 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 TypeDescription
CustomA general-purpose custom line.
NominalThe target or nominal value for the process.
LSLLower Specification Limit.
USLUpper Specification Limit.

Each custom control line supports two position modes:

  1. Static - Enter a fixed numeric value directly.
  2. 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:

Adding a custom control line with field lookup from a series

  1. 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).

  2. 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.
  3. 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.

  4. Select the field. Set Position Input to Series, then choose the numeric field from the Position dropdown.

tip

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:

PropertyDescription
NameDisplay name shown in the legend and tooltip.
PositionThe Y-axis value where the line is drawn (for static lines).
SeriesWhich data series to associate the control line with.
Line WidthLine thickness, from 1 to 10 pixels.
ColorLine 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 DirectionBelow (-1), None (0), or Above (1). Creates a shaded region extending from the line to the adjacent control line.
Fill OpacityOpacity 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

ScenarioRecommended ChartSubgroup Size
Individual measurements, no rational subgroupsXmR1
Small subgroups (2-10 samples)Xbar-R2-10
Larger subgroups (10+ samples)Xbar-S10-25
Standard deviation is a better variability estimateXbar-S2-25
Simple variability monitoring with small samplesXbar-R2-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.

ChartCenter LineUCLLCL
X (XmR)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)D4 × R̅D3 × R̅
X-bar (Xbar-S)X̅̅X̅̅ + A3 × S̅X̅̅ - A3 × S̅
S (Xbar-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.

Panel editor with SQL queries configured as feature queries

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:

  1. Hover over a data point on the chart and click to pin the tooltip.
  2. Click the Add annotation button in the pinned tooltip.
  3. Enter a Description (required) and optionally add Tags.
  4. Click Save.

To edit an annotation:

  1. Click on an existing annotation marker on the chart.
  2. Click the Edit button in the annotation tooltip.
  3. Modify the description or tags.
  4. Click Save.

To delete an annotation:

  1. Click on an existing annotation marker on the chart.
  2. Click the Remove button in the annotation tooltip.
  3. 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:

StatusColor
AlertingRed
OKGreen
PendingOrange
No DataBlue
ErrorRed

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:

  1. Configure an alert rule in Grafana that uses the same data source query as your SPC Chart.
  2. Set threshold conditions based on your calculated control limits.
  3. 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:

  1. Go to Dashboard Settings > Variables.
  2. Create a new variable named subgroupSize.
  3. Set the variable type (e.g., Custom with a comma-separated list of sizes like 1,2,3,5,10).
  4. All SPC Chart panels on the dashboard will use this variable's value for the subgroup size.

Dashboard variable configuration for 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.

info

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

OptionValues
Draw styleLine, Bars, Points
Line interpolationLinear, Smooth, Step Before, Step After
Line width0-10 pixels
Line styleSolid, Dash, Dots (with configurable dash patterns)
Fill opacity0-100%
Gradient modeNone, Opacity, Hue, Scheme
Show pointsAuto, Always, Never
Point size1-40 pixels

Bar Options

OptionDescription
Bar alignmentBefore, Center, After
Bar width factorWidth of bars relative to available space (0-1)

Null Values

OptionDescription
Connect null valuesNever, Always, or Threshold (connect gaps smaller than a time threshold)
Disconnect valuesNever, 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

License

This software is distributed under the Apache License 2.0.