Plotly.js: hoverlabel formatting in unified mode

Created on 25 Mar 2020  路  6Comments  路  Source: plotly/plotly.js

The intention for unified hoverlabel formatting is that if layout.hoverlabel isn't specified, it will use the settings from layout.legend for e.g. bgcolor and font etc, otherwise it will use the layout.hoverlabel settings.

Right now it seems like neither work to override the hoverlabel formatting in x unified mode

bug

Most helpful comment

Just be careful re: all the template confusion, ideally we can just use the legend settings as the defaults for the hoverlabel settings at the coerce level, rather than interrogating the input layout directly.

Now what do you suppose will happen if you provide:

layout: {
    template: { layout: { hoverlabel: { bgcolor: 'blue' } } },
    legend: { bgcolor: 'red' }
}

I'm not sure what this should do, but we have similar inheritance scattered all around - and we I do recall we discussed this during the templates push - so it should be handled at the coerce level rather than special logic for this case.

All 6 comments

At the moment, it inherits layout.font. I'll implement what you're asking.

@nicolaskruchten @alexcjohnson is it ever possible for layout.hoverlabel to be undefined? Doesn't it always get coerced?

Oh I meant if e.g. layout.hoverlabel.bgcolor isn't specified in the input, we should fall back to layout.legend.bgcolor's coerced value in unified hovermode... makes sense?

so: layout: {} will get us a white hoverlabel, layout: {legend: {bgcolor: 'red}} will get us a red hoverlabel and layout: {legend: {bgcolor: 'red}, hoverlabel: {bgcolor: 'blue'} will get us a blue one. Ditto all the other settings in layout.hoverlabel like font etc that are in common with layout.legend.

Just be careful re: all the template confusion, ideally we can just use the legend settings as the defaults for the hoverlabel settings at the coerce level, rather than interrogating the input layout directly.

Now what do you suppose will happen if you provide:

layout: {
    template: { layout: { hoverlabel: { bgcolor: 'blue' } } },
    legend: { bgcolor: 'red' }
}

I'm not sure what this should do, but we have similar inheritance scattered all around - and we I do recall we discussed this during the templates push - so it should be handled at the coerce level rather than special logic for this case.

right sorry I meant to post this exact example... the answer is blue ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maxwell8888 picture maxwell8888  路  3Comments

nicolaskruchten picture nicolaskruchten  路  3Comments

bryaan picture bryaan  路  3Comments

boleslawmaliszewski picture boleslawmaliszewski  路  3Comments

hashimmoosavi picture hashimmoosavi  路  3Comments