pub struct CandlestickChart { /* private fields */ }Expand description
Candlestick / OHLC chart with optional volume panel and overlays.
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{Candle, CandlestickChart};
let chart = CandlestickChart::new(vec![Candle::new(10.0, 12.0, 9.0, 11.0), Candle::new(11.0, 13.0, 10.0, 12.5)]);
let area = Rect::new(0, 0, 40, 12);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl CandlestickChart
impl CandlestickChart
Sourcepub fn style(self, v: CandleStyle) -> Self
pub fn style(self, v: CandleStyle) -> Self
Bar style.
Sourcepub fn hollow(self, v: bool) -> Self
pub fn hollow(self, v: bool) -> Self
Draw bullish candle bodies hollow (outlined) and bearish ones filled.
Sourcepub fn theme(self, theme: impl Into<Theme>) -> Self
pub fn theme(self, theme: impl Into<Theme>) -> Self
Apply a Theme: bull/bear colors, axes, labels, background fill.
Colors set via CandlestickChart::colors still win.
Sourcepub fn base_style(self, style: Style) -> Self
pub fn base_style(self, style: Style) -> Self
Base style painted over the whole area (beats the theme).
Sourcepub fn candle_width(self, w: u16) -> Self
pub fn candle_width(self, w: u16) -> Self
Body width in cells (ignored for OHLC bars; min 1).
Sourcepub fn show_volume(self, v: bool) -> Self
pub fn show_volume(self, v: bool) -> Self
Show a volume histogram under the price panel.
Sourcepub fn last_price_line(self, v: bool) -> Self
pub fn last_price_line(self, v: bool) -> Self
Dashed horizontal line at the last visible close.
Sourcepub fn band(self, band: BandOverlay) -> Self
pub fn band(self, band: BandOverlay) -> Self
Add a shaded band (e.g. Bollinger) behind the candles.
Sourcepub fn pane(self, pane: IndicatorPane) -> Self
pub fn pane(self, pane: IndicatorPane) -> Self
Add an indicator sub-pane below price/volume (dropped if there is no room).
Sourcepub fn marker(self, marker: TradeMarker) -> Self
pub fn marker(self, marker: TradeMarker) -> Self
Add a buy/sell marker.
Sourcepub fn resistance(self, price: f64) -> Self
pub fn resistance(self, price: f64) -> Self
Resistance level (red dashed line labelled “R”).
Sourcepub fn volume_profile(self, v: bool) -> Self
pub fn volume_profile(self, v: bool) -> Self
Horizontal volume-by-price histogram along the right of the price panel.
Sourcepub fn x_axis(self, axis: Axis) -> Self
pub fn x_axis(self, axis: Axis) -> Self
X axis (title / label style; labels come from Candle::label).
Trait Implementations§
Source§impl Clone for CandlestickChart
impl Clone for CandlestickChart
Source§impl Debug for CandlestickChart
impl Debug for CandlestickChart
Source§impl Themed for CandlestickChart
Available on crate feature theme only.
impl Themed for CandlestickChart
theme only.Source§fn apply_theme(self, theme: &Theme) -> Self
fn apply_theme(self, theme: &Theme) -> Self
self styled from theme. Explicit per-item colors set on the
widget should keep winning over the theme.Source§fn themed(self, provider: &impl ThemeProvider) -> Self
fn themed(self, provider: &impl ThemeProvider) -> Self
ThemeProvider.Source§impl Widget for &CandlestickChart
impl Widget for &CandlestickChart
Auto Trait Implementations§
impl !RefUnwindSafe for CandlestickChart
impl !UnwindSafe for CandlestickChart
impl Forget for CandlestickChart
impl Freeze for CandlestickChart
impl Send for CandlestickChart
impl Sync for CandlestickChart
impl Unpin for CandlestickChart
impl UnsafeUnpin for CandlestickChart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more