'Using Altair in a Dash project - error running the app

I am facing an issue using Altair in a Dash project.

I am building an app using Dash. The plot to display on it is generated using Altair instead of Plotly-Dash. When I run the app I am receiving an error with the following message:

dash.exceptions.InvalidCallbackReturnValue: The callback for `[<Output `my-graph.figure`>, <Output `download2.data`>]`
returned a value having type `tuple`
which is not JSON serializable.

(This error originated from the built-in JavaScript code that runs Dash apps. Click to see the full stack trace or open your browser's console.)
TypeError: Cannot read properties of null (reading 'layout')

In general, Dash properties can only be dash components, strings, dictionaries, numbers, None, or lists of those.

By the last part, I think this issue is being generated by Altair plot.

So my question is: how can I solve this? I prefer to use Altair instead of Plotly.

Do any of you face a similar issue?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source