MCPcopy Create free account
hub / github.com/alceal/plotlars / determine_bar_mode

Function determine_bar_mode

crates/plotlars-plotly/src/subplot_grid/shared.rs:628–656  ·  view source on GitHub ↗
(
    traces_list: &[Vec<Box<dyn Trace + 'static>>],
)

Source from the content-addressed store, hash-verified

626}
627
628pub(super) fn determine_bar_mode(
629 traces_list: &[Vec<Box<dyn Trace + 'static>>],
630) -> Option<plotly::layout::BarMode> {
631 let mut has_histogram = false;
632 let mut has_barplot = false;
633
634 for traces in traces_list {
635 for trace in traces {
636 let json_str = trace.to_json();
637 if let Ok(json) = serde_json::from_str::<Value>(&json_str) {
638 if let Some(trace_type) = json.get("type").and_then(|v| v.as_str()) {
639 match trace_type {
640 "histogram" => has_histogram = true,
641 "bar" => has_barplot = true,
642 _ => {}
643 }
644 }
645 }
646 }
647 }
648
649 if has_histogram {
650 Some(plotly::layout::BarMode::Overlay)
651 } else if has_barplot {
652 Some(plotly::layout::BarMode::Group)
653 } else {
654 None
655 }
656}
657
658pub(super) fn determine_box_mode(
659 traces_list: &[Vec<Box<dyn Trace + 'static>>],

Callers 2

create_regular_layoutFunction · 0.85
create_irregular_layoutFunction · 0.85

Calls 1

to_jsonMethod · 0.45

Tested by

no test coverage detected