Candlesticks
A candlestick shows how a value moved within each period: where it started, how high and low it went, and where it ended. Prices, but also measurements: the first, highest, lowest and last temperature per hour or day.
From readings
Give CandlestickSeries the raw readings and a Bucket: the readings of each hour (or day, week, …) become
one candle, in the series color: a rising period is lightly filled, a falling one solid. Three
weeks of hourly candles are too narrow to see, so they merge into longer periods of the clock and calendar (6 or 12 hours, days,
depending on the width) that keep the highs and lows; drag to zoom in and the hours come back.
Code
<RioChart TItem="Reading" Items="readings" Zoomable="true">
<CandlestickSeries Name="Outdoor" XValue="r => r.Time" YValue="r => r.Value"
Bucket="TimeBucket.Hour" Format="0.0 °C" />
</RioChart>
@code {
record Reading(DateTime Time, double? Value); // every 15 minutes
}From numbers computed elsewhere
With one item per period, pass OpenValue, HighValue, LowValue and CloseValue.
For prices, DirectionColors="true" colors rising candles green and falling ones red (--rio-positive and
--rio-negative) and adds the change in percent to the tooltip. It is off by default: red and green read as good
and bad, and a percentage of, say, a temperature means nothing. Here a line on the same chart shows the average of each
day's first and last price.
Code
<RioChart TItem="PriceDay" Items="prices">
<CandlestickSeries Name="Price" XValue="p => p.Date" OpenValue="p => p.First" HighValue="p => p.Highest"
LowValue="p => p.Lowest" CloseValue="p => p.Last" Format="0.0 €" DirectionColors="true" />
<LineSeries Name="Midpoint" XValue="p => p.Date" YValue="p => (p.First + p.Last) / 2" />
</RioChart>In JSON definitions
"type": "candlestick" (also "ohlc", "candle") with a time x, y and a
timeBucket makes candles from the rows' y values per bucket (a day when not set). With open, high
and low, each row is a candle and y its close. "directionColors": true colors candles by direction.