Skip to content

Re-add support for passing title as string #7230

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

Closed
wants to merge 6 commits into from

Conversation

emilykl
Copy link
Contributor

@emilykl emilykl commented Oct 17, 2024

@@ -228,4 +228,10 @@ module.exports = overrideAll({
].join(' ')
}
},
_deprecated: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about dropping the deprecation here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I see then it would collide with the the title which is declared as an object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best way of handing these cases today is to change the title valType to be any and then support both String and Object types so that when title is a string title.text is set to the string.
How about opening a new PR with this approach?

Copy link
Contributor Author

@emilykl emilykl Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archmoj That sounds fine but I'm unsure about the attributes syntax for accepting both an object (with specific nested keys) and a string... this is the attribute definition right now for title in colorbar:

    title: {
        text: {
            valType: 'string',
            description: 'Sets the title of the color bar.'
        },
        font: fontAttrs({
            description: 'Sets this color bar\'s title font.'
        }),
        side: {
            valType: 'enumerated',
            values: ['right', 'top', 'bottom'],
            description: [
                'Determines the location of color bar\'s title',
                'with respect to the color bar.',
                'Defaults to *top* when `orientation` if *v* and ',
                'defaults to *right* when `orientation` if *h*.',
            ].join(' ')
        }
    },

My point is that there doesn't seem to be a place to define valType for title if we are also defining nested attributes under title. Do you have a suggestion?

Copy link
Contributor

@archmoj archmoj Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see what @alexcjohnson would suggest here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about keeping the valType as Object with and add an extra option for this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps we should just handle this String option on the plotly.py side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archmoj Do you have an example of an extra option being used elsewhere in the codebase?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this: https://github.com/plotly/plotly.js/pull/6990/files#r1591049384
Instead of extra you may add another option to coerce and name it stringOk or something else.

@archmoj
Copy link
Contributor

archmoj commented Oct 17, 2024

We should possibly support this option on places e.g. legend.title. No?

@emilykl
Copy link
Contributor Author

emilykl commented Oct 17, 2024

We should possibly support this option on places e.g. legend.title. No?

Agreed, it makes sense to be consistent, I'll look into how much work this would be.

@gvwilson gvwilson added P1 needed for current cycle fix fixes something broken labels Nov 5, 2024
@archmoj
Copy link
Contributor

archmoj commented Nov 5, 2024

Revised in #7262.

@archmoj archmoj closed this Nov 5, 2024
@archmoj archmoj deleted the support-title-string branch November 5, 2024 17:30
Comment on lines +631 to +647
},
{
desc: 'despite passing title only as a string (backwards-compatibility)',
update: {
title: NEW_TITLE,
xaxis: {title: NEW_XTITLE},
yaxis: {title: NEW_YTITLE}
}
},
{
desc: 'despite passing title only as a string using string attributes ' +
'(backwards-compatibility)',
update: {
title: NEW_TITLE,
'xaxis.title': NEW_XTITLE,
'yaxis.title': NEW_YTITLE
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archmoj These tests should also be included in #7262 , right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix fixes something broken P1 needed for current cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants