ECG Leads and How to Read an ECG Strip
What is an ECG?
An electrocardiogram (ECG, or EKG) is a recording of the heart's electrical activity, picked up by electrodes on the skin. It plots voltage against time, and each heartbeat draws the same sequence of waves: a P wave, a QRS complex and a T wave. A standard 12-lead ECG shows that activity from twelve directions at once.

A simulated lead II rhythm strip on ECG paper, with the PR, QRS and QT intervals of the latest beat marked (sample data from a heart model, not a patient). Try the interactive version.
This guide explains how ECG traces are recorded, drawn and read. It is not clinical guidance: ECGs are interpreted by trained clinicians, alongside the patient.
- An ECG lead is a voltage between electrodes, not a wire: 10 electrodes give 12 leads, each viewing the heart from its own direction.
- Each beat draws a P wave (the atria), a QRS complex (the ventricles) and a T wave (the ventricles recovering).
- On standard paper (25 mm/s, 10 mm/mV) a small square is 0.04 s and 0.1 mV; a large square is 0.2 s and 0.5 mV.
- Heart rate is 300 divided by the large squares between two R waves, or 1,500 divided by the small squares.
- Read every strip in the same order: rate, rhythm, axis, intervals, then the shape of each wave.
What an ECG records
Each heartbeat starts with an electrical impulse in the sinoatrial (SA) node, a small cluster of cells high in the right atrium. The impulse spreads across both atria, which contract. It is delayed briefly in the atrioventricular (AV) node, then runs down the bundle of His and its branches into the Purkinje fibres, which spread it through the ventricles from the inside out. The ventricles contract, then their cells recover (repolarise), ready for the next beat.
As the wave of activation moves through the heart muscle, the cells it has reached and the cells it hasn't yet reached sit at different voltages. Seen from outside, the whole heart behaves like a single electrical arrow, a dipole, that swings round and changes length through each beat. The body conducts that field to the skin, where it measures about one millivolt.
An electrode pair records how much of the arrow points along the line between them. When the activation moves towards the positive electrode, the trace goes up; when it moves away, the trace goes down; when it moves at right angles, the trace barely moves. So the same beat looks different in each lead, depending on where the lead's electrodes sit.
"ECG" and "EKG" mean the same thing. EKG comes from the German spelling, Elektrokardiogramm, and is common in the United States, partly so that it isn't misheard as EEG, the recording of brain activity.
ECG leads: what the 12 leads are
A lead is one voltage measurement: the difference between a positive electrode and a negative reference. A standard 12-lead ECG uses ten electrodes, four on the limbs and six on the chest, and calculates twelve leads from them. The leads fall into three groups.
Limb leads I, II and III
The three standard limb leads each measure between two limb electrodes. Together they form Einthoven's triangle around the heart:
| Lead | Positive electrode | Negative electrode | Points towards |
|---|---|---|---|
| I | Left arm | Right arm | 0°, the patient's left |
| II | Left leg | Right arm | +60°, down and to the left |
| III | Left leg | Left arm | +120°, down and to the right |
Because the three leads go round a closed loop of the same three electrodes, their voltages are linked at every instant: lead II equals lead I plus lead III (Einthoven's law). Lead II runs close to the usual direction of activation, so it usually shows the tallest, clearest P waves and QRS complexes, which is why monitors and rhythm strips default to it.
Augmented limb leads aVR, aVL and aVF
The augmented leads use one limb electrode as the positive pole and the average of the other two as the reference. aVR looks from the right shoulder (−150°), aVL from the left shoulder (−30°) and aVF from the feet (+90°). "Augmented" refers to the way the reference is built, which makes the signal about 50% larger than measuring against all three electrodes. Activation normally moves away from the right shoulder, so most waves in aVR point downwards. Together with leads I, II and III, they divide the frontal plane every 30°: the hexaxial reference system.
Chest (precordial) leads V1 to V6
Each chest lead compares one chest electrode with Wilson's central terminal, the average of the right arm, left arm and left leg electrodes. Because the electrodes sit close to the heart, they see the horizontal plane, from the front of the right ventricle (V1) round to the left side of the left ventricle (V6). Across V1 to V6 the R wave normally grows and the S wave shrinks; the lead where they are about equal, usually V3 or V4, is the transition zone.
ECG electrode placement
| Electrode | Where it goes |
|---|---|
| V1 | Fourth intercostal space, just right of the sternum |
| V2 | Fourth intercostal space, just left of the sternum |
| V3 | Halfway between V2 and V4 |
| V4 | Fifth intercostal space, on the midclavicular line |
| V5 | Anterior axillary line, level with V4 |
| V6 | Mid-axillary line, level with V4 and V5 |
| RA, LA | Right and left arm, usually the wrists or upper arms |
| LL | Left leg, usually the ankle or lower leg |
| RL | Right leg: the ground, not part of any lead |
To find the fourth intercostal space, feel for the sternal angle (the ridge where the top of the breastbone joins its body) and move sideways onto the second rib. The gap just below it is the second intercostal space; count down two more gaps to the fourth. Placing V1 and V2 too high is one of the most common recording errors.
Lead groups: which leads look at which part of the heart
Leads that face the same wall of the left ventricle are read together, because a change seen in two or more neighbouring (contiguous) leads is more meaningful than a change in one.
| Group | Leads | Faces |
|---|---|---|
| Inferior | II, III, aVF | The bottom of the heart |
| Lateral | I, aVL, V5, V6 | The left side |
| Septal | V1, V2 | The wall between the ventricles |
| Anterior | V3, V4 | The front |
| None | aVR | Looks into the cavity from the right shoulder |
Other lead systems
- Monitoring leads. Bedside and transport monitors often use three electrodes (giving leads I, II and III) or five (adding one chest lead), with the limb electrodes moved onto the torso so the patient can move.
- Torso-placed limb electrodes (the Mason-Likar position) are used for exercise tests. They change the waveform slightly, so the recording should be labelled.
- Right-sided and posterior leads. V3R and V4R mirror V3 and V4 on the right of the chest; V7 to V9 continue round the back. They are added to look at the right ventricle or the back wall.
The ECG waveform: P, QRS, T and U waves
Each normal heartbeat draws a P wave, a QRS complex and a T wave, sometimes followed by a small U wave, and the intervals between them are what an ECG reader measures.
- P wave. Activation spreading through the atria. Small and rounded, normally upright in leads I and II.
- PR segment. The flat line after the P wave, while the impulse is delayed in the AV node.
- QRS complex. Activation of the ventricles. A Q wave is any first downward deflection, the R wave is the first upward one and an S wave is a downward one after the R. Not every lead shows all three, and the letters describe the shape: "rS" is a small r and a deep S.
- ST segment. The line from the end of the QRS (the J point) to the start of the T wave, when the ventricles are fully activated. It is normally close to the baseline.
- T wave. The ventricles recovering. Normally upright in most leads where the QRS is upright, and inverted in aVR.
- U wave. A small wave sometimes seen after the T wave, best in V2 and V3. Its origin is still debated.
Atrial recovery happens during the QRS complex and is hidden by it, which is why there is no wave for it.
ECG intervals and normal values
Intervals are measured from the start of one wave to the start or end of another, in the lead where the edges are clearest.
| Measure | From → to | Typical adult range | In small squares |
|---|---|---|---|
| Heart rate | — | 60 to 100 beats per minute at rest | — |
| PR interval | Start of P → start of QRS | 120 to 200 ms | 3 to 5 |
| QRS duration | Start → end of QRS | Under 120 ms, usually 80 to 110 ms | Under 3 |
| QT interval | Start of QRS → end of T | Depends on heart rate: see QTc | — |
| QTc | QT corrected for rate | Prolonged at 450 ms or more (men), 460 ms or more (women) | — |
| RR interval | One R wave → the next | 0.6 to 1.0 s at 60 to 100 bpm | 15 to 25 |
| Frontal axis | Direction of the main QRS arrow | −30° to +90° | — |
Some references use 50 bpm as the lower limit of a normal resting rate, and children have faster rates and shorter intervals. Measured values depend on the lead and the method, so a machine's printed numbers can differ from a careful manual measurement by a few milliseconds.
Correcting the QT interval for heart rate (QTc)
The QT interval shortens as the heart speeds up, so a raw QT can't be compared between recordings at different rates. A corrected QT (QTc) estimates what it would be at 60 beats per minute, where the RR interval is 1 second. With QT and RR in seconds, the two best-known formulas are:
Bazett's formula is the most widely printed, but it over-corrects at fast rates and under-corrects at slow ones. Take a QT of 313 ms at 125 beats per minute (RR = 0.48 s):
- Bazett: s, or 452 ms, just over the 450 ms threshold for men.
- Fridericia: s, or 400 ms, well within the normal range.
So the same recording can look prolonged with one formula and normal with the other. The interactive ECG shows both side by side as you change the heart rate.
ECG paper: small squares, large squares and calibration
ECG paper is printed with a grid of 1 mm squares, with every fifth line bolder. At the standard paper speed of 25 mm per second and gain of 10 mm per millivolt:
| Width (time) | Height (voltage) | |
|---|---|---|
| Small square, 1 mm | 0.04 s (40 ms) | 0.1 mV |
| Large square, 5 mm | 0.2 s (200 ms) | 0.5 mV |
| 5 large squares | 1 s | — |
| 10 small squares | — | 1 mV |
Every recording starts with a calibration pulse: a 1 mV step that should be 10 mm (two large squares) tall. Check it before measuring. Some recordings are made at 50 mm/s, which stretches every wave to twice the width, or at half or double gain (5 or 20 mm/mV) to fit very large or very small complexes; the settings are printed on the strip.
How to calculate heart rate from an ECG
A minute at 25 mm/s is 1,500 mm of paper: 300 large squares or 1,500 small ones. Three methods follow from that.
- 300 method: count the large squares between two consecutive R waves and divide 300 by that number. One large square is 300 bpm, then 150, 100, 75, 60 and 50 for two to six squares, a sequence worth memorising.
- 1,500 method: count the small squares between two R waves and divide 1,500 by it. It is more precise.
- 6-second method: count the QRS complexes in 6 seconds (30 large squares) and multiply by 10, or count them across a whole 10-second recording and multiply by 6. This is the only one of the three that works when the rhythm is irregular.
Worked examples:
| Strip | Count | Calculation | Heart rate |
|---|---|---|---|
| Regular, R waves 4 large squares apart | 4 large | 300 ÷ 4 | 75 bpm |
| The same strip, counted in small squares | 20 small | 1,500 ÷ 20 | 75 bpm |
| Regular, R waves 23 small squares apart | 23 small | 1,500 ÷ 23 | about 65 bpm |
| Irregular, 14 QRS complexes in a 10-second recording | 14 | 14 × 6 | about 84 bpm |
How to read an ECG strip, step by step
A systematic order catches things a quick glance misses. The steps below follow the order taught in resuscitation and nursing courses for rhythm strips, with the extra checks used on a full 12-lead ECG.
- Check the recording. Confirm the patient details, the paper speed, the gain and the calibration pulse, and that the leads are labelled. Look for artefact: a fuzzy, jittery baseline from muscle tremor, or a wandering one from breathing or movement.
- Work out the heart rate with one of the methods above. Under 60 bpm is described as bradycardia and over 100 bpm as tachycardia.
- Decide whether the rhythm is regular. Mark two or three R waves on a piece of paper (or use calipers) and slide it along the strip. Are the RR intervals the same, regularly irregular (a repeating pattern) or irregularly irregular (no pattern at all)?
- Look at the atrial activity. Is there a P wave before every QRS complex, and a QRS after every P wave? Are the P waves upright in lead II and all the same shape? Is the PR interval constant?
- Measure the QRS width. A narrow QRS (under 120 ms) means the ventricles were activated through the normal conduction system; a broad one means they weren't, for example a bundle branch block or a beat starting in the ventricle.
- Estimate the axis (12-lead ECG only). See the table below.
- Measure the intervals. PR and QT, and the QTc from the RR interval before the beat.
- Look at the shape of each wave and segment. P wave size, Q waves, R wave progression across V1 to V6, the ST segments and the T waves, comparing contiguous leads.
- Compare with any earlier ECG of the same person. A change matters more than a single value.
Working out the axis from leads I and aVF
The QRS axis is the average direction of ventricular activation in the frontal plane. A quick estimate uses whether the QRS is mainly positive or negative in two leads at right angles:
| Lead I | Lead aVF | Axis | Description |
|---|---|---|---|
| Positive | Positive | 0° to +90° | Normal |
| Positive | Negative | 0° to −90° | Normal if lead II is positive (down to −30°); otherwise left axis deviation |
| Negative | Positive | +90° to +180° | Right axis deviation |
| Negative | Negative | −90° to ±180° | Extreme (northwest) axis |
For a finer estimate, find the limb lead where the QRS is most nearly equal up and down (isoelectric): the axis is at right angles to it.
Common heart rhythms on an ECG strip
These are descriptions of how the strips look, not a guide to diagnosis.
| Rhythm | Rate | Regularity | P waves | QRS |
|---|---|---|---|---|
| Normal sinus rhythm | 60 to 100 bpm | Regular | Upright in II, one before every QRS, constant PR | Narrow |
| Sinus tachycardia | Over 100 bpm | Regular | As sinus rhythm; may merge into the preceding T wave at fast rates | Narrow |
| Sinus bradycardia | Under 60 bpm | Regular | As sinus rhythm | Narrow |
| Atrial fibrillation | Varies | Irregularly irregular | None: a wavy, fibrillating baseline instead | Usually narrow |
| Premature ventricular complexes (PVCs) | Underlying rhythm | Early beats break the pattern | No P wave before the early beat | Early beat is broad and oddly shaped, with a T wave pointing the opposite way |
A sinus tachycardia is often a normal response, to exercise, fever or anxiety for example. In atrial fibrillation the atria are activated chaotically, several hundred times a minute, and the AV node lets impulses through at random intervals, so no two RR intervals match. A PVC is usually followed by a pause: the next normal beat arrives two normal cycles after the one before the PVC (a compensatory pause). Many other rhythms exist, such as atrial flutter, heart blocks and ventricular tachycardia; they are beyond this guide.
How ECG monitors and recorders draw the trace
A paper recorder pulls paper past a pen at a constant speed. A screen does the same job in one of two ways. A sweeping display redraws the trace from left to right over the old one, leaving a small gap ahead of the newest point; it is what most patient monitors use, because the waveform stays still while it is drawn. A scrolling display moves the whole trace left as new data arrives. Both are explained in the strip chart guide.
Behind the trace, the signal is sampled, digitised and filtered before it is drawn. Diagnostic recorders typically sample at 500 times a second or more.
| Problem | What causes it | Filter that removes it |
|---|---|---|
| Baseline wander | Breathing, movement, electrode contact | High-pass filter |
| Mains hum at 50 or 60 Hz | Nearby power cables and equipment | Notch filter |
| Fuzzy, jittery trace | Muscle activity, shivering | Low-pass filter |
Filters change the waveform as well as the noise. The AHA recommendations for diagnostic ECGs set the low-frequency cut-off at 0.05 Hz (or up to 0.67 Hz with linear-phase digital filters) and the high-frequency cut-off at 150 Hz for adults. Monitors often offer a narrower "monitoring" band, for example around 0.5 to 40 Hz, which gives a steadier trace but can distort the ST segment and reduce small, sharp features such as pacemaker spikes. Check which filter mode a strip was recorded in before reading its ST segments.
A printed 12-lead ECG is usually 10 seconds long and laid out as three rows of four columns. Each column shows 2.5 seconds of three leads (I, II and III; then aVR, aVL and aVF; then V1 to V3; then V4 to V6), recorded at the same moment, and a 10-second rhythm strip of one lead, usually lead II, runs along the bottom.
12-lead ECG vs rhythm strip vs Holter vs wearable ECG
| Leads | How long | Used for | |
|---|---|---|---|
| Resting 12-lead ECG | 12 | 10 seconds | A full picture of the heart from all directions: axis, conduction, the walls of the ventricle |
| Monitor rhythm strip | 1 to 3 at a time, from 3 or 5 electrodes | Continuous, printed in 6 to 10 s strips | Watching rate and rhythm at the bedside or in an ambulance, with alarms |
| Holter or patch monitor | 1 to 3 (some record 12) | 24 hours to two weeks or more | Catching rhythm problems that come and go |
| Smartwatch or handheld ECG | Usually 1 (similar to lead I) | About 30 seconds, when the user starts it | Checking the rhythm when symptoms happen |
A single lead is enough to read rate and rhythm, but not axis, or changes confined to one wall of the heart.
Common ECG reading mistakes
Many ECG misreadings come from how the trace was recorded, such as misplaced electrodes or the wrong gain, or from applying a rule of thumb where it doesn't fit.
- Swapped arm electrodes. Reversing the left and right arm electrodes turns lead I upside down (negative P wave, QRS and T wave) and swaps aVR with aVL and lead II with lead III. An inverted lead I with an upright aVR is the clue.
- Chest electrodes in the wrong place. V1 and V2 placed one or two spaces too high, or V4 to V6 placed by eye on a large chest, change the R wave progression and can mimic disease.
- Ignoring the calibration pulse. At half gain every wave looks half its true height; at 50 mm/s every interval looks twice as long.
- Using the 300 rule on an irregular rhythm. It gives a different answer for each pair of beats. Count the complexes over 6 or 10 seconds instead.
- Reading artefact as an arrhythmia. Tremor, a loose electrode or tapping on a lead wire can look like fast, chaotic beats. Normal QRS complexes marching through the noise at a regular rate give it away.
- Measuring the QT in the wrong lead or including the U wave. Use the lead with the longest clear QT, often II or V5, and end it where the T wave returns to the baseline.
- Trusting Bazett's QTc at fast or slow rates. Cross-check with Fridericia's formula when the rate is outside about 60 to 100 bpm.
- Relying on the machine's printed interpretation. Automated statements are a starting point. They miss things and over-call others, so the trace is always read by a person.
How to build an ECG chart in JavaScript, React or Angular
The demo below sweeps twelve leads across the screen at 500 samples a second per lead, the rate of many diagnostic ECGs, and SciChart.js redraws every lead as new samples arrive. It simulates an ECG from a simple model of the heart's electrical activity: one rotating heart vector, seen by each lead from its own direction, so all twelve leads come from the same beats, and lead II always equals lead I plus lead III. It is sample data, not a patient recording.
Choose the Layout: a 4-second rhythm strip of one lead, about what a monitor screen shows, or the standard 12-lead layout with a lead II rhythm strip underneath. Pick a Lead to see the same beats from another direction: compare II with aVR, or V1 with V6. Rhythm switches between normal sinus rhythm, sinus tachycardia and bradycardia, atrial fibrillation and sinus rhythm with PVCs, and Heart rate sets the rate. Show intervals puts calipers on the latest normal beat, and the readouts give the rate, PR, QRS, QT and both QTc formulas. On most screen sizes the grid keeps the squares square, as on paper at 25 mm/s and 10 mm/mV. Hover for times and voltages. Press Pause to freeze the sweep, then scroll to zoom, drag to pan and double-click to reset.
Here is the code for this chart. The heart model, the rhythms and the measurements are plain JavaScript; SciChart.js draws the ECG paper grid, the sweeping traces and the calipers. The React and Angular versions show the core of it: one lead sweeping across ECG paper, fed by your own data.
- JavaScript
- React
- Angular
// A sweeping ECG on ECG paper with SciChart.js: one lead or a 12-lead layout, with calipers on the latest beat
const {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
FastLineRenderableSeries,
XyDataSeries,
BoxAnnotation,
TextAnnotation,
EHorizontalAnchorPoint,
EVerticalAnchorPoint,
SciChartJsNavyTheme,
CursorModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier
} = SciChart;
// or, for npm, import { SciChartSurface, ... } from "scichart"
const TRACE_COLOUR = "#3BD16F"; // monitors traditionally draw the ECG in green
const MV_PER_SECOND = MM_PER_SECOND / MM_PER_MV; // 2.5 mV of height looks as tall as 1 s is wide
const ROW_BASELINES = [4.3, 1.3, -1.7, -4.6]; // mV: three rows of four leads, then the rhythm strip
const { sciChartSurface, wasmContext } = await SciChartSurface.create(ui.chart, {
theme: new SciChartJsNavyTheme()
});
// ECG paper: a small square is 1 mm (0.04 s by 0.1 mV) and a large square 5 mm (0.2 s by 0.5 mV)
const xAxis = new NumericAxis(wasmContext, {
axisTitle: "Time in sweep (s)",
autoRange: EAutoRange.Never,
autoTicks: false,
majorDelta: 0.2,
minorDelta: 0.04,
drawMajorBands: false,
majorGridLineStyle: { color: "#E0607E80", strokeThickness: 1 },
minorGridLineStyle: { color: "#E0607E30", strokeThickness: 1 },
cursorLabelPrecision: 2
});
xAxis.labelProvider.formatLabel = (value) =>
Math.abs(value - Math.round(value)) < 1e-6 ? `${Math.round(value)}` : "";
const yAxis = new NumericAxis(wasmContext, {
axisTitle: "mV",
autoRange: EAutoRange.Never,
autoTicks: false,
majorDelta: 0.5,
minorDelta: 0.1,
drawMajorBands: false,
majorGridLineStyle: { color: "#E0607E80", strokeThickness: 1 },
minorGridLineStyle: { color: "#E0607E30", strokeThickness: 1 },
labelPrecision: 0,
cursorLabelPrecision: 2
});
yAxis.labelProvider.formatLabel = (value) =>
Math.abs(value - Math.round(value)) < 1e-6 ? `${Math.round(value)}` : "";
sciChartSurface.xAxes.add(xAxis);
sciChartSurface.yAxes.add(yAxis);
// Calipers on the latest complete beat: shaded spans for the PR interval, the QRS and the QT interval
const caliper = (fill, stroke) =>
new BoxAnnotation({ fill, stroke, strokeThickness: 1, x1: 0, x2: 0, y1: 0, y2: 0, isHidden: true });
const label = (textColor, horizontalAnchorPoint, verticalAnchorPoint) =>
new TextAnnotation({
text: "",
textColor,
fontSize: 13,
x1: 0,
y1: 0,
isHidden: true,
horizontalAnchorPoint,
verticalAnchorPoint
});
const calipers = {
// The PR label sits to the left of the P wave, the QRS label above the R wave and the QT label underneath
qt: {
box: caliper("#F6E05E18", "#F6E05E99"),
text: label("#F6E05E", EHorizontalAnchorPoint.Left, EVerticalAnchorPoint.Top)
},
pr: {
box: caliper("#50C7E030", "#50C7E0CC"),
text: label("#50C7E0", EHorizontalAnchorPoint.Right, EVerticalAnchorPoint.Bottom)
},
qrs: {
box: caliper("#FF8A3D40", "#FF8A3DCC"),
text: label("#FF8A3D", EHorizontalAnchorPoint.Left, EVerticalAnchorPoint.Bottom)
}
};
Object.values(calipers).forEach(({ box, text }) => sciChartSurface.annotations.add(box, text));
// Lead names for the 12-lead layout, at the start of each column
const leadLabels = [];
const leadLabel = (lead, x, baseline) =>
new TextAnnotation({
text: lead,
textColor: "#FFFFFF",
fontSize: 14,
x1: x + 0.08,
y1: baseline + 1.2,
verticalAnchorPoint: EVerticalAnchorPoint.Bottom
});
// Hover for the time and voltage; pause, then scroll to zoom, drag to pan and double-click to reset
const cursor = new CursorModifier({ showTooltip: true, tooltipContainerBackground: "#14233CDD" });
sciChartSurface.chartModifiers.add(
cursor,
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier({
onZoomExtents: () => {
setView(true);
return false; // back to the calibrated ECG paper view, not to the data
}
})
);
// --- Traces: a fixed time grid per trace. The sweep writes into it from left to right, then wraps around. ---
let layout = "single";
let windowSeconds = 4;
let traces = []; // { leadAt(i), offset(i), ys, dataSeries }
let xs = [];
function buildTraces() {
traces.forEach((trace) => sciChartSurface.renderableSeries.remove(trace.line, true));
leadLabels.forEach((annotation) => sciChartSurface.annotations.remove(annotation, true));
leadLabels.length = 0;
windowSeconds = layout === "single" ? 4 : 10; // a 4-second strip, as on a monitor screen, or a 10-second 12-lead
const count = windowSeconds * SAMPLE_RATE;
xs = Array.from({ length: count }, (_, i) => i / SAMPLE_RATE);
const columnLength = count / 4;
const rows =
layout === "single"
? [{ name: `Lead ${ui.lead.value}`, leadAt: () => ui.lead.value, baseline: 0, isColumns: false }]
: [
...TWELVE_LEAD_ROWS.map((row, r) => ({
name: row.join(", "),
leadAt: (i) => row[Math.floor(i / columnLength)],
baseline: ROW_BASELINES[r],
isColumns: true
})),
{
name: "Rhythm strip, lead II",
leadAt: () => "II",
baseline: ROW_BASELINES[3],
isColumns: false
}
];
traces = rows.map((row) => {
const dataSeries = new XyDataSeries(wasmContext, {
dataSeriesName: row.name,
isSorted: true,
containsNaN: true
});
const line = new FastLineRenderableSeries(wasmContext, {
dataSeries,
stroke: TRACE_COLOUR,
strokeThickness: 1.5
});
sciChartSurface.renderableSeries.add(line);
return { ...row, ys: new Float64Array(count).fill(NaN), dataSeries, line };
});
if (layout === "twelve") {
TWELVE_LEAD_ROWS.forEach((row, r) =>
row.forEach((lead, c) => {
leadLabels.push(leadLabel(lead, c * (windowSeconds / 4), ROW_BASELINES[r]));
})
);
leadLabels.push(leadLabel("II", 0, ROW_BASELINES[3]));
leadLabels.forEach((annotation) => sciChartSurface.annotations.add(annotation));
}
cursor.showTooltip = layout === "single"; // in the 12-lead layout, rows are offset, so only times are shown
cursor.showYLine = layout === "single";
yAxis.drawLabels = layout === "single";
yAxis.axisTitle = layout === "single" ? "mV" : "";
setView(true);
}
// Keeps the squares square at 25 mm/s and 10 mm/mV, whatever the size of the chart
let lastAspect = 0;
function setView(force) {
const rect = sciChartSurface.seriesViewRect;
const hasSize = Boolean(rect) && rect.width > 0 && rect.height > 0;
const aspect = hasSize ? rect.height / rect.width : 0.45; // before the first layout, assume a typical shape
if (!force && Math.abs(aspect - lastAspect) < 0.005) return;
lastAspect = aspect;
// On very wide or very tall screens, stretch the squares a little to keep the waves in view
const [minimum, maximum] = layout === "single" ? [3.5, 5.5] : [12.4, 15];
const span = Math.min(maximum, Math.max(minimum, windowSeconds * MV_PER_SECOND * aspect));
const centre = layout === "single" ? 0.4 : 0;
xAxis.visibleRange = new NumberRange(0, windowSeconds);
yAxis.visibleRange = new NumberRange(centre - span / 2, centre + span / 2);
// Hide the small squares when they would be less than 4 pixels wide
const pixelsPerSmallSquare = hasSize ? (rect.width / windowSeconds) * 0.04 : 4;
xAxis.drawMinorGridLines = pixelsPerSmallSquare >= 4;
yAxis.drawMinorGridLines = pixelsPerSmallSquare >= 4;
}
// --- The live sweep ---
const generator = createRhythmGenerator();
let sample = 0; // samples drawn so far
let running = true;
const settings = { rhythm: "normal", heartRate: 72, showIntervals: true };
const GAP = Math.round(0.2 * SAMPLE_RATE); // a 0.2 s gap ahead of the sweep, as on a monitor
// Writes sample number s into every trace, at its place in the sweep
function writeSample(s) {
const length = xs.length;
const t = s / SAMPLE_RATE;
const i = s % length;
const h = heartVector(generator.beats, t, settings.rhythm === "af");
const wander = 0.04 * Math.sin(2 * Math.PI * 0.21 * t); // slow baseline wander, e.g. from breathing
for (const trace of traces) {
// Break the line where one lead ends and the next begins, as on a printed 12-lead
const isColumnStart = trace.isColumns && i % (length / 4) === 0;
trace.ys[i] = isColumnStart
? NaN
: trace.baseline + leadVoltage(trace.leadAt(i), h) + wander + 0.012 * gaussian();
}
}
// Clears the gap ahead of the write position and sends the traces to the chart
function refresh() {
const length = xs.length;
const writeAt = sample % length;
for (const trace of traces) {
for (let g = 0; g < GAP; g++) trace.ys[(writeAt + g) % length] = NaN;
trace.dataSeries.clear();
trace.dataSeries.appendRange(xs, trace.ys);
}
}
function addSamples(count) {
generator.extend((sample + count) / SAMPLE_RATE + 1, settings.rhythm, settings.heartRate);
for (let n = 0; n < count; n++) writeSample(sample++);
refresh();
}
// Redraws the sweep on screen from the beats already made, after a change of lead or layout
function redrawSweep() {
const start = Math.max(0, sample - xs.length + GAP);
for (let s = start; s < sample; s++) writeSample(s);
refresh();
}
// --- Readouts ---
const readoutNames = ["Rhythm", "Heart rate", "PR", "QRS", "QT", "QTc (Bazett)", "QTc (Fridericia)", "Paper"];
const readouts = readoutNames.map((name) => {
const tile = document.createElement("div");
tile.style.cssText = "padding:2px 10px; border-radius:6px; background:#14233C; min-width:76px;";
tile.innerHTML = `<div style="font-size:11px; color:#c8d3e8">${name}</div><div style="font-size:15px; font-weight:600">–</div>`;
ui.readoutRow.append(tile);
return tile.lastElementChild;
});
const ms = (seconds) => (isFinite(seconds) ? `${Math.round(seconds * 1000)} ms` : "–");
function rhythmName(rate) {
if (settings.rhythm === "af") return "Atrial fibrillation";
if (settings.rhythm === "pvc") return "Sinus rhythm with PVCs";
return rate > 100 ? "Sinus tachycardia" : rate < 60 ? "Sinus bradycardia" : "Normal sinus rhythm";
}
// Measures the latest complete beat, places the calipers on it and updates the readouts
function measure() {
const now = sample / SAMPLE_RATE;
const done = generator.beats.filter((beat) => beat.tEnd + 0.05 < now && beat.qrsOn > now - 8);
// Heart rate from the QRS complexes of the last 6 seconds, as a monitor counts them
const recent = done.filter((beat) => beat.qrsOn > now - 6);
const rate =
recent.length > 1 ? (60 * (recent.length - 1)) / (recent[recent.length - 1].qrsOn - recent[0].qrsOn) : NaN;
// The calipers go on the latest normally conducted beat that sits within one sweep
let index = -1;
for (let k = done.length - 1; k > 0 && index < 0; k--) {
const beat = done[k];
const start = isFinite(beat.pOn) ? beat.pOn : beat.qrsOn;
const sameSweep = Math.floor(start / windowSeconds) === Math.floor((beat.tEnd + 0.1) / windowSeconds);
if (beat.kind === "normal" && sameSweep) index = k;
}
const beat = index > 0 ? done[index] : null;
const rr = beat ? beat.qrsOn - done[index - 1].qrsOn : NaN; // the RR interval before this beat
const qt = beat ? beat.tEnd - beat.qrsOn : NaN;
const values = [
rhythmName(settings.heartRate),
isFinite(rate) ? `${Math.round(rate)} bpm` : "–",
beat && isFinite(beat.pOn) ? ms(beat.qrsOn - beat.pOn) : beat ? "no P waves" : "–",
beat ? ms(beat.qrsOff - beat.qrsOn) : "–",
ms(qt),
ms(qt / Math.sqrt(rr)),
ms(qt / Math.cbrt(rr)),
`${MM_PER_SECOND} mm/s, ${MM_PER_MV} mm/mV`
];
values.forEach((text, k) => (readouts[k].textContent = text));
const show = Boolean(beat) && settings.showIntervals;
Object.values(calipers).forEach(({ box, text }) => {
box.isHidden = !show;
text.isHidden = !show;
});
if (!show) return;
const toX = (t) => t - Math.floor(beat.qrsOn / windowSeconds) * windowSeconds;
const baseline = traces[traces.length - 1].baseline; // the single trace, or the 12-lead rhythm strip
// Each caliper is a shaded span from one wave's start to another's end, with its label at (labelX, labelY)
const place = ({ box, text }, from, to, bottom, top, labelX, labelY, caption) => {
box.isHidden = !isFinite(from);
text.isHidden = !isFinite(from);
if (!isFinite(from)) return;
box.x1 = toX(from);
box.x2 = toX(to);
box.y1 = baseline + bottom;
box.y2 = baseline + top;
text.x1 = toX(labelX);
text.y1 = baseline + labelY;
text.text = caption;
};
place(calipers.pr, beat.pOn, beat.qrsOn, -0.3, 0.5, beat.pOn, 0.5, `PR ${ms(beat.qrsOn - beat.pOn)}`);
place(
calipers.qrs,
beat.qrsOn,
beat.qrsOff,
-0.3,
1.75,
beat.qrsOn,
1.75,
`QRS ${ms(beat.qrsOff - beat.qrsOn)}`
);
place(calipers.qt, beat.qrsOn, beat.tEnd, -0.55, -0.85, beat.qrsOn, -0.85, `QT ${ms(qt)}`);
}
// Add the samples that have arrived since the last update, about 30 times a second
let lastTime = performance.now();
let carry = 0;
const timer = setInterval(() => {
const time = performance.now();
const due = Math.min(((time - lastTime) * SAMPLE_RATE) / 1000, SAMPLE_RATE / 4) + carry;
lastTime = time;
if (!running) return;
const count = Math.floor(due);
carry = due - count;
if (count > 0) {
addSamples(count);
measure();
setView(false);
}
}, 33);
sciChartSurface.addDeletable({ delete: () => clearInterval(timer) });
// --- Controls ---
const PRESET_RATES = { normal: 72, tachycardia: 125, bradycardia: 48, af: 100, pvc: 72 };
const readControls = () => {
settings.heartRate = Number(ui.rate.value);
settings.showIntervals = ui.intervals.checked;
ui.rateOut.textContent = `${settings.heartRate} bpm`;
ui.lead.disabled = layout === "twelve";
};
const setRunning = (value) => {
running = value;
ui.run.textContent = running ? "Pause" : "Resume";
if (running) setView(true);
};
ui.rhythm.addEventListener("change", () => {
settings.rhythm = ui.rhythm.value === "af" || ui.rhythm.value === "pvc" ? ui.rhythm.value : "sinus";
ui.rate.value = String(PRESET_RATES[ui.rhythm.value]);
readControls();
});
ui.rate.addEventListener("input", () => {
readControls();
// The three sinus presets are the same rhythm at different rates, so follow the rate
if (settings.rhythm === "sinus") {
const rate = settings.heartRate;
ui.rhythm.value = rate > 100 ? "tachycardia" : rate < 60 ? "bradycardia" : "normal";
}
});
ui.intervals.addEventListener("change", () => {
readControls();
measure();
});
ui.lead.addEventListener("change", () => {
traces[0].dataSeries.dataSeriesName = `Lead ${ui.lead.value}`;
redrawSweep(); // show the whole strip in the new lead at once
});
ui.layout.addEventListener("change", () => {
layout = ui.layout.value;
readControls();
buildTraces();
redrawSweep();
measure();
});
ui.run.addEventListener("click", () => setRunning(!running));
// Zooming or panning pauses the sweep, so the live update doesn't undo it
const pauseForZoom = () => running && setRunning(false);
ui.chart.addEventListener("wheel", pauseForZoom);
ui.chart.addEventListener("pointerdown", pauseForZoom);
settings.rhythm = "sinus";
readControls();
buildTraces();
// Start with one full sweep already drawn
addSamples(xs.length - GAP);
measure();
sciChartSurface.rendered.subscribe(() => running && setView(false));
import { SciChartReact } from "scichart-react";
import {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
FastLineRenderableSeries,
XyDataSeries,
SciChartJsNavyTheme,
CursorModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier
} from "scichart";
const SAMPLE_RATE = 500; // samples per second
const WINDOW = 6; // seconds across the screen
// initChart builds the chart; SciChartReact creates it, sizes it and cleans it up
const initChart = async (rootElement: string | HTMLDivElement) => {
const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement, {
theme: new SciChartJsNavyTheme()
});
// ECG paper: minor gridlines every 0.04 s and 0.1 mV, major gridlines every 0.2 s and 0.5 mV
const paper = {
autoRange: EAutoRange.Never,
autoTicks: false,
drawMajorBands: false,
majorGridLineStyle: { color: "#E0607E80", strokeThickness: 1 },
minorGridLineStyle: { color: "#E0607E30", strokeThickness: 1 }
};
sciChartSurface.xAxes.add(
new NumericAxis(wasmContext, {
...paper,
axisTitle: "Time in sweep (s)",
majorDelta: 0.2,
minorDelta: 0.04,
visibleRange: new NumberRange(0, WINDOW)
})
);
sciChartSurface.yAxes.add(
new NumericAxis(wasmContext, {
...paper,
axisTitle: "mV",
majorDelta: 0.5,
minorDelta: 0.1,
visibleRange: new NumberRange(-1, 2)
})
);
// A sweeping FIFO buffer: new samples overwrite the oldest from left to right, with a 0.2 s gap
const capacity = WINDOW * SAMPLE_RATE;
const dataSeries = new XyDataSeries(wasmContext, {
dataSeriesName: "Lead II",
fifoCapacity: capacity,
fifoSweeping: true,
fifoSweepingGap: SAMPLE_RATE / 5,
isSorted: false,
containsNaN: false
});
sciChartSurface.renderableSeries.add(
new FastLineRenderableSeries(wasmContext, { dataSeries, stroke: "#3BD16F", strokeThickness: 1.5 })
);
sciChartSurface.chartModifiers.add(
new CursorModifier({ showTooltip: true }),
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier()
);
// Append the samples that arrived since the last update; x wraps round to 0 at the end of each sweep
let sample = 0;
const timer = setInterval(() => {
const millivolts: number[] = getYourNewEcgSamples(); // e.g. from a WebSocket or a device
const times = millivolts.map(() => (sample++ % capacity) / SAMPLE_RATE);
dataSeries.appendRange(times, millivolts);
}, 33);
sciChartSurface.addDeletable({ delete: () => clearInterval(timer) });
return { sciChartSurface };
};
export const EcgChart = () => <SciChartReact initChart={initChart} style={{ width: "100%", height: 400 }} />;
import { Component } from "@angular/core";
import { ScichartAngularComponent } from "scichart-angular";
import {
SciChartSurface,
NumericAxis,
NumberRange,
EAutoRange,
FastLineRenderableSeries,
XyDataSeries,
SciChartJsNavyTheme,
CursorModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier
} from "scichart";
const SAMPLE_RATE = 500; // samples per second
const WINDOW = 6; // seconds across the screen
@Component({
selector: "app-ecg-chart",
standalone: true,
imports: [ScichartAngularComponent],
template: `<scichart-angular [initChart]="initChart" style="display: block; width: 100%; height: 400px"></scichart-angular>`
})
export class EcgChartComponent {
// initChart builds the chart; scichart-angular creates it, sizes it and cleans it up
initChart = async (rootElement: string | HTMLDivElement) => {
const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement, {
theme: new SciChartJsNavyTheme()
});
// ECG paper: minor gridlines every 0.04 s and 0.1 mV, major gridlines every 0.2 s and 0.5 mV
const paper = {
autoRange: EAutoRange.Never,
autoTicks: false,
drawMajorBands: false,
majorGridLineStyle: { color: "#E0607E80", strokeThickness: 1 },
minorGridLineStyle: { color: "#E0607E30", strokeThickness: 1 }
};
sciChartSurface.xAxes.add(
new NumericAxis(wasmContext, {
...paper,
axisTitle: "Time in sweep (s)",
majorDelta: 0.2,
minorDelta: 0.04,
visibleRange: new NumberRange(0, WINDOW)
})
);
sciChartSurface.yAxes.add(
new NumericAxis(wasmContext, {
...paper,
axisTitle: "mV",
majorDelta: 0.5,
minorDelta: 0.1,
visibleRange: new NumberRange(-1, 2)
})
);
// A sweeping FIFO buffer: new samples overwrite the oldest from left to right, with a 0.2 s gap
const capacity = WINDOW * SAMPLE_RATE;
const dataSeries = new XyDataSeries(wasmContext, {
dataSeriesName: "Lead II",
fifoCapacity: capacity,
fifoSweeping: true,
fifoSweepingGap: SAMPLE_RATE / 5,
isSorted: false,
containsNaN: false
});
sciChartSurface.renderableSeries.add(
new FastLineRenderableSeries(wasmContext, { dataSeries, stroke: "#3BD16F", strokeThickness: 1.5 })
);
sciChartSurface.chartModifiers.add(
new CursorModifier({ showTooltip: true }),
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier()
);
// Append the samples that arrived since the last update; x wraps round to 0 at the end of each sweep
let sample = 0;
const timer = setInterval(() => {
const millivolts: number[] = getYourNewEcgSamples(); // e.g. from a WebSocket or a device
const times = millivolts.map(() => (sample++ % capacity) / SAMPLE_RATE);
dataSeries.appendRange(times, millivolts);
}, 33);
sciChartSurface.addDeletable({ delete: () => clearInterval(timer) });
return { sciChartSurface };
};
}
Key points:
- Each trace is a
FastLineRenderableSeriesover anXyDataSeriesof millivolts against time. NaN values break the line, which the 12-lead layout uses between columns and the sweep uses for the gap ahead of the newest point. - The ECG paper is the axes' own gridlines:
autoTicks: falsewithmajorDeltaandminorDeltaset to 0.2 s and 0.04 s on the x-axis and 0.5 mV and 0.1 mV on the y-axis. The demo sets the y-axis range from the plot area's shape so that 1 s is as wide as 2.5 mV is tall, as on paper. - The calipers are
BoxAnnotations withTextAnnotationlabels, moved to the latest complete beat on each update. - For a monitor fed by a device,
fifoCapacitywithfifoSweepinggives the sweeping display with no buffer code of your own, as in the React and Angular versions.
See it in the demo app: JavaScript ECG vital signs chart · React ECG vital signs chart · Angular ECG vital signs chart, and for several live signals at once, JavaScript real-time chart performance.
Go deeper: SciChart.js line chart documentation, real-time updates and FIFO sweeping and the box annotation documentation. For how SciChart is used in patient monitoring and medical research software, see SciChart for medical charts and dashboards and SciChart for telehealth.
Frequently asked questions
What are the 12 leads of an ECG?
The 12 leads are six limb leads and six chest leads. The limb leads, I, II, III, aVR, aVL and aVF, look at the heart in the frontal plane, from above, below and the sides. The chest (precordial) leads, V1 to V6, look at it in the horizontal plane, from the front of the chest round to the left side. Each lead is a voltage measured between electrodes, so it shows the same heartbeat from its own direction.
Why does a 12-lead ECG use only 10 electrodes?
A lead is a measurement, not a wire. The six limb leads are all calculated from three limb electrodes (right arm, left arm and left leg), and the six chest leads each compare one chest electrode with the average of those three. The tenth electrode, on the right leg, is a ground that reduces interference and isn't part of any lead.
How do you read an ECG strip?
Use the same order every time. Check the paper speed, gain and lead labels; work out the heart rate; decide whether the rhythm is regular and whether a P wave comes before every QRS complex; estimate the axis from leads I and aVF; measure the PR interval, QRS duration and QT interval; then look at the shape of each wave and segment. A trained clinician interprets the result alongside the patient.
What do the small and large squares on ECG paper mean?
At the standard settings of 25 mm per second and 10 mm per millivolt, a small 1 mm square is 0.04 seconds wide and 0.1 mV tall, and a large 5 mm square is 0.2 seconds wide and 0.5 mV tall. Five large squares make one second, so a minute is 300 large squares or 1,500 small ones. That is where the 300 and 1,500 rules for heart rate come from.
What are the normal PR, QRS and QT intervals?
In adults the PR interval is usually 120 to 200 ms (three to five small squares) and the QRS duration under 120 ms (three small squares). The QT interval depends on heart rate, so it is corrected to QTc; AHA/ACCF/HRS recommendations treat a QTc of 450 ms or more in men and 460 ms or more in women as prolonged. Normal ranges vary with age and between references.
How do I draw an ECG chart in JavaScript?
Plot the samples in millivolts against time with a line series, on fixed axes with major gridlines every 0.2 s and 0.5 mV and minor gridlines every 0.04 s and 0.1 mV, so the grid matches ECG paper. For a live monitor, append new samples to a FIFO data series in sweep mode, which redraws from left to right with a gap ahead of the newest point. SciChart.js does this with FastLineRenderableSeries and XyDataSeries with fifoSweeping.
Sources
- Kligfield, P. et al. (2007), Recommendations for the standardization and interpretation of the electrocardiogram, Part I: the electrocardiogram and its technology. Circulation, 115(10). AHA/ACCF/HRS. Lead definitions, electrode placement, sampling and the 0.05 Hz and 150 Hz filter recommendations.
- Surawicz, B. et al. (2009), Part III: intraventricular conduction disturbances. Circulation, 119(10). QRS duration, bundle branch block and axis deviation.
- Rautaharju, P. M., Surawicz, B. and Gettes, L. S. (2009), Part IV: the ST segment, T and U waves, and the QT interval. Circulation, 119(10). QT measurement, rate correction and the 450 ms and 460 ms QTc thresholds.
- Becker, D. E. (2006), Fundamentals of electrocardiography interpretation. Anesthesia Progress, 53(2). The conduction system, ECG paper, rate calculation and a systematic reading order.
- Hegde, S. and Ahmed, I. (updated 2026), Electrocardiogram: fundamentals, interpretation, and rhythm analysis. StatPearls, NCBI Bookshelf. Leads, waves, intervals and normal values.
- Resuscitation Council UK, Advanced Life Support, 9th edition (2025), chapter on monitoring and rhythm recognition. The structured approach to reading rhythm strips.
- Joglar, J. A. et al. (2024), 2023 ACC/AHA/ACCP/HRS guideline for the diagnosis and management of atrial fibrillation. Circulation, 149(1). The ECG features of atrial fibrillation.