DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty

DwsChartCandlestick

Shows how a value moved over a series of periods, such as a share price per day: each candle's body runs from the period's open to its close, its wick from the low to the high, and its color says whether the period closed higher or lower. The drawing stretches to any size with crisp strokes and text, the colors are theme colors, and hovering, focusing or tapping a candle shows its values. The arrow keys move between the candles.

API Reference

Basic

Only ChartData is needed: one candle per period with its label, open, high, low and close. The value axis picks round steps around the data, the labels below thin out when there are many candles, and the legend counts the rising and falling ones.

ACME share price, March
  • Rising (13)
  • Falling (7)
Show Code
CandlestickChart.razor

<DwsChartCandlestick Name="CandlestickChartDemo_Basic" ChartData="@_prices" Title="ACME share price, March" />

@code {
    // A share's daily open, high, low and close in March; the Tag carries the traded volume.
    private readonly DwsChartCandlestickData _prices = new()
    {
        Candles =
        [
            Day("Mar 2", 100.0, 103.2, 99.1, 102.6, 1_204_000), Day("Mar 3", 102.6, 104.8, 101.9, 104.1, 1_388_000),
            Day("Mar 4", 104.1, 104.5, 100.8, 101.3, 1_650_000), Day("Mar 5", 101.3, 102.0, 98.4, 99.0, 1_902_000),
            Day("Mar 6", 99.0, 101.7, 98.7, 101.2, 1_120_000), Day("Mar 9", 101.2, 105.9, 100.9, 105.4, 2_015_000),
            Day("Mar 10", 105.4, 108.2, 104.6, 107.7, 1_840_000), Day("Mar 11", 107.7, 108.0, 105.1, 105.6, 1_310_000),
            Day("Mar 12", 105.6, 106.3, 102.2, 103.0, 1_575_000), Day("Mar 13", 103.0, 104.1, 101.5, 103.9, 990_000),
            Day("Mar 16", 103.9, 109.4, 103.5, 108.8, 2_230_000), Day("Mar 17", 108.8, 112.6, 108.1, 111.9, 2_480_000),
            Day("Mar 18", 111.9, 113.0, 109.2, 109.8, 1_760_000), Day("Mar 19", 109.8, 110.5, 106.7, 107.1, 1_690_000),
            Day("Mar 20", 107.1, 111.3, 106.9, 110.8, 1_430_000), Day("Mar 23", 110.8, 115.2, 110.2, 114.6, 2_105_000),
            Day("Mar 24", 114.6, 117.9, 113.8, 117.2, 2_640_000), Day("Mar 25", 117.2, 118.1, 114.0, 114.5, 1_980_000),
            Day("Mar 26", 114.5, 116.4, 113.2, 116.0, 1_215_000), Day("Mar 27", 116.0, 118.3, 114.9, 116.0, 1_050_000),
        ]
    };

    private static DwsChartCandlestickDataElement Day(string label, double open, double high, double low, double close, int volume) =>
        new(label, open, high, low, close) { Tag = volume };

    // Without a Tag, Add chains candles:
    // new DwsChartCandlestickData().Add("Mar 2", 100.0, 103.2, 99.1, 102.6).Add("Mar 3", 102.6, 104.8, 101.9, 104.1);
}

Hollow rising candles

HollowRising draws rising candles as outlines, which tells the two kinds apart without color.

  • Rising (13)
  • Falling (7)
Show Code
CandlestickChart.razor

<DwsSwitch Name="CandlestickChartDemo_HollowRising" Class="mb-3" @bind-Value="_hollowRising" Label="HollowRising" />
<DwsChartCandlestick Name="CandlestickChartDemo_Hollow" ChartData="@_prices" HollowRising="@_hollowRising" />

@code {
    private bool _hollowRising = true;

    // A share's daily open, high, low and close in March; the Tag carries the traded volume.
    private readonly DwsChartCandlestickData _prices = new()
    {
        Candles =
        [
            Day("Mar 2", 100.0, 103.2, 99.1, 102.6, 1_204_000), Day("Mar 3", 102.6, 104.8, 101.9, 104.1, 1_388_000),
            Day("Mar 4", 104.1, 104.5, 100.8, 101.3, 1_650_000), Day("Mar 5", 101.3, 102.0, 98.4, 99.0, 1_902_000),
            Day("Mar 6", 99.0, 101.7, 98.7, 101.2, 1_120_000), Day("Mar 9", 101.2, 105.9, 100.9, 105.4, 2_015_000),
            Day("Mar 10", 105.4, 108.2, 104.6, 107.7, 1_840_000), Day("Mar 11", 107.7, 108.0, 105.1, 105.6, 1_310_000),
            Day("Mar 12", 105.6, 106.3, 102.2, 103.0, 1_575_000), Day("Mar 13", 103.0, 104.1, 101.5, 103.9, 990_000),
            Day("Mar 16", 103.9, 109.4, 103.5, 108.8, 2_230_000), Day("Mar 17", 108.8, 112.6, 108.1, 111.9, 2_480_000),
            Day("Mar 18", 111.9, 113.0, 109.2, 109.8, 1_760_000), Day("Mar 19", 109.8, 110.5, 106.7, 107.1, 1_690_000),
            Day("Mar 20", 107.1, 111.3, 106.9, 110.8, 1_430_000), Day("Mar 23", 110.8, 115.2, 110.2, 114.6, 2_105_000),
            Day("Mar 24", 114.6, 117.9, 113.8, 117.2, 2_640_000), Day("Mar 25", 117.2, 118.1, 114.0, 114.5, 1_980_000),
            Day("Mar 26", 114.5, 116.4, 113.2, 116.0, 1_215_000), Day("Mar 27", 116.0, 118.3, 114.9, 116.0, 1_050_000),
        ]
    };

    private static DwsChartCandlestickDataElement Day(string label, double open, double high, double low, double close, int volume) =>
        new(label, open, high, low, close) { Tag = volume };

    // Without a Tag, Add chains candles:
    // new DwsChartCandlestickData().Add("Mar 2", 100.0, 103.2, 99.1, 102.6).Add("Mar 3", 102.6, 104.8, 101.9, 104.1);
}

