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

Options for BarChartNode labels #34

Closed
jessegreenberg opened this issue Apr 25, 2019 · 4 comments
Closed

Options for BarChartNode labels #34

jessegreenberg opened this issue Apr 25, 2019 · 4 comments
Assignees

Comments

@jessegreenberg
Copy link
Contributor

One of the TODOs mentioned in #29 is

      if ( bar.labelString ) {
        var labelText = new RichText( bar.labelString, {
          rotation: -Math.PI / 2,
          font: new PhetFont( { size: 12, weight: 'bold' } ),
          fill: bar.entries.length === 1 ? bar.entries[ 0 ].color : 'black',
          maxWidth: 40 // TODO: Standardize
        } );

I need to set the maxWidth of the label for phetsims/energy-skate-park#31 so Ill add the options.

@jessegreenberg jessegreenberg self-assigned this Apr 25, 2019
jessegreenberg added a commit that referenced this issue Apr 26, 2019
@jessegreenberg
Copy link
Contributor Author

Done in the above commit. @Denz1994 would you please review?

@Denz1994
Copy link
Contributor

Thanks for handling this @jessegreenberg.

My only suggestion would be to allow the client to pass in options.barLabelOptions.rotation and not explicitly set it in BarChartNode.js. So options would look like this:

 // passed along to the RichText
    options.barLabelOptions = _.extend( {
      font: new PhetFont( { size: 12, weight: 'bold' } ),

      // chosen by inspection, good for short labels
      maxWidth: 40,
      rotation: -Math.PI / 2
    }, options.barLabelOptions );

This would remove the below assertion and declaration in BarChartNode.js

assert && assert( options.barLabelOptions.rotation === undefined, 'label rotation set for BarChartNode orientation' );
options.barLabelOptions.rotation = -Math.PI / 2;

The initial reason for defaulting to vertical labels was so they would fit on the x-axis in the current sims using BarChartNode.js, but there may be a future case where labels shouldn't be vertical by default (i.e. bar labels text using only numbers). Also, if we ever needed horizontal support for BarChartNode.js we may not want to keep the bars labels vertical, as noted by the TODO in the header.

/**
 * Bar chart for sims that need to display separate values
 *
 * TODO: Add horizontal support
 *

@jessegreenberg
Copy link
Contributor Author

That sounds great @Denz1994, thanks for reviewing. Done in the above commit, can you take a look? Anything else for this issue?

@Denz1994
Copy link
Contributor

Denz1994 commented May 1, 2019

Looks great. I'll close this issue. Thanks for handling this.

@Denz1994 Denz1994 closed this as completed May 1, 2019
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