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

Function determine_box_mode

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

Source from the content-addressed store, hash-verified

656}
657
658pub(super) fn determine_box_mode(
659 traces_list: &[Vec<Box<dyn Trace + 'static>>],
660) -> Option<plotly::layout::BoxMode> {
661 let mut has_grouped_box = false;
662
663 for traces in traces_list {
664 if traces.len() > 1 {
665 for trace in traces {
666 let json_str = trace.to_json();
667 if let Ok(json) = serde_json::from_str::<Value>(&json_str) {
668 if let Some(trace_type) = json.get("type").and_then(|v| v.as_str()) {
669 if trace_type == "box" {
670 has_grouped_box = true;
671 break;
672 }
673 }
674 }
675 }
676 }
677
678 if has_grouped_box {
679 break;
680 }
681 }
682
683 if has_grouped_box {
684 Some(plotly::layout::BoxMode::Group)
685 } else {
686 None
687 }
688}
689
690#[cfg(test)]
691mod tests {

Callers 2

create_regular_layoutFunction · 0.85
create_irregular_layoutFunction · 0.85

Calls 1

to_jsonMethod · 0.45

Tested by

no test coverage detected