Width and height

Width, Height, MinWidth, MaxWidth, MinHeight and MaxHeight size the chart in pixels, caption, axes and legend included; the drawing takes what is left. Drag the corner of the dashed box: the chart in it is 320px high and keeps between 220px and 720px wide.

  • Rising (13)
  • Falling (7)
Show Code
CandlestickChart.razor

<div class="candlestick-demo-resizable">
    <DwsChartCandlestick Name="CandlestickChartDemo_Size" ChartData="@_prices" Height="320" MinWidth="220" MaxWidth="720" />
</div>

<style>
    .candlestick-demo-resizable {
        resize: horizontal;
        overflow: auto;
        width: 100%;
        min-width: 240px;
        max-width: 100%;
        padding: 0.5rem;
        border: 1px dashed var(--secondary);
    }
</style>

@code {
    // A share's daily open, high, low and close in March; the Tag carries the traded volume.
    private readonly DwsChartCandlestickData _prices = new()
    {
        Candles =
        [
            Day("Mar 2", 100.0, 103.2, 99.1, 102.6, 1_204_000), Day("Mar 3", 102.6, 104.8, 101.9, 104.1, 1_388_000),
            Day("Mar 4", 104.1, 104.5, 100.8, 101.3, 1_650_000), Day("Mar 5", 101.3, 102.0, 98.4, 99.0, 1_902_000),
            Day("Mar 6", 99.0, 101.7, 98.7, 101.2, 1_120_000), Day("Mar 9", 101.2, 105.9, 100.9, 105.4, 2_015_000),
            Day("Mar 10", 105.4, 108.2, 104.6, 107.7, 1_840_000), Day("Mar 11", 107.7, 108.0, 105.1, 105.6, 1_310_000),
            Day("Mar 12", 105.6, 106.3, 102.2, 103.0, 1_575_000), Day("Mar 13", 103.0, 104.1, 101.5, 103.9, 990_000),
            Day("Mar 16", 103.9, 109.4, 103.5, 108.8, 2_230_000), Day("Mar 17", 108.8, 112.6, 108.1, 111.9, 2_480_000),
            Day("Mar 18", 111.9, 113.0, 109.2, 109.8, 1_760_000), Day("Mar 19", 109.8, 110.5, 106.7, 107.1, 1_690_000),
            Day("Mar 20", 107.1, 111.3, 106.9, 110.8, 1_430_000), Day("Mar 23", 110.8, 115.2, 110.2, 114.6, 2_105_000),
            Day("Mar 24", 114.6, 117.9, 113.8, 117.2, 2_640_000), Day("Mar 25", 117.2, 118.1, 114.0, 114.5, 1_980_000),
            Day("Mar 26", 114.5, 116.4, 113.2, 116.0, 1_215_000), Day("Mar 27", 116.0, 118.3, 114.9, 116.0, 1_050_000),
        ]
    };

    private static DwsChartCandlestickDataElement Day(string label, double open, double high, double low, double close, int volume) =>
        new(label, open, high, low, close) { Tag = volume };

    // Without a Tag, Add chains candles:
    // new DwsChartCandlestickData().Add("Mar 2", 100.0, 103.2, 99.1, 102.6).Add("Mar 3", 102.6, 104.8, 101.9, 104.1);
}

Fixed size

Width and Height together give a fixed size, here 360 x 200px.

Show Code
CandlestickChart.razor

<DwsChartCandlestick Name="CandlestickChartDemo_FixedSize" ChartData="@_prices" Width="360" Height="200" WithLegend="false" />

