I am using Plotly-Dash and need the font size of my text annotations to scale with the viewport width, as my graphs do. For various headers in my layout, I am able to directly set font-size: '1vw', however vw is not an accepted unit for setting the font-size for the style attribute of a dcc.Graph component. Here is the associated traceback:
ValueError: Invalid element(s) received for the 'size' property of scatter.textfont Invalid elements include: ['1vw', '1vw', '1vw', '1vw', '1vw', '1vw', '1vw', '1vw', '1vw', '1vw']
The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] - A tuple, list, or one-dimensional numpy array of the above
I figure that if the dcc.Graph component can accept viewport units (e.g. style = {height: 30vw, width: 30vw}) and simply convert them to pixels browser-side, then I should be able to perform a similar conversion with the font-size.
Is there a means on the Python side to retrieve the viewport width in pixels, so that I can perform my own scaling logic for the font size?
from Plotly graph component cannot accept viewport units to set text annotation font size
No comments:
Post a Comment