πŸ“ sections.box_plotΒΆ

Builds the Box Plot section for the report.

This function retrieves configuration for box plot analysis from the report builder, initializes the appropriate analyzer and plotter classes with their parameters, computes the necessary data for box plots, generates the corresponding plots, and returns a dictionary containing both the computed data and chart metadata (including a base64-encoded image).

FunctionsΒΆ

owlmix.reporting.sections.box_plot.build_box_plot_section(report_builder)ΒΆ
Parameters:

report_builder (ReportBuilderProtocol) – The report builder instance containing the dataframe and configuration.

Returns:

A dictionary with keys:

  • data: The computed box plot results.

  • chart: Metadata and image for the generated plot, including:

    • title: Title of the chart.

    • description: Description of the chart.

    • alt_text: Alternative text for the image.

    • images: Dictionary with base64-encoded image(s) of the plot.

Return type:

dict

Workflow:

  1. Retrieves the box plot configuration from the report builder.

  2. Fetches the analyzer and plotter classes and their parameter classes from the registries.

  3. Initializes analyzer and plotter parameter objects using the configuration.

  4. Instantiates the analyzer with the DataFrame and parameters, then computes the box plot data.

  5. Instantiates the plotter with the computed data and plot parameters, then generates the plot.

  6. Converts the plot image to a base64 string for embedding in the report.

  7. Returns a dictionary containing both the computed data and chart metadata.

Example Usage:

section = build_box_plot_section(report_builder)
data = section["data"]
chart = section["chart"]

DependenciesΒΆ

  • os: For file path operations.

  • register_section, ANALYZERS_REGISTRY, PLOTTERS_REGISTRY: For section registration and dynamic class retrieval.

  • ReportBuilderProtocol: Protocol for the report builder object.

RegistriesΒΆ

  • ANALYZERS_REGISTRY["box_plot"]: Provides the analyzer class and its parameter class for box plots.

  • PLOTTERS_REGISTRY["box_plot"]: Provides the plotter class and its parameter class for box plots.

Section RegistrationΒΆ

The function is registered as a report section under the name "box_plot" using the @register_section decorator.

@register_section("box_plot")
def build_box_plot_section(report_builder: ReportBuilderProtocol) -> Dict[str, Any]:
    ...

See AlsoΒΆ

Back to Home