Skip to content

Add timeUnit support #27

Open
Open
@kdorr

Description

@kdorr

mpl-altair currently doesn't support conversion for Altair charts that use timeUnit aggregations.

Code for reproduction

This and other timeUnit transformations don't work:

from vega_datasets import data
seattle = data.seattle_weather()

chart = alt.Chart(seattle).mark_point().encode(
    alt.X('month(date)'), alt.Y('temp_max')
)
mplaltair.convert(chart)

Actual outcome

A NotImplementedError is raised for anything that has a timeUnit.

Expected outcome

Any plot with a timeUnit transformation should work.

This plot should look something like this:

timeunit_altair

Possible solution and notes

  • Manipulate the data in parse_chart.ChannelMetadata() so that the data reflects the timeUnit aggregation. (see parse_chart.ChannelMetadata._handle_timeUnit().)
  • Also note that timeUnit transformations can also be applied separately from timeUnit transformations in the encoding channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions