ian
ian10mo ago

Displaying multiple layers of charts

Displaying multiple layers of charts seems to be a problem. E.g. a simple errorbar plot: source = pd.DataFrame({ "yield_error": [7.5522, 6.9775, 3.9167, 11.9732], "yield_center": [32.4, 30.96667, 33.966665, 30.45], "variety": ["Glabron", "Manchuria", "No. 457", "No. 462"], }) bar = alt.Chart(source).mark_errorbar(ticks=True).encode( x=alt.X("yield_center:Q").scale(zero=False).title("yield"), xError=("yield_error:Q"), y=alt.Y("variety:N"), ).properties(width="container") point = alt.Chart(source).mark_point( filled=True, color="black" ).encode( alt.X("yield_center:Q"), alt.Y("variety:N"), ) this_chart = bar + point display = mo.ui.altair_chart(this_chart, chart_selection="point") this_chart The native display looks fine but mo.vstack([display, display.value]) looks wrong and is not really showing the errorbars.
7 Replies
Myles Scolnick
Myles Scolnick10mo ago
It looks like at some point, we convert floats to strings by accident. ill look into this today and let you know when we fix this I have a fix here: https://github.com/marimo-team/marimo/pull/739. Will be in the next release
ian
ianOP10mo ago
@Myles Scolnick : the latest release does fix the display issue but the chart.value is always empty and neither point or interval selection seems to work. display = mo.ui.altair_chart(this_chart, chart_selection="interval") mo.vstack([display, display.value]) With interval I can see an issue with how you would choose which layer's dataframe to pass but point selection should not be an issue.
Myles Scolnick
Myles Scolnick10mo ago
i should probably add a note somewhere, but i hadnt implemented the selection with altair stacked charts i can look into this though i have a fix - ill put it up in a bit
ian
ianOP10mo ago
@Myles Scolnick , the selection is working beautifully and making my life much easier, thank you! @Myles Scolnick how do you choose which layer is going into the selection? I can't see how to change which layer is chosen by changing the order in which they are combined.
Myles Scolnick
Myles Scolnick10mo ago
I think right now it blindly does to both. I was originally going to choose one, but I didn’t think it changed the end result
ian
ianOP10mo ago
Hmm, for me it just picks one of the layers.
Myles Scolnick
Myles Scolnick10mo ago
is that causing issues? if you print chart.selection or chart.value does it have what you expect?