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

Wrap Labels for the Trend Indicator #2229

Closed
tlmille2 opened this issue Apr 22, 2021 · 3 comments · Fixed by #2483
Closed

Wrap Labels for the Trend Indicator #2229

tlmille2 opened this issue Apr 22, 2021 · 3 comments · Fixed by #2483
Labels
type: enhancement Minor feature or improvement to an existing feature
Milestone

Comments

@tlmille2
Copy link

When your labels are a long number of character's, with underscores, the Trend Indicator doesn't wrap the labels. The long label names will then 'misbehave' their css properties. Padding the Trend Indicator is a temporary fix, but it would be nice if a trend indicator can support wrapping of labels.

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Apr 22, 2021

Hi @tlmille2

Thanks for reporting.

It would help a lot of you provided a minimum, reproducible example and a screenshot of the problem. Could you do that?

And please add the css of the temporary fix or a true fix. Thanks.

Thanks.

@philippjfr philippjfr added the type: enhancement Minor feature or improvement to an existing feature label Apr 23, 2021
@tlmille2
Copy link
Author

@MarcSkovMadsen - Here's a reproducible example and screenshot

Example

import pandas as pd
import panel as pn
  
data = [[1, 10, 15], [2, 15, 20], [3, 20, 25], 
       [4, 25, 30], [5, 30, 35], [6, 35, 40], 
       [7, 40, 45], [8, 45, 50], [9, 50, 55]]
  
df = pd.DataFrame(data, columns = ['week', 'TEST_LONG_NAME_WITH_UNDERSCORE_1', 'TEST_LONG_NAME_WITH_UNDERSCORE_2'])

columns = df.columns

list_of_trend = []

for i in columns:
    data = df[['week', i]]
    data = data.rename(columns={"week": "x", i: "y"})
    
    trend = pn.indicators.Trend(title=i, data=data, width=200, height=200, plot_type='area')
    
    list_of_trend.append(trend)
    
pn.Row(list_of_trend[0], list_of_trend[1], list_of_trend[2])

image

Temporary Fix Using Margins

The temporary fix is to add margins to the indicator widget

import pandas as pd
import panel as pn
  
data = [[1, 10, 15], [2, 15, 20], [3, 20, 25], 
       [4, 25, 30], [5, 30, 35], [6, 35, 40], 
       [7, 40, 45], [8, 45, 50], [9, 50, 55]]
  
df = pd.DataFrame(data, columns = ['week', 'TEST_LONG_NAME_WITH_UNDERSCORE_1', 'TEST_LONG_NAME_WITH_UNDERSCORE_2'])

columns = df.columns

list_of_trend = []

for i in columns:
    data = df[['week', i]]
    data = data.rename(columns={"week": "x", i: "y"})
    
    trend = pn.indicators.Trend(title=i, data=data, width=200, height=200, plot_type='area', margin=(25, 50))
    
    list_of_trend.append(trend)
    
pn.Row(list_of_trend[0], list_of_trend[1], list_of_trend[2])

image

@philippjfr
Copy link
Member

Thanks @tlmille2!

@philippjfr philippjfr added this to the v0.11.4 milestone Apr 23, 2021
@philippjfr philippjfr modified the milestones: v0.11.4, v0.12.0 Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants