I have this interactive plot with a slider bar over the 'Time' field. My problems are:
- The font is different from the other texts in the plot (both with Chrome and Edge). I looked at the doc but I could not find a way to change it. Is it possible?
- I cannot set the
init
attribute of the slider properly. Following the example doc I try to setinit={'Time': 3}
(I need it to be at the end), but I get the following error
selector = alt.selection_single(
File "C:\Users\sparisi\Anaconda3\lib\site-packages\altair\vegalite\v5\api.py", line 395, in selection_single
return selection(type="point", **kwargs)
File "C:\Users\sparisi\Anaconda3\lib\site-packages\altair\vegalite\v5\api.py", line 365, in selection
return parameter(select=select, **param_kwds)
File "C:\Users\sparisi\Anaconda3\lib\site-packages\altair\vegalite\v5\api.py", line 319, in parameter
parameter.param = core.SelectionParameter(
File "C:\Users\sparisi\Anaconda3\lib\site-packages\altair\vegalite\v5\schema\core.py", line 14283, in __init__
super(SelectionParameter, self).__init__(name=name, select=select, bind=bind, value=value,
File "C:\Users\sparisi\Anaconda3\lib\site-packages\altair\utils\schemapi.py", line 177, in __init__
self.to_dict(validate=True)
File "C:\Users\sparisi\Anaconda3\lib\site-packages\altair\utils\schemapi.py", line 340, in to_dict
raise SchemaValidationError(self, err)
altair.utils.schemapi.SchemaValidationError: Invalid specification
altair.vegalite.v5.schema.core.SelectionParameter->0, validating 'type'
3 is not of type 'array'
CodePudding user response:
Since you are a bit ahead of the curve (since you are on vegalite V5 already), you can use the upcoming parameter
for interactivity in Altair. See here for some examples https://christopherdavisuci.github.io/UCI-Math-10/param.html
Especially the transform-filter section is relevant for you.
Here you see the init
is replaced with a value
parameter.
Regarding the init
error you observe. I cannot reproduce this using the example you refer to (see this colab notebook), so I suspect something else is wrong. If you prepare a minimum reproducible example I can have a look again.
Regarding the font of the sliders. There is no known syntax in altair for doing this, but if it is important for you, you can overrule the css. See this SO answer for an example https://stackoverflow.com/a/62104504/2459096