Skip to main content

densa_chart/
palette.rs

1use densa_core::Color;
2
3/// Chart colors: [`ChartPalette::new`] is the dark default; change its fields for others.
4#[derive(Debug, Clone, Copy, PartialEq)]
5#[non_exhaustive]
6pub struct ChartPalette {
7    /// Behind the plot and its labels.
8    pub background: Color,
9    /// Gridlines at the ticks.
10    pub grid: Color,
11    /// The plot's bottom and right edges.
12    pub axis: Color,
13    /// Tick labels.
14    pub label: Color,
15    /// A line series without a color of its own.
16    pub line: Color,
17    /// Rising values: candles that closed up.
18    pub up: Color,
19    /// Falling values: candles that closed down.
20    pub down: Color,
21    /// The crosshair's lines.
22    pub crosshair: Color,
23    /// Behind the crosshair's values.
24    pub marker: Color,
25    /// The crosshair's values.
26    pub marker_text: Color,
27}
28
29impl ChartPalette {
30    /// The default dark palette.
31    pub fn new() -> Self {
32        Self {
33            background: Color::srgb(0x0D1117),
34            grid: Color::srgb(0x161B22),
35            axis: Color::srgb(0x30363D),
36            label: Color::srgb(0x8B949E),
37            line: Color::srgb(0x58A6FF),
38            up: Color::srgb(0x3FB950),
39            down: Color::srgb(0xF85149),
40            crosshair: Color::srgb(0x8B949E).with_alpha(0.6),
41            marker: Color::srgb(0x484F58),
42            marker_text: Color::srgb(0xF0F6FC),
43        }
44    }
45}
46
47impl Default for ChartPalette {
48    fn default() -> Self {
49        Self::new()
50    }
51}