Get help from the marimo community

Updated 3 days ago

mo.ui.altair_chart() reinterpreting str x-axis as datetime.

I have a altair.Chart() which outputs fine if I render it directly but if I wrap it in a mo.ui.altair_chart() then the string x-axis values which are versions of the form "x.y.x" are getting evaluated as datetimes so the graph is exactly the same except the x-values are erroneously shown as datetimes. How can I stop this? See https://imgur.com/a/0wFfaYk. First graph is raw altair graph, second is wrapped graph.
b
M
8 comments
I've created a trivial example of this as follows. Could this be a marimo bug?
Plain Text
import marimo

__generated_with = "0.10.9"
app = marimo.App(width="medium")

@app.cell
def _():
    import pandas as _pd
    import altair as _alt
    _d = _pd.DataFrame({"Version": ["1.1.1", "2.2.2"], "Days": [3, 4]})

    ct = _alt.Chart(_d).mark_bar().encode(
            x='Version',
            y='Days',
            )
    ct
    return ct,

@app.cell
def _(ct):
    import marimo as _mo
    _mo.ui.altair_chart(ct)
    return

if __name__ == "__main__":
    app.run()
If you don’t wrap it in an altair_chart, is there still a bug?

Thanks for the minimal repro, we can fix this if it’s a marimo bug
Look at the image I posted above, 1st image is my app just rendering the chart directly as chart, the second image is merely wrapping it in mo.ui.altair_chart(chart).
Ah yea I see now. Thanks, this is a bug in marimo then. We auto-infer the data type and we should not for charts
So I should raise an issue?
That would be great, thank you very much
Add a reply
Sign up and join the conversation on Discord