Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Candlestick chart

Since 0.1.0-alpha.23
Charts a stock's or a currency's price by the day or hour, with up and down periods told apart at a glance.

Use candlesticks to show how a price moved in each period, such as a stock's day of trading. Up and down periods stand out at a glance. Over long histories the candles crowd together, so use an OHLC chart. For the closing price alone, use a line chart.

Candlesticks

ChartCandlestickSeries takes each item's Open, High, Low and Close. A period that closed up is hollow and one that closed down is filled, so the direction shows without color.

Static

Preview

Northwind Traders (NWND), Sep to Oct 2026
Arrow keys move between values; Escape hides the tooltip.

Code

Usage.razor
@* Six weeks of a stock's trading days as candlesticks. *@
<Chart Items="_days" Argument="d => d.Date" Title="Northwind Traders (NWND), Sep to Oct 2026">
    <ChartValueAxis Format="C2" />
    <ChartCandlestickSeries Open="d => d.Open" High="d => d.High" Low="d => d.Low" Close="d => d.Close" Name="NWND" />
</Chart>

@code {
    private record Day(DateOnly Date, decimal Open, decimal High, decimal Low, decimal Close);

    private static readonly HashSet<DateOnly> Holidays = [new(2026, 9, 7)];

    private readonly Day[] _days;

    public Usage()
    {
        // Trading days: a random walk with a slow climb, each day opening near the last close.
        var random = new Random(26);
        var days = new List<Day>();
        var close = 204m;
        for (var date = new DateOnly(2026, 9, 14); date <= new DateOnly(2026, 10, 23); date = date.AddDays(1))
        {
            if (date.DayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday || Holidays.Contains(date)) continue;
            var open = Math.Round(close * (1 + (decimal)(random.NextDouble() - 0.5) * 0.012m), 2);
            close = Math.Round(open * (1 + (decimal)(random.NextDouble() - 0.47) * 0.04m), 2);
            var high = Math.Round(Math.Max(open, close) * (1 + (decimal)random.NextDouble() * 0.012m), 2);
            var low = Math.Round(Math.Min(open, close) * (1 - (decimal)random.NextDouble() * 0.012m), 2);
            days.Add(new Day(date, open, high, low, close));
        }

        _days = [.. days];
    }
}

Add this example to a page with the izzy CLI:

bash
izzy add component ChartCandlestickSeries --at <file>:<line>

Dates under candles sit side by side by item, so weekends and holidays leave no gaps.

IncreaseColor and DecreaseColor set the colors, such as green and red.

With a moving average and volume

A stock chart often adds a moving average over the candles and the volume traded beneath them. The 20-day average is a ChartLineSeries of a value worked out in the data, so it starts from the days before the chart's first. The volume is a bar chart of its own, joined to the prices with Sync for hover and zoom.

Static

Preview

Northwind Traders (NWND), daily
  • Price
  • 20-day average
Arrow keys move between values; plus and minus zoom, 0 zooms out; Escape hides the tooltip.
Northwind Traders (NWND), volume
Arrow keys move between values; Escape hides the tooltip.

Code

CandlestickVolume.razor
@* A stock's last three months of trading days: candles with a 20-day moving average, and the day's volume in a chart under them, synced. *@
<Chart Items="_shown" Argument="d => d.Date" Title="Northwind Traders (NWND), daily" Sync="nwnd" DataTable="ChartDataTable.None">
    <ChartValueAxis Title="Price" Format="C2" Position="ChartAxisPosition.Right" LabelWidth="Length.Rem(4)" />
    <ChartArgumentAxis HideLabels Zoom />
    <ChartCandlestickSeries Open="d => d.Open" High="d => d.High" Low="d => d.Low" Close="d => d.Close" Name="Price" />
    <ChartLineSeries Value="d => d.Average" Name="20-day average" />
</Chart>

<Chart Items="_shown" Argument="d => d.Date" Title="Northwind Traders (NWND), volume" HideTitle Sync="nwnd" Height="Length.Rem(8)" DataTable="ChartDataTable.None">
    <ChartValueAxis Title="Volume" Format="#,##0,,M" Position="ChartAxisPosition.Right" LabelWidth="Length.Rem(4)" />
    <ChartBarSeries Value="d => d.Volume" Name="Volume" />
</Chart>

@code {
    private record Day(DateOnly Date, decimal Open, decimal High, decimal Low, decimal Close, long Volume)
    {
        public decimal? Average { get; init; }
    }

    private static readonly HashSet<DateOnly> Holidays = [new(2026, 5, 25), new(2026, 6, 19), new(2026, 7, 3), new(2026, 9, 7)];

    private readonly Day[] _shown;

    public CandlestickVolume()
    {
        // Trading days from May to October 2026: a random walk with a slow climb, a wider swing
        // on busier days, and more shares traded when the price moves most.
        var random = new Random(26);
        var days = new List<Day>();
        var close = 182m;
        for (var date = new DateOnly(2026, 5, 1); date <= new DateOnly(2026, 10, 30); date = date.AddDays(1))
        {
            if (date.DayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday || Holidays.Contains(date)) continue;
            var open = Math.Round(close * (1 + (decimal)(random.NextDouble() - 0.5) * 0.012m), 2);
            var move = (decimal)(random.NextDouble() - 0.47) * 0.04m;
            close = Math.Round(open * (1 + move), 2);
            var high = Math.Round(Math.Max(open, close) * (1 + (decimal)random.NextDouble() * 0.012m), 2);
            var low = Math.Round(Math.Min(open, close) * (1 - (decimal)random.NextDouble() * 0.012m), 2);
            var volume = (long)(18_000_000 + Math.Abs(move) * 900_000_000m + random.Next(0, 8_000_000));
            days.Add(new Day(date, open, high, low, close, volume));
        }

        // The 20-day average of the close, from the days before the chart's first too.
        for (var i = 19; i < days.Count; i++)
        {
            days[i] = days[i] with { Average = Math.Round(days.Skip(i - 19).Take(20).Average(d => d.Close), 2) };
        }

        _shown = days.Where(d => d.Date >= new DateOnly(2026, 8, 3)).ToArray();
    }
}

A line series over the candles takes the same spacing by item; on a chart without bars or candles, SkipGaps on ChartArgumentAxis does it.

The same LabelWidth on both value axes lines up their plots, and the prices' chart hides its dates with HideLabels, since the volume's show them. Only the prices' chart sets Zoom, so its buttons zoom both, and the volume follows.

One title names the pair: the volume chart's Title is for screen readers, hidden with HideTitle, and each value axis's Title says what it measures. Both leave out their tables (DataTable="ChartDataTable.None"), so nothing sits between the two plots.

Details

A candle is hollow when the price closed above its open and filled when it closed below, in the chart's increase and decrease colors (blue and red by default, which stay apart for red-green color blindness), so the direction shows without color too. Add a ChartLineSeries<T> for a moving average; volume reads best as bars in a chart of its own under this one, joined with Sync. For many items, ChartOhlcSeries<T> is thinner. Stands upright only.

Mode support

What works in each mode, Candlestick chart
FeatureStaticInteractive
Candlesticks, hollow when the price closed up and filled when it closed down, so direction shows without colorYesYes
Trading days side by side, with no gaps for weekends and holidays, labeled where weeks, months and years beginYesYes
A moving average or other line drawn over the prices, and volume in a synced chart beneathYesYes
Each period's four prices in its tooltip and the tableYesYes
A table of the values behind a "Show data" buttonYesYes
Tooltips on hover and from the keyboardYesYes
Zoom and pan along the datesYesYes

Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.

Without JavaScript

Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off.

  • Tooltips on hover and from the keyboard: waits for the script
  • Zoom and pan along the dates: waits for the script

Parameters

ChartCandlestickSeries parameters
PropTypeDefault
OpenEach item's opening price, such as d => d.Open.Expression<Func<TItem, object?>>Required
HighEach item's highest price, such as d => d.High.Expression<Func<TItem, object?>>Required
LowEach item's lowest price, such as d => d.Low.Expression<Func<TItem, object?>>Required
CloseEach item's closing price, such as d => d.Close.Expression<Func<TItem, object?>>Required
IncreaseColorThe CSS color of items that closed up, such as var(--ib-color-success).string?computed
DecreaseColorThe CSS color of items that closed down.string?computed
AggregateWith ChartDrillLevel<T>s, how each level adds up its items' values: DataAggregate.Sum (the default), DataAggregate.Avg, DataAggregate.Min, DataAggregate.Max or DataAggregate.Count (the items with a value).DataAggregateDataAggregate.Sum
NameThe series' name, in the legend, the data table and each value's description.string?computed
SeriesBySplits the series into one per value of this, such as p => p.Device: each draws only its own items' values, is named by its value, and takes the next color and marker, in the order the values first appear.Expression<Func<TItem, object?>>?
ColorA CSS color, such as var(--ib-color-danger) or #0f766e.string?computed
LabelsWrites each value beside its bar or point.ChartLabelsChartLabels.None
LabelFormatA .NET format string for this series' labels, such as C0.string?computed
LabelTextWhat each label says in place of its value, such as r => r.Region to name each bubble or point.Expression<Func<TItem, object?>>?
LabelOverlapWhat labels do when they'd overlap others: left out at those widths (ChartLabelOverlap.Hide, the default), or shown anyway (ChartLabelOverlap.Show).ChartLabelOverlapChartLabelOverlap.Hide
TrendDraws a trend through the values: a dashed line in the series' color, named "Revenue trend" (a moving average "Revenue, 7-day average") in the legend, tooltips and data table.ChartTrendChartTrend.None
TrendOrderA polynomial trend's order, 2 (a parabola) to 6.int2
TrendPeriodHow many values a moving average takes in, 2 or more.int3
TrendColorThe trend's CSS color, such as var(--ib-color-danger), used as given.string?computed
ValueAxisThe Name of the value axis the series is read off, for a measure in other units on a second axis at the end side, such as "margin".string?computed
HiddenStarts with the series hidden: the chart is drawn as if it weren't there, and it keeps its place in the legend, to show it again, and in the data table.boolfalse

Connection lost

Rejoining the server…