@code {
    // A share's daily open, high, low and close in March; the Tag carries the traded volume.
    private readonly DwsChartCandlestickData _prices = new()
    {
        Candles =
        [
            Day("Mar 2", 100.0, 103.2, 99.1, 102.6, 1_204_000), Day("Mar 3", 102.6, 104.8, 101.9, 104.1, 1_388_000),
            Day("Mar 4", 104.1, 104.5, 100.8, 101.3, 1_650_000), Day("Mar 5", 101.3, 102.0, 98.4, 99.0, 1_902_000),
            Day("Mar 6", 99.0, 101.7, 98.7, 101.2, 1_120_000), Day("Mar 9", 101.2, 105.9, 100.9, 105.4, 2_015_000),
            Day("Mar 10", 105.4, 108.2, 104.6, 107.7, 1_840_000), Day("Mar 11", 107.7, 108.0, 105.1, 105.6, 1_310_000),
            Day("Mar 12", 105.6, 106.3, 102.2, 103.0, 1_575_000), Day("Mar 13", 103.0, 104.1, 101.5, 103.9, 990_000),
            Day("Mar 16", 103.9, 109.4, 103.5, 108.8, 2_230_000), Day("Mar 17", 108.8, 112.6, 108.1, 111.9, 2_480_000),
            Day("Mar 18", 111.9, 113.0, 109.2, 109.8, 1_760_000), Day("Mar 19", 109.8, 110.5, 106.7, 107.1, 1_690_000),
            Day("Mar 20", 107.1, 111.3, 106.9, 110.8, 1_430_000), Day("Mar 23", 110.8, 115.2, 110.2, 114.6, 2_105_000),
            Day("Mar 24", 114.6, 117.9, 113.8, 117.2, 2_640_000), Day("Mar 25", 117.2, 118.1, 114.0, 114.5, 1_980_000),
            Day("Mar 26", 114.5, 116.4, 113.2, 116.0, 1_215_000), Day("Mar 27", 116.0, 118.3, 114.9, 116.0, 1_050_000),
        ]
    };

    private static DwsChartCandlestickDataElement Day(string label, double open, double high, double low, double close, int volume) =>
        new(label, open, high, low, close) { Tag = volume };

    // Without a Tag, Add chains candles:
    // new DwsChartCandlestickData().Add("Mar 2", 100.0, 103.2, 99.1, 102.6).Add("Mar 3", 102.6, 104.8, 101.9, 104.1);
}

Fixed value range

Min and Max fix the ends of the value axis instead of taking them from the data.

  • Rising (13)
  • Falling (7)
Show Code
CandlestickChart.razor

<DwsSwitch Name="CandlestickChartDemo_FixedRange" Class="mb-3" @bind-Value="_fixedRange" Label="Min = 80, Max = 130" />
<DwsChartCandlestick Name="CandlestickChartDemo_Range" ChartData="@_prices" Min="@(_fixedRange ? 80 : null)" Max="@(_fixedRange ? 130 : null)" />

@code {
    private bool _fixedRange = true;

    // A share's daily open, high, low and close in March; the Tag carries the traded volume.
    private readonly DwsChartCandlestickData _prices = new()
    {
        Candles =
        [
            Day("Mar 2", 100.0, 103.2, 99.1, 102.6, 1_204_000), Day("Mar 3", 102.6, 104.8, 101.9, 104.1, 1_388_000),
            Day("Mar 4", 104.1, 104.5, 100.8, 101.3, 1_650_000), Day("Mar 5", 101.3, 102.0, 98.4, 99.0, 1_902_000),
            Day("Mar 6", 99.0, 101.7, 98.7, 101.2, 1_120_000), Day("Mar 9", 101.2, 105.9, 100.9, 105.4, 2_015_000),
            Day("Mar 10", 105.4, 108.2, 104.6, 107.7, 1_840_000), Day("Mar 11", 107.7, 108.0, 105.1, 105.6, 1_310_000),
            Day("Mar 12", 105.6, 106.3, 102.2, 103.0, 1_575_000), Day("Mar 13", 103.0, 104.1, 101.5, 103.9, 990_000),
            Day("Mar 16", 103.9, 109.4, 103.5, 108.8, 2_230_000), Day("Mar 17", 108.8, 112.6, 108.1, 111.9, 2_480_000),
            Day("Mar 18", 111.9, 113.0, 109.2, 109.8, 1_760_000), Day("Mar 19", 109.8, 110.5, 106.7, 107.1, 1_690_000),
            Day("Mar 20", 107.1, 111.3, 106.9, 110.8, 1_430_000), Day("Mar 23", 110.8, 115.2, 110.2, 114.6, 2_105_000),
            Day("Mar 24", 114.6, 117.9, 113.8, 117.2, 2_640_000), Day("Mar 25", 117.2, 118.1, 114.0, 114.5, 1_980_000),
            Day("Mar 26", 114.5, 116.4, 113.2, 116.0, 1_215_000), Day("Mar 27", 116.0, 118.3, 114.9, 116.0, 1_050_000),
        ]
    };

    private static DwsChartCandlestickDataElement Day(string label, double open, double high, double low, double close, int volume) =>
        new(label, open, high, low, close) { Tag = volume };

    // Without a Tag, Add chains candles:
    // new DwsChartCandlestickData().Add("Mar 2", 100.0, 103.2, 99.1, 102.6).Add("Mar 3", 102.6, 104.8, 101.9, 104.1);
}

Value format

ValueFormat formats the values of the axis, the tooltip and the accessible names in the current culture, here as euros with two decimals.

  • Rising (13)
  • Falling (7)
Show Code
CandlestickChart.razor

<DwsChartCandlestick Name="CandlestickChartDemo_ValueFormat" ChartData="@_prices" ValueFormat="0.00 €" />

