use std::collections::BTreeMap;
use zenith_core::{ChartSeries, Diagnostic, ResolvedToken};
use crate::ir::Color;
use super::super::paint::resolve_property_color;
pub(super) const SERIES_PALETTE: [Color; 8] = [
Color::srgb(66, 133, 244, 255), Color::srgb(234, 67, 53, 255), Color::srgb(52, 168, 83, 255), Color::srgb(251, 188, 4, 255), Color::srgb(255, 109, 0, 255), Color::srgb(103, 58, 183, 255), Color::srgb(0, 172, 193, 255), Color::srgb(233, 30, 99, 255), ];
pub(super) fn series_color(
series: &ChartSeries,
idx: usize,
resolved: &BTreeMap<String, ResolvedToken>,
diagnostics: &mut Vec<Diagnostic>,
chart_id: &str,
) -> Color {
series
.color
.as_ref()
.and_then(|prop| resolve_property_color(prop, resolved, diagnostics, chart_id))
.unwrap_or_else(|| {
SERIES_PALETTE
.get(idx % SERIES_PALETTE.len())
.copied()
.unwrap_or(Color::srgb(66, 133, 244, 255))
})
}