Skip to content

Animation

ipyvizzustory.storylib.animation

A module for working with chart animations.

ipyvizzustory.storylib.animation.DataFilter

Bases: Data

A class for representing a data filter.

Source code in src/ipyvizzustory/storylib/animation.py
class DataFilter(Data):
    """A class for representing a data filter."""

    def build(self) -> dict:
        """
        A method for overwriting [Data.build][ipyvizzu.animation.Data.build] method.
        Data initialized with a `DataFilter` must contain only a filter.

        Returns:
            A dictionary contains the filter key with the filter expression.

        Raises:
            ValueError: If `DataFilter` does not contain a filter or contains anything else.
        """

        if len(self.keys()) != 1 or "filter" not in self:
            raise KeyError("Data must contain filter and only that.")
        return {"filter": self["filter"]}

build()

A method for overwriting Data.build method. Data initialized with a DataFilter must contain only a filter.

Returns:

Type Description
dict

A dictionary contains the filter key with the filter expression.

Raises:

Type Description
ValueError

If DataFilter does not contain a filter or contains anything else.

Source code in src/ipyvizzustory/storylib/animation.py
def build(self) -> dict:
    """
    A method for overwriting [Data.build][ipyvizzu.animation.Data.build] method.
    Data initialized with a `DataFilter` must contain only a filter.

    Returns:
        A dictionary contains the filter key with the filter expression.

    Raises:
        ValueError: If `DataFilter` does not contain a filter or contains anything else.
    """

    if len(self.keys()) != 1 or "filter" not in self:
        raise KeyError("Data must contain filter and only that.")
    return {"filter": self["filter"]}