JavaScript Chart with Smith Chart

Demonstrates how to create a JavaScript Smith Chart using SciChart.js, High Performance JavaScript Charts

MARKERSClick chart to place a marker
src/drawExample.ts
import {
    SciChartSurface,
    EAxisAlignment,
    NumberRange,
    ZoomExtentsModifier,
    MouseWheelZoomModifier,
    PinchZoomModifier,
    ZoomPanModifier,
    EExecuteOn,
} from "scichart";
import { appTheme } from "./appTheme";
import { SmithChartResistanceAxis, SmithChartReactanceAxis } from "./smithChartAxes";
import { SmithChartAdmittanceResistanceAxis, SmithChartAdmittanceReactanceAxis } from "./smithChartAdmittance";
import { SmithMarkersAdapter } from "./smithChartMarkers";
import { SmithVswrAdapter } from "./smithChartVswr";
import { SmithChainAdapter } from "./smithChartChain";
import { SmithState, SmithAction } from "./smithState";

export const drawExample = async (rootElement: string | HTMLDivElement) => {
    const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
        theme: appTheme.SciChartJsTheme,
    });

    const gridColor = "#aaaaaa";
    const axisRange = 1.2;
    sciChartSurface.xAxes.add(
        new SmithChartResistanceAxis(wasmContext, {
            visibleRange: new NumberRange(-axisRange, axisRange),
            axisAlignment: EAxisAlignment.Bottom,
            labelPrecision: 2,
            majorGridLineStyle: { color: gridColor, strokeThickness: 2 },
            minorGridLineStyle: { color: gridColor + "77", strokeThickness: 1 },
            rimLineStyle: { color: appTheme.MutedBlue },
            rimTickLineStyle: { color: appTheme.MutedBlue },
            rimLabelStyle: { color: appTheme.MutedBlue },
        })
    );

    sciChartSurface.yAxes.add(
        new SmithChartReactanceAxis(wasmContext, {
            visibleRange: new NumberRange(-axisRange, axisRange),
            axisAlignment: EAxisAlignment.Left,
            labelPrecision: 2,
            majorGridLineStyle: { color: gridColor, strokeThickness: 2 },
            minorGridLineStyle: { color: gridColor + "77", strokeThickness: 1 },
        })
    );

    const yAdmittanceColor = "#44AAFF";
    const admittanceResistanceAxis = new SmithChartAdmittanceResistanceAxis(wasmContext, {
        visibleRange: new NumberRange(-axisRange, axisRange),
        axisAlignment: EAxisAlignment.Bottom,
        isVisible: false,
        majorGridLineStyle: { color: yAdmittanceColor, strokeThickness: 2 },
        minorGridLineStyle: { color: yAdmittanceColor + "77", strokeThickness: 1 },
    });
    const admittanceReactanceAxis = new SmithChartAdmittanceReactanceAxis(wasmContext, {
        visibleRange: new NumberRange(-axisRange, axisRange),
        axisAlignment: EAxisAlignment.Left,
        isVisible: false,
        majorGridLineStyle: { color: yAdmittanceColor, strokeThickness: 2 },
        minorGridLineStyle: { color: yAdmittanceColor + "77", strokeThickness: 1 },
    });
    sciChartSurface.xAxes.add(admittanceResistanceAxis);
    sciChartSurface.yAxes.add(admittanceReactanceAxis);

    // vswrAdapter must be created first so SmithVswrModifier gets priority over SmithClickModifier
    const vswrAdapter = new SmithVswrAdapter(sciChartSurface);
    const markersAdapter = new SmithMarkersAdapter(sciChartSurface, wasmContext);
    const chainAdapter = new SmithChainAdapter(sciChartSurface, wasmContext);

    sciChartSurface.chartModifiers.add(
        new MouseWheelZoomModifier(),
        new ZoomExtentsModifier(),
        new PinchZoomModifier(),
        new ZoomPanModifier({ executeCondition: { button: EExecuteOn.MouseRightButton } })
    );

    const alphaHex = (v: number) =>
        Math.round(Math.min(1, Math.max(0, v)) * 255)
            .toString(16)
            .padStart(2, "0");

    const update = (state: SmithState) => {
        markersAdapter.update(state);
        vswrAdapter.update(state);
        chainAdapter.update(state);

        // Grid mode — show/hide impedance and admittance axes
        const zGridActive = state.gridMode === "Z" || state.gridMode === "ZY";
        const yGridActive = state.gridMode === "Y" || state.gridMode === "ZY";
        // Z resistance axis stays visible in all modes so the rim always draws;
        // its R-circles are made transparent when not in Z/ZY mode.
        sciChartSurface.xAxes.get(0).isVisible = true;
        sciChartSurface.yAxes.get(0).isVisible = zGridActive;
        admittanceResistanceAxis.isVisible = yGridActive;
        admittanceReactanceAxis.isVisible = yGridActive;

        // Labels: Z labels in Z or ZY; Y labels only in Y-only mode
        const zLabels = zGridActive;
        const yLabels = state.gridMode === "Y";
        (sciChartSurface.xAxes.get(0) as SmithChartResistanceAxis).drawGridLabels = zLabels;
        admittanceResistanceAxis.drawLabels = yLabels;
        admittanceReactanceAxis.drawLabels = yLabels;

        // Grid opacity — Z circles hidden (transparent) in Y-only mode
        const zMajor = zGridActive ? `${gridColor}${alphaHex(state.zOpacity)}` : "#00000000";
        const zMinor = zGridActive ? `${gridColor}${alphaHex(state.zOpacity * 0.5)}` : "#00000000";
        const yMajor = `${yAdmittanceColor}${alphaHex(state.yOpacity)}`;
        const yMinor = `${yAdmittanceColor}${alphaHex(state.yOpacity * 0.5)}`;
        sciChartSurface.xAxes.get(0).majorGridLineStyle = { color: zMajor, strokeThickness: 2 };
        sciChartSurface.xAxes.get(0).minorGridLineStyle = { color: zMinor, strokeThickness: 1 };
        sciChartSurface.yAxes.get(0).majorGridLineStyle = { color: zMajor, strokeThickness: 2 };
        sciChartSurface.yAxes.get(0).minorGridLineStyle = { color: zMinor, strokeThickness: 1 };
        admittanceResistanceAxis.majorGridLineStyle = { color: yMajor, strokeThickness: 2 };
        admittanceResistanceAxis.minorGridLineStyle = { color: yMinor, strokeThickness: 1 };
        admittanceReactanceAxis.majorGridLineStyle = { color: yMajor, strokeThickness: 2 };
        admittanceReactanceAxis.minorGridLineStyle = { color: yMinor, strokeThickness: 1 };
    };

    const setDispatch = (dispatch: (a: SmithAction) => void) => {
        markersAdapter.setDispatch(dispatch);
        vswrAdapter.setDispatch(dispatch);
        chainAdapter.setDispatch(dispatch);
    };

    return {
        sciChartSurface,
        wasmContext,
        update,
        setDispatch,
        getChainTip: (s: SmithState) => chainAdapter.getChainTip(s),
        addChainStep: chainAdapter.addStep.bind(chainAdapter),
    };
};