@code {
    // A share's daily open, high, low and close in March; the Tag carries the traded volume.
    private readonly DwsChartCandlestickData _prices = new()
    {
        Candles =
        [
            Day("Mar 2", 100.0, 103.2, 99.1, 102.6, 1_204_000), Day("Mar 3", 102.6, 104.8, 101.9, 104.1, 1_388_000),
            Day("Mar 4", 104.1, 104.5, 100.8, 101.3, 1_650_000), Day("Mar 5", 101.3, 102.0, 98.4, 99.0, 1_902_000),
            Day("Mar 6", 99.0, 101.7, 98.7, 101.2, 1_120_000), Day("Mar 9", 101.2, 105.9, 100.9, 105.4, 2_015_000),
            Day("Mar 10", 105.4, 108.2, 104.6, 107.7, 1_840_000), Day("Mar 11", 107.7, 108.0, 105.1, 105.6, 1_310_000),
            Day("Mar 12", 105.6, 106.3, 102.2, 103.0, 1_575_000), Day("Mar 13", 103.0, 104.1, 101.5, 103.9, 990_000),
            Day("Mar 16", 103.9, 109.4, 103.5, 108.8, 2_230_000), Day("Mar 17", 108.8, 112.6, 108.1, 111.9, 2_480_000),
            Day("Mar 18", 111.9, 113.0, 109.2, 109.8, 1_760_000), Day("Mar 19", 109.8, 110.5, 106.7, 107.1, 1_690_000),
            Day("Mar 20", 107.1, 111.3, 106.9, 110.8, 1_430_000), Day("Mar 23", 110.8, 115.2, 110.2, 114.6, 2_105_000),
            Day("Mar 24", 114.6, 117.9, 113.8, 117.2, 2_640_000), Day("Mar 25", 117.2, 118.1, 114.0, 114.5, 1_980_000),
            Day("Mar 26", 114.5, 116.4, 113.2, 116.0, 1_215_000), Day("Mar 27", 116.0, 118.3, 114.9, 116.0, 1_050_000),
        ]
    };

    private static DwsChartCandlestickDataElement Day(string label, double open, double high, double low, double close, int volume) =>
        new(label, open, high, low, close) { Tag = volume };

    // Without a Tag, Add chains candles:
    // new DwsChartCandlestickData().Add("Mar 2", 100.0, 103.2, 99.1, 102.6).Add("Mar 3", 102.6, 104.8, 101.9, 104.1);
}

Many candles

Half a year of daily candles: the candles get thinner, every candle keeps a full-height hover target, and MaxLabelCount (here 6) limits the labels below the drawing to every n-th candle. Page Up/Down jump by that many candles.

  • Rising (77)
  • Falling (53)
Show Code
CandlestickChart.razor

@using System.Globalization

<DwsChartCandlestick Name="CandlestickChartDemo_Many" ChartData="@_halfYear" MaxLabelCount="6" Height="300" />

@code {
    private readonly DwsChartCandlestickData _halfYear = BuildHalfYear();

    // A random walk over 130 trading days, the same every time.
    private static DwsChartCandlestickData BuildHalfYear()
    {
        Random random = new(122);
        DwsChartCandlestickData data = new();
        DateOnly day = new(2026, 1, 5);
        double close = 48;

        while (data.Candles.Count < 130)
        {
            if (day.DayOfWeek is not (DayOfWeek.Saturday or DayOfWeek.Sunday))
            {
                double open = close + (random.NextDouble() - 0.5) * 0.8;
                close = Math.Max(5, open + (random.NextDouble() - 0.47) * 3);
                double high = Math.Max(open, close) + random.NextDouble() * 1.2;
                double low = Math.Min(open, close) - random.NextDouble() * 1.2;

                data.Add(day.ToString("MMM d", CultureInfo.InvariantCulture), Math.Round(open, 2), Math.Round(high, 2), Math.Round(low, 2), Math.Round(close, 2));
            }

            day = day.AddDays(1);
        }

        return data;
    }
}

Time axis with gaps

By default the candles stand side by side, whatever lies between them. With TimeAxis they are placed by their Time: the axis runs from the first candle to the last in steps of the shortest distance between two candles (here one day), so the two weekends and the holiday on Wednesday the 14th show as gaps. Add(time, open, high, low, close) sets the Time and labels the candle with its short date.

  • Rising (8)
  • Falling (6)
Show Code
CandlestickChart.razor

<DwsSwitch Name="CandlestickChartDemo_TimeAxis" @bind-Value="_timeAxis" Label="TimeAxis" Class="mb-3" />
<DwsChartCandlestick Name="CandlestickChartDemo_TimeAxisChart" ChartData="@_threeWeeks" TimeAxis="@_timeAxis" Height="300" />

@code {
    private bool _timeAxis = true;

    // Three trading weeks in October 2026: no candles on the weekends, nor on Wednesday the 14th.
    private readonly DwsChartCandlestickData _threeWeeks = new DwsChartCandlestickData()
        .Add(new DateTime(2026, 10, 5), 101.2, 103.8, 100.4, 103.1)
        .Add(new DateTime(2026, 10, 6), 103.1, 104.6, 102.0, 102.4)
        .Add(new DateTime(2026, 10, 7), 102.4, 105.9, 102.1, 105.2)
        .Add(new DateTime(2026, 10, 8), 105.2, 106.3, 103.7, 104.0)
        .Add(new DateTime(2026, 10, 9), 104.0, 104.9, 101.8, 102.2)
        .Add(new DateTime(2026, 10, 12), 100.6, 102.7, 99.5, 102.3)
        .Add(new DateTime(2026, 10, 13), 102.3, 104.4, 101.9, 104.1)
        .Add(new DateTime(2026, 10, 15), 106.0, 108.2, 105.4, 107.6)
        .Add(new DateTime(2026, 10, 16), 107.6, 108.0, 105.1, 105.8)
        .Add(new DateTime(2026, 10, 19), 104.9, 106.6, 104.2, 106.1)
        .Add(new DateTime(2026, 10, 20), 106.1, 109.3, 105.8, 108.9)
        .Add(new DateTime(2026, 10, 21), 108.9, 110.4, 107.7, 108.2)
        .Add(new DateTime(2026, 10, 22), 108.2, 108.8, 106.0, 106.5)
        .Add(new DateTime(2026, 10, 23), 106.5, 107.9, 105.6, 107.4);
}

Calendar ticks

With CalendarTicks (on by default) a time axis prints calendar ticks from the shared date scale - here the beginnings of the weeks, in the current language's format and week start, also where a tick falls into a gap - instead of the labels of every n-th candle; MaxLabelCount is the most ticks it may print (raise it to 20 for one tick a day).

  • Rising (8)
  • Falling (6)
Show Code
CandlestickChart.razor

<DwsSwitch Name="CandlestickChartDemo_CalendarTicks" @bind-Value="_calendarTicks" Label="CalendarTicks" />
<DwsSwitch Name="CandlestickChartDemo_DailyTicks" @bind-Value="_dailyTicks" Label="MaxLabelCount 20 (a tick a day)" />
<DwsChartCandlestick Name="CandlestickChartDemo_CalendarTicksChart" ChartData="@_threeWeeks" TimeAxis="true" CalendarTicks="@_calendarTicks"
                     Height="300" MaxLabelCount="@(_dailyTicks ? 20 : 5)" />

@code {
    private bool _calendarTicks = true;
    private bool _dailyTicks;

    // Three trading weeks in October 2026: no candles on the weekends, nor on Wednesday the 14th.
    private readonly DwsChartCandlestickData _threeWeeks = new DwsChartCandlestickData()
        .Add(new DateTime(2026, 10, 5), 101.2, 103.8, 100.4, 103.1)
        .Add(new DateTime(2026, 10, 6), 103.1, 104.6, 102.0, 102.4)
        .Add(new DateTime(2026, 10, 7), 102.4, 105.9, 102.1, 105.2)
        .Add(new DateTime(2026, 10, 8), 105.2, 106.3, 103.7, 104.0)
        .Add(new DateTime(2026, 10, 9), 104.0, 104.9, 101.8, 102.2)
        .Add(new DateTime(2026, 10, 12), 100.6, 102.7, 99.5, 102.3)
        .Add(new DateTime(2026, 10, 13), 102.3, 104.4, 101.9, 104.1)
        .Add(new DateTime(2026, 10, 15), 106.0, 108.2, 105.4, 107.6)
        .Add(new DateTime(2026, 10, 16), 107.6, 108.0, 105.1, 105.8)
        .Add(new DateTime(2026, 10, 19), 104.9, 106.6, 104.2, 106.1)
        .Add(new DateTime(2026, 10, 20), 106.1, 109.3, 105.8, 108.9)
        .Add(new DateTime(2026, 10, 21), 108.9, 110.4, 107.7, 108.2)
        .Add(new DateTime(2026, 10, 22), 108.2, 108.8, 106.0, 106.5)
        .Add(new DateTime(2026, 10, 23), 106.5, 107.9, 105.6, 107.4);
}

Volume

Candles with a Volume get a pane of bars under them (ShowVolume, VolumeHeight, VolumeFormat): a bar takes the color of its candle and shares its slot, so pointing at either shows the same tooltip. The accessible name of a candle says its volume too.

Share price, eight weeks
  • Rising (21)
  • Falling (19)
Show Code
CandlestickChart.razor

<DwsSwitch Name="CandlestickChartDemo_Overlay_Volume" Class="mb-3" @bind-Value="_showVolume" Label="ShowVolume" />
<DwsChartCandlestick Name="CandlestickChartDemo_Overlay" ChartData="@_quarter" Title="Share price, eight weeks" Height="440"
                     ShowVolume="@_showVolume" TimeAxis="true" VolumeFormat="#,0" />

@code {
    private bool _showVolume = true;

    // Eight trading weeks of daily candles; the sixth number of a candle is its volume.
    private readonly DwsChartCandlestickData _quarter = BuildQuarter();

    private static DwsChartCandlestickData BuildQuarter()
    {
        DwsChartCandlestickData data = new();
        DateTime day = new(2026, 8, 3);
        double close = 84;

        for (int index = 0; index < 40; index++)
        {
            double open = close + Math.Sin(index * 1.7) * 0.6;
            close = open + Math.Sin(index * 0.9) * 2.2 + Math.Cos(index * 0.31) * 1.4 + 0.25;
            double high = Math.Max(open, close) + 0.6 + Math.Abs(Math.Sin(index * 2.3)) * 1.2;
            double low = Math.Min(open, close) - 0.6 - Math.Abs(Math.Cos(index * 1.9)) * 1.2;
            double volume = Math.Round(12000 + Math.Abs(close - open) * 9000 + Math.Abs(Math.Sin(index * 0.7)) * 8000);

            data.Add(day, Math.Round(open, 2), Math.Round(high, 2), Math.Round(low, 2), Math.Round(close, 2), volume);
            day = day.AddDays(day.DayOfWeek == DayOfWeek.Friday ? 3 : 1);
        }

        return data;
    }

    // Or on an element: new DwsChartCandlestickDataElement("Mon", 84, 86.1, 83.2, 85.4) { Volume = 24500 }
}

Moving averages

MovingAverages draws the mean of the last closes as lines over the candles - here over 5 and 20 days -, each with a legend entry (MovingAverageColors sets their colors). MovingAverageKind Exponential draws exponential averages (EMA), which follow recent closes faster.

  • Rising (21)
  • Falling (19)
  • MA 5
  • MA 20
Show Code
CandlestickChart.razor

<DwsSwitch Name="CandlestickChartDemo_Overlay_Ema" Class="mb-3" @bind-Value="_exponentialAverages" Label="MovingAverageKind Exponential" />
<DwsChartCandlestick Name="CandlestickChartDemo_Averages" ChartData="@_quarter" Height="360" ShowVolume="false" TimeAxis="true"
                     MovingAverages="@_averagePeriods"
                     MovingAverageKind="@(_exponentialAverages ? DwsChartMovingAverageKind.Exponential : DwsChartMovingAverageKind.Simple)" />

@code {
    private static readonly int[] _averagePeriods = [5, 20];
    private bool _exponentialAverages;

    // Eight trading weeks of daily candles; the sixth number of a candle is its volume.
    private readonly DwsChartCandlestickData _quarter = BuildQuarter();

    private static DwsChartCandlestickData BuildQuarter()
    {
        DwsChartCandlestickData data = new();
        DateTime day = new(2026, 8, 3);
        double close = 84;

        for (int index = 0; index < 40; index++)
        {
            double open = close + Math.Sin(index * 1.7) * 0.6;
            close = open + Math.Sin(index * 0.9) * 2.2 + Math.Cos(index * 0.31) * 1.4 + 0.25;
            double high = Math.Max(open, close) + 0.6 + Math.Abs(Math.Sin(index * 2.3)) * 1.2;
            double low = Math.Min(open, close) - 0.6 - Math.Abs(Math.Cos(index * 1.9)) * 1.2;
            double volume = Math.Round(12000 + Math.Abs(close - open) * 9000 + Math.Abs(Math.Sin(index * 0.7)) * 8000);

            data.Add(day, Math.Round(open, 2), Math.Round(high, 2), Math.Round(low, 2), Math.Round(close, 2), volume);
            day = day.AddDays(day.DayOfWeek == DayOfWeek.Friday ? 3 : 1);
        }

        return data;
    }

    // Or on an element: new DwsChartCandlestickDataElement("Mon", 84, 86.1, 83.2, 85.4) { Volume = 24500 }
}

Readout

The line above the chart reads out the open, high, low, close, change, volume and averages of the candle under the pointer or with the focus, and of the last candle otherwise (ShowReadout).

  • Rising (21)
  • Falling (19)
Show Code
CandlestickChart.razor

<DwsSwitch Name="CandlestickChartDemo_Overlay_Readout" Class="mb-3" @bind-Value="_showReadout" Label="ShowReadout" />
<DwsChartCandlestick Name="CandlestickChartDemo_Readout" ChartData="@_quarter" Height="400" TimeAxis="true" ShowCrosshair="false"
                     ShowReadout="@_showReadout" />

@code {
    private bool _showReadout = true;

    // Eight trading weeks of daily candles; the sixth number of a candle is its volume.
    private readonly DwsChartCandlestickData _quarter = BuildQuarter();

    private static DwsChartCandlestickData BuildQuarter()
    {
        DwsChartCandlestickData data = new();
        DateTime day = new(2026, 8, 3);
        double close = 84;

        for (int index = 0; index < 40; index++)
        {
            double open = close + Math.Sin(index * 1.7) * 0.6;
            close = open + Math.Sin(index * 0.9) * 2.2 + Math.Cos(index * 0.31) * 1.4 + 0.25;
            double high = Math.Max(open, close) + 0.6 + Math.Abs(Math.Sin(index * 2.3)) * 1.2;
            double low = Math.Min(open, close) - 0.6 - Math.Abs(Math.Cos(index * 1.9)) * 1.2;
            double volume = Math.Round(12000 + Math.Abs(close - open) * 9000 + Math.Abs(Math.Sin(index * 0.7)) * 8000);

            data.Add(day, Math.Round(open, 2), Math.Round(high, 2), Math.Round(low, 2), Math.Round(close, 2), volume);
            day = day.AddDays(day.DayOfWeek == DayOfWeek.Friday ? 3 : 1);
        }

        return data;
    }

    // Or on an element: new DwsChartCandlestickDataElement("Mon", 84, 86.1, 83.2, 85.4) { Volume = 24500 }
}

Share price over six months

A share from January to June: every trading day (Monday to Friday), added with its date and volume, on a time axis with calendar ticks in the current language. The 20-day average shows the trend, the volume pane the turnover, and the readout above the chart the candle under the pointer (else the last one). The chart lays out its labels for its own width, and the last candle stays inside. On a phone, tap a candle: the nearest one is selected and its tooltip stays pinned until you tap elsewhere or press Escape.

Share price, January to June
  • Rising (73)
  • Falling (55)
  • MA 20

After a weak March the share recovered to a new high in June.

Show Code
CandlestickChart.razor

<DwsChartCandlestick Name="CandlestickChartDemo_SixMonths" ChartData="@_sixMonths" Title="Share price, January to June"
                     TimeAxis="true" ShowVolume="true" VolumeFormat="#,0" MovingAverages="@_sixMonthAverages" ValueFormat="0.00 €"
                     Height="420" Caption="After a weak March the share recovered to a new high in June." />

@code {
    private readonly DwsChartCandlestickData _sixMonths = BuildSixMonths();
    private static readonly int[] _sixMonthAverages = [20];

    // The trading days from January to June 2026 with their volume; the same numbers on every visit.
    private static DwsChartCandlestickData BuildSixMonths()
    {
        DwsChartCandlestickData data = new();
        DateTime day = new(2026, 1, 2);
        double close = 62;
        int index = 0;

        while (day.Month <= 6)
        {
            if (day.DayOfWeek is not (DayOfWeek.Saturday or DayOfWeek.Sunday))
            {
                // A dip in March, a recovery after it.
                double drift = index is > 40 and < 60 ? -0.45 : 0.22;
                double open = close + Math.Sin(index * 1.3) * 0.5;
                close = open + drift + Math.Sin(index * 0.8) * 1.1 + Math.Cos(index * 0.37) * 0.7;
                double high = Math.Max(open, close) + 0.3 + Math.Abs(Math.Sin(index * 2.1)) * 0.9;
                double low = Math.Min(open, close) - 0.3 - Math.Abs(Math.Cos(index * 1.7)) * 0.9;
                double volume = Math.Round(40000 + Math.Abs(close - open) * 30000 + Math.Abs(Math.Sin(index * 0.6)) * 25000);

                // The sixth number is the volume; the date labels the candle and places it on the time axis.
                data.Add(day, Math.Round(open, 2), Math.Round(high, 2), Math.Round(low, 2), Math.Round(close, 2), volume);
                index++;
            }

            day = day.AddDays(1);
        }

        return data;
    }
}

On a phone: caption, loading and empty content

