Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add number type to annotations.text chart schema #2523

Closed
chriddyp opened this issue Apr 4, 2018 · 2 comments
Closed

Add number type to annotations.text chart schema #2523

chriddyp opened this issue Apr 4, 2018 · 2 comments

Comments

@chriddyp
Copy link
Member

chriddyp commented Apr 4, 2018

Similar to #2519 , in plotly/plotly.py#942 we're updating plotly.py's validation logic to automatically use the plotly.js schema.

Annotations allow numbers as text (https://codepen.io/chriddyp/pen/WzgxwK) and it's a pretty common use case in the Python library to directly pass data into the text field.

Could we add number to the valid types in the annotations schema? It's currently:

                                "text": {
                                    "valType": "string",
                                    "role": "info",
                                    "editType": "calc",
                                    "description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub> <span> are also supported."
                                },
@alexcjohnson
Copy link
Collaborator

Better: you can look at whether the attribute includes strict: true - if it does, the value must be explicitly a string, and numbers will be rejected. If it does not, we accept numbers (and ONLY numbers - not booleans or any other types) and will coerce them to strings during supplyDefaults.

@chriddyp
Copy link
Member Author

chriddyp commented Apr 5, 2018

ah very nice, that should work. fyi @jmmease

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants