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 trace legendItem styles #3735

Open
etpinard opened this issue Apr 5, 2019 · 11 comments
Open

add trace legendItem styles #3735

etpinard opened this issue Apr 5, 2019 · 11 comments
Labels
feature something new P3 not needed for current cycle

Comments

@etpinard
Copy link
Contributor

etpinard commented Apr 5, 2019

I'm thinking of adding a new trace attribute container: legenditem

{
  x: [/* */],
  y: [/* */],
  legenditem: {
    textfont: {
       color: 'red'
       size: 12
     },
     marker: {
       size: 20,
       symbol: 'circle',
       line: {width: 2, color: '#444'}
     }
  }
}

to the scatter*, bar* and pie traces to make their legend item styling configurable. This would be an easy (easier than @alexcjohnson 's legend 2.0 idea 😏 ) solution to #2967, #2080, #1701 and #1560


By the way, I'm thinking a naming this new container legenditem and not legend as I'm thinking legend could eventually be used when we implement multiple legends where e.g. legend: 'legend2' would mean "put this trace's legend item in the second legend".

One more note on @alexcjohnson 's legend 2.0 idea: having legenditem in traces wouldn't make it obsolete. We could still add a way to turn annotations into legend items later.

Thoughts?

@alexcjohnson
Copy link
Collaborator

Oh sure, if legends 2.0 ever happens it would play just fine with this. Great idea 💯

@alexcjohnson
Copy link
Collaborator

Would this idea replace #3732 or would we still continue with that?

@etpinard
Copy link
Contributor Author

etpinard commented Apr 5, 2019

Would this idea replace #3732 or would we still continue with that?

This ticket will augment (not replace) #3732

@kris16034
Copy link

I know I am a random nobody Intruding on this conversation but I have a team of data analysts that want to switch to plotly but struggle with the legend versatility (we have a variety of complicated custom plots) 3732 would greatly help. Any plans to put this in ?

@brian428
Copy link

brian428 commented Feb 5, 2021

@etpinard I know this is an older ticket but it's still a limitation for us. In our case, we have traces with multiple symbols. Right now, the legend symbol is always whatever symbol is used for the first point, which is quite confusing to our users. It would be great to have the option to specify the legend marker as you outlined in your initial comment. Any chance this will get implemented in the near future?

@brian428
Copy link

brian428 commented Feb 5, 2021

Honestly even an option to just always use a standard circle would work for us, if exposing all the other style options would be significant work. Maybe just an itemsymbol: "constant" option to go along with the itemsizing option?

brian428 pushed a commit to brian428/plotly.js that referenced this issue Feb 5, 2021
…which uses a circle symbol for all legend entries.
brian428 pushed a commit to brian428/plotly.js that referenced this issue Feb 11, 2021
… in theory the user could now specify any valid symbol name.
brian428 pushed a commit to brian428/plotly.js that referenced this issue Feb 22, 2021
…which uses a circle symbol for all legend entries.
brian428 pushed a commit to brian428/plotly.js that referenced this issue Feb 22, 2021
… in theory the user could now specify any valid symbol name.
brian428 pushed a commit to brian428/plotly.js that referenced this issue Feb 22, 2021
…which uses a circle symbol for all legend entries.
brian428 pushed a commit to brian428/plotly.js that referenced this issue Feb 22, 2021
… in theory the user could now specify any valid symbol name.
@jleape
Copy link

jleape commented Mar 10, 2021

This was an issue for a plot where I put a border around the bar with the highest value. To avoid getting a border around the legend item when the first bar is the winner, I just added buffers ([' '] and [0]) to the x and y vectors and set the xaxis range to [1:len(y)]. Not ideal, but it let me keep my square legend items, consistent with other plots.

@PlatosTwin
Copy link

PlatosTwin commented Apr 19, 2021

Any developments on this question? I can offer the following as a use case:

Within each trace I color markers and marker borders according to various criteria—but this means that when the legend is generated, marker colors and borders come out in odd combinations. It would be ideal to be able to set the legend marker color and border manually.

(I should mention that the above is with plotly.py.)

@rom3k
Copy link

rom3k commented Jan 16, 2024

Any updates on this issue?

@mhangaard
Copy link

transparent-legends

Would be great to be able to remove legenditem marker transparency for a case like this

@janjongboom
Copy link

janjongboom commented Jun 19, 2024

One workaround is to update the DOM after the graph is rendered, e.g. this sets all icons to a circle (even if the first item in the trace is e.g. a square):

for (let el of document.querySelectorAll('.legendpoints .scatterpts')) { 
    el.setAttribute('d', 'M5,0A5,5 0 1,1 0,-5A5,5 0 0,1 5,0Z'); 
}

@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson changed the title Trace legendItem styles add trace legendItem styles Aug 8, 2024
@gvwilson gvwilson added the P3 not needed for current cycle label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 not needed for current cycle
Projects
None yet
Development

No branches or pull requests

10 participants