pub enum Timeframe {
Show 18 variants
Ms100,
Ms250,
Ms500,
Sec1,
Sec2,
Sec5,
Sec10,
Sec30,
Min1,
Min5,
Min15,
Min30,
Hour1,
Hour4,
Day1,
Week1,
Month1,
Custom(u64),
}Expand description
Timeframe for bar aggregation.
Each variant represents a fixed time interval over which OHLCV data is aggregated
into a single Bar. The default timeframe is Min1.
Timeframes are divided into tiers:
| Tier | Variants |
|---|---|
| Millisecond | Ms100, Ms250, Ms500 |
| Second | Sec1 .. Sec30 |
| Minute | Min1, Min5, Min15, Min30 |
| Hourly | Hour1, Hour4 |
| Daily+ | Day1, Week1, Month1 |
| Custom | Custom(seconds) – any user-defined interval |
§Example
use egui_charts::model::Timeframe;
let tf = Timeframe::Hour4;
assert_eq!(tf.duration_ms(), 14_400_000);
assert_eq!(tf.to_string(), "4h");Variants§
Ms100
100-millisecond bars (HFT).
Ms250
250-millisecond bars (HFT).
Ms500
500-millisecond bars (HFT).
Sec1
1-second bars.
Sec2
2-second bars.
Sec5
5-second bars.
Sec10
10-second bars.
Sec30
30-second bars.
Min1
1-minute bars (default).
Min5
5-minute bars.
Min15
15-minute bars.
Min30
30-minute bars.
Hour1
1-hour bars.
Hour4
4-hour bars.
Day1
Daily bars.
Week1
Weekly bars.
Month1
Monthly bars (approximated as 30 days for duration calculations).
Custom(u64)
Custom timeframe defined in seconds. Allows user-defined intervals (e.g., 45s, 3min, 2h).
Implementations§
Source§impl Timeframe
impl Timeframe
Sourcepub fn as_str(&self) -> Cow<'static, str>
pub fn as_str(&self) -> Cow<'static, str>
Returns the canonical string label for this timeframe (e.g. "1min", "4h", "1D").
Sourcepub fn duration_ms(&self) -> i64
pub fn duration_ms(&self) -> i64
Get duration in milliseconds
Sourcepub fn total_seconds(&self) -> u64
pub fn total_seconds(&self) -> u64
Get the number of seconds for this timeframe
Sourcepub fn as_seconds(self) -> i64
pub fn as_seconds(self) -> i64
Convert timeframe to seconds (signed, for range calculations)
Sourcepub fn to_seconds(self) -> i64
pub fn to_seconds(self) -> i64
Alias for as_seconds for backward compatibility
Sourcepub fn from_resolution(resolution: &str) -> Option<Self>
pub fn from_resolution(resolution: &str) -> Option<Self>
Convert a resolution string to Timeframe