from typing import Optional

from attrs import field, define
from attrs.validators import instance_of, optional, deep_iterable
from src.data_classes.parameters_visualization import PlotParameters


@define
class BarChartPlotParameters(PlotParameters):
    variable_x_axis: str = field(validator=instance_of(str))
    variable_y_axis: Optional[str] = field(validator=optional(instance_of(str)))
    chart_orientation: str = field(validator=instance_of(str))
    sort_order: str = field(validator=instance_of(str))
    custom_order: Optional[list[str]] = field(
        default=None,
        validator=optional(
            deep_iterable(
                member_validator=instance_of(str), iterable_validator=instance_of(list)
            )
        ),
    )