The chart measures its own width (not the window's) and lays its labels out for it: as many axis labels as fit, labels at the edges run inward, long labels are cut at a word with the full text in their title and tooltip, and the legend goes below. On a touch screen a tap shows the nearest mark's tooltip until the next tap elsewhere or Escape. Caption puts a sentence under the chart that is also its accessible description, IsLoading shows a spinner instead of the drawing, and EmptyContent replaces the no-data text.

  • Rising (77)
  • Falling (53)

Half a year of daily candles, drawn 320px wide.

Nothing recorded yet - data appears here after the first import.

Show Code
CandlestickChart.razor
<button @onclick='() => _phoneLoading = !_phoneLoading'>IsLoading = @_phoneLoading</button>

<div style='max-width: 320px;'>
    <DwsChartCandlestick Name='CandlestickChartDemo_Phone' ChartData='@_halfYear' IsLoading='@_phoneLoading' Caption='Half a year of daily candles, drawn 320px wide.' />
</div>

<DwsChartCandlestick Name='CandlestickChartDemo_EmptyContent' ChartData='null'>
    <EmptyContent>
        <DwsTypography Name='CandlestickChartDemo_EmptyContentText' Typography='DwsTypographyType.Paragraph'>Nothing recorded yet - data appears here after the first import.</DwsTypography>
    </EmptyContent>
</DwsChartCandlestick>

Empty

Without candles the chart shows NoDataText (or the localized default).

No data to display
Show Code
CandlestickChart.razor

<DwsChartCandlestick Name="CandlestickChartDemo_Empty" ChartData="null" />

Interface-Description

Name Typ Parameters Description
GetDataAsCsv string CultureInfo? culture The data the chart was given as CSV text (RFC 4180, CRLF, a header line): one row per mark in data order, the values as passed in. Null writes numbers the invariant way with commas between the cells; a culture writes them its way with its list separator. Text a spreadsheet would run as a formula gets an apostrophe in front.
ExportDataAsync Task string? fileName, CultureInfo? culture Downloads GetDataAsCsv() as a .csv file (UTF-8 with a byte order mark). Null names the file after the chart's title, else its Name.
FocusAsync ValueTask bool containedInScrollableList Focuses the candle that takes part in the tab order: the first one, or the one the user was on last. Does nothing while the chart is hidden, empty, disabled or in permission select mode.
Name Typ Default Description
ChartData DwsChartCandlestickData? null The candles to draw, left to right: each DwsChartCandlestickDataElement has a Label, Open, High, Low, Close and an optional Tag. Add(label, open, high, low, close) chains candles. A High below Open/Close or a Low above them is widened to enclose them; a candle with NaN or infinity is skipped (both logged as a warning). Null, or no candle, shows NoDataText.
Title string? null Caption above the chart, also its accessible name.
NoDataText string? null Text shown when there is nothing to draw. Null uses the localized "No data to display".
EmptyContent RenderFragment? null Shown instead of NoDataText when there is nothing to draw.
IsLoading bool false The data is still on its way: a spinner with the localized "Loading..." instead of the drawing (under static SSR the same, without motion). Also sets the component's loading state.
Caption string? null A sentence under the chart (source, note, takeaway) in a <p class="dws-chart-caption">, referenced by the chart's aria-describedby.
Width int? null Width in px. Never wider than the container unless MinWidth asks for more. Null fills the container.
Height int? null Height in px, caption, axes and legend included; the drawing takes what is left. Null gives the drawing 15rem.
MinWidth int? null Smallest width in px; the only size that may make the chart wider than its container.
MaxWidth int? null Largest width in px, and never more than the container.
MinHeight int? null Smallest height in px; the drawing grows to fill it.
MaxHeight int? null Largest height in px; the drawing shrinks to fit it.
RisingColor DwsColor DwsColor.Success Theme color of a candle that closed at or above its open (a CSS variable, so the chart follows the active theme). Undefined uses Success.
FallingColor DwsColor DwsColor.Error Theme color of a candle that closed below its open. Undefined uses Error.
HollowRising bool false Draws the bodies of rising candles as an outline, which tells the two kinds apart without color.
Min double? null Lower end of the value axis. Null starts at the tick below the lowest low. Lower values are drawn at the edge; Min above Max is swapped with a warning.
Max double? null Upper end of the value axis. Null ends at the tick above the highest high. Higher values are drawn at the edge.
TickCount int 5 About how many values the value axis labels, 2 to 12 (others are clamped with a warning); the steps are 1, 2, 2.5 or 5 times a power of ten.
ShowValueAxis bool true Shows the value axis with its labels left of the drawing.
ShowGrid bool true Draws a horizontal line at every labelled value.
ShowLabels bool true Shows the candles' labels below the drawing.
MaxLabelCount int 8 Most labels shown below the drawing; with more candles only every n-th is labelled. Page Up/Down jump by n candles.
TimeAxis bool false Places the candles by the Time of their data element instead of side by side: the axis runs from the first candle to the last in steps of the shortest distance between two candles, so periods without a candle (weekends, holidays, missing data) show as gaps. Needs a Time on every candle in ascending order and at most 2000 steps; otherwise the candles are drawn side by side and a warning is logged. DwsChartCandlestickData.Add(time, open, high, low, close, label) sets the Time; without a label the candle gets the short date.
CalendarTicks bool true With TimeAxis, labels the axis with calendar ticks from DwsChartTimeScale (minutes, hours, days, weeks, months or years: the finest step that needs at most MaxLabelCount ticks, never finer than the candles' own period) in the current culture's formats and week start, instead of with the labels of every n-th candle. A tick stands under the period that begins at it, candle or gap; one at which a larger unit begins (a new month on a day axis) is bold. False keeps the candles' labels; without TimeAxis it does nothing.
ShowVolume bool true Shows the Volume of the candles (DwsChartCandlestickDataElement.Volume, or the Add overloads with a volume) as bars in a pane under them, when at least one candle has one. A bar takes the color of its candle; the tooltip, the readout and the accessible name of a candle say its volume, and the CSV export gets a column for it.
VolumeHeight double 0.22 Share of the plot's height the volume pane takes, 0.1 to 0.5.
VolumeFormat string "#,0.##" .NET number format for the volume, in the current UI culture.
MovingAverages IReadOnlyList<int>? null Periods of the moving averages drawn as lines over the candles, e.g. [5, 20]: the mean of the closes of that many candles up to and including the one it stands at (a simple moving average). At most four; periods below 2 and repeated ones are skipped with a warning. Each line gets a legend entry, and DwsChartCandlestickCandle.MovingAverages / MovingAverageTexts hold the values for templates and events.
MovingAverageColors IReadOnlyList<DwsColor>? null Theme colors of the moving-average lines, in the order of MovingAverages, repeated when there are more lines. Null or empty uses Info, Warning, Accent and Primary.
MovingAverageKind DwsChartMovingAverageKind Simple How the moving-average lines average the closes: Simple (the plain mean, "MA") or Exponential (recent closes count more, "EMA"; starts with the simple average of the first period).
ShowCrosshair bool true Marks the hovered or focused candle with a line through it (through its volume bar too) and a line at its close, whose value stands on the value axis.
ShowReadout bool true Shows a line above the chart with the open, high, low, close and change (and the volume and moving averages, when shown) of the hovered or focused candle, and of the last candle while none is.
ValueFormat string "#,0.##" .NET number format for the axis, the tooltip and the accessible names, in the current UI culture. An invalid format falls back to the default with a warning.
WithLegend bool true Shows the rising and falling colors, each with its number of candles. Hovering an entry fades the candles of the other kind.
LegendPosition DwsChartLegendPosition DwsChartLegendPosition.Bottom Bottom, Top, Right or Left of the drawing. Right and Left move below it on screens narrower than 576px.
ShowTooltip bool true Shows the values of the hovered or focused candle; on touch screens a tap shows it. Escape hides it until the next candle.
TooltipTemplate RenderFragment<DwsChartCandlestickCandle>? null Content of the tooltip. Null shows the label, open, high, low, close and the change.
Name Typ Description
OnCandleClick EventCallback<DwsChartCandlestickCandle> Raised when a candle is clicked, tapped or activated with Enter/Space. Not raised while disabled or in permission select mode (a click then selects the chart).
OnCandleHover EventCallback<DwsChartCandlestickCandle?> Raised when the pointer or focus enters a candle, and with null when neither is on a candle any more: also when the chart stops reacting or new data no longer has the candle.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.