What is a Smith Chart?

RF and microwave engineers face a recurring problem: getting maximum power from a source into a load when both have complex, frequency-dependent impedances. A mismatch causes reflections that waste power, distort signals, and can damage amplifiers. Fixing it means choosing the right combination of inductors, capacitors, and transmission-line sections — but the interactions are non-linear and hard to reason about algebraically.

The Smith chart makes this tractable by turning the matching problem into a geometry problem. Every possible impedance maps to a point inside a circle, and adding each type of component moves that point along a predictable curve. Series inductors and capacitors arc along circles; shunt components arc along a different family; a length of transmission line rotates the point around the chart centre. The goal — a perfect impedance match — is the centre of the chart.

This demo lets you explore those mechanics interactively. Place a marker to read the full impedance, admittance, VSWR and return-loss figures at any point. Load one of the built-in examples to see a complete matching problem worked through step by step. Or build your own network in the Chain panel, adding components one at a time and watching the operating point move to its destination.

SciChart.js Implementation

This example is built entirely on SciChartSurface with custom NumericAxis subclasses — no specialised polar surface is required because the Γ plane is Cartesian.

Custom axes override drawGridLines and drawLabels to render the characteristic Smith chart curves using WebGL arc primitives via the SciChart WASM context:

  • SmithChartResistanceAxis (X-axis) draws constant-R circles and the outer rim ring, and hosts a custom SmithChartAxisRenderer that places R labels at each circle’s left tangent point.
  • SmithChartReactanceAxis (Y-axis) draws constant-X arcs clipped to the unit circle with X labels at each arc’s unit-circle intersection.
  • SmithChartAdmittanceResistanceAxis / SmithChartAdmittanceReactanceAxis mirror these for the Y-overlay, registered as secondary axes. Labels are shown only in Y-only mode to avoid clutter in ZY mode.

Grid density is dynamically computed by SmithGridCalculator, which selects major and minor tick values in s-space (s = 1/(v+1)) to give perceptually uniform coverage and automatically clips minor arcs near the (1, 0) singularity.

Three adapters add interactivity on top of the chart surface:

  • SmithMarkersAdapter — click-to-place markers with constrained drag modes (free, constant |Γ|, R, X, G or B curve), implemented as custom ChartModifierBase subclasses.
  • SmithVswrAdapter — draggable VSWR circle with optional fill shading rendered as an EllipsePointMarker annotation.
  • SmithChainAdapter — component chain that moves a starting point along the correct Smith chart curve for each component type, computing the new Γ analytically for series L/C/R, shunt L/C/R and transmission line sections.

Using the Demo

Chart navigation: mouse wheel to zoom, right-click drag to pan, double-click to zoom to extents.

Markers: click anywhere on the chart to place a numbered marker. The right-hand sidebar shows a full readout for each marker — Γ (complex), |Γ|, ∠Γ, normalised Z and Y, VSWR, return loss, mismatch loss, Q factor, WTG and WTL. Each marker can be dragged freely or constrained to a constant-R, X, |Γ|, G or B curve via the Drag selector in its accordion.

Examples menu (top-left overlay button) loads pre-built RF scenarios demonstrating typical Smith chart workflows such as L-network matching and stub tuning.

Chain panel builds a component matching network step by step: select a component type (Series L/C/R, Shunt L/C/R, Transmission Line), enter a value and click Add. Each step draws the arc from the current point to the next impedance. The VSWR circle can be resized by dragging its handle on the real axis; Shade fills the acceptable-match region.

Grid Config panel controls the chart appearance: the Z / Y / ZY toggle switches between the impedance grid (grey), admittance grid (blue) or both overlaid. Independent opacity sliders fade each grid. Advanced controls adjust grid density and the outer rim tick spacing.