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

Function create_regular_layout

crates/plotlars-plotly/src/subplot_grid/regular.rs:358–579  ·  view source on GitHub ↗
(
    grid_config: &GridConfig,
    plot_title: Option<Text>,
    subplot_titles: &[Option<Text>],
    axis_configs: &[(AxisConfig, AxisConfig)],
    legends: Option<Vec<Option<CustomLegend>>>,
    pe

Source from the content-addressed store, hash-verified

356
357#[allow(clippy::too_many_arguments)]
358fn create_regular_layout(
359 grid_config: &GridConfig,
360 plot_title: Option<Text>,
361 subplot_titles: &[Option<Text>],
362 axis_configs: &[(AxisConfig, AxisConfig)],
363 legends: Option<Vec<Option<CustomLegend>>>,
364 per_plot_traces: &[Vec<Box<dyn Trace + 'static>>],
365 subplot_info: &[NonCartesianLayout],
366 dimensions: Option<&Dimensions>,
367) -> (LayoutPlotly, Value) {
368 let mut layout = LayoutPlotly::new().show_legend(false);
369
370 if let Some(bar_mode) = determine_bar_mode(per_plot_traces) {
371 layout = layout.bar_mode(bar_mode);
372 }
373
374 if let Some(box_mode) = determine_box_mode(per_plot_traces) {
375 layout = layout.box_mode(box_mode);
376 }
377
378 if let Some(title) = plot_title {
379 layout = layout.title(conv::convert_text_to_title(
380 &title.with_plot_title_defaults(),
381 ));
382 }
383
384 let grid = LayoutGrid::new()
385 .rows(grid_config.rows)
386 .columns(grid_config.cols)
387 .pattern(GridPattern::Independent)
388 .x_gap(grid_config.h_gap)
389 .y_gap(grid_config.v_gap);
390
391 layout = layout.grid(grid);
392
393 for (idx, (x_config, y_config)) in axis_configs.iter().enumerate() {
394 let is_cartesian = subplot_info
395 .get(idx)
396 .map(|info| matches!(info.plot_type, PlotType::Cartesian2D))
397 .unwrap_or(true);
398
399 if !is_cartesian {
400 continue;
401 }
402
403 if let Some(x_axis) = build_axis_from_config(x_config) {
404 layout = match idx {
405 0 => layout.x_axis(x_axis),
406 1 => layout.x_axis2(x_axis),
407 2 => layout.x_axis3(x_axis),
408 3 => layout.x_axis4(x_axis),
409 4 => layout.x_axis5(x_axis),
410 5 => layout.x_axis6(x_axis),
411 6 => layout.x_axis7(x_axis),
412 7 => layout.x_axis8(x_axis),
413 _ => layout,
414 };
415 }

Callers 1

build_regularFunction · 0.85

Calls 15

determine_bar_modeFunction · 0.85
determine_box_modeFunction · 0.85
convert_text_to_titleFunction · 0.85
convert_text_to_fontFunction · 0.85
titleMethod · 0.80
columnsMethod · 0.80
rowsMethod · 0.80
with_x_title_defaultsMethod · 0.80
with_y_title_defaultsMethod · 0.80

Tested by

no test coverage detected