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 label alignment option to axis label title #6521

Merged
merged 11 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Documentation and style fixes
  • Loading branch information
el committed Sep 16, 2019
commit 7ecdf3a2e26a6ed0cf0b3111a2ba9b10bc3a50db
2 changes: 1 addition & 1 deletion docs/axes/labelling.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The scale label configuration is nested under the scale configuration in the `sc
| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
| `display` | `boolean` | `false` | If true, display the axis title.
| `labelAlign` | `string` | `center` | Alignment of the axis title. Possible options are `start`, `center` and `end`
| `labelAlign` | `string` | `'center'` | Alignment of the axis title. Possible options are `'start'`, `'center'` and `'end'`
| `labelString` | `string` | `''` | The text for the title. (i.e. "# of People" or "Response Choices").
| `lineHeight` | <code>number&#124;string</code> | `1.2` | Height of an individual line of text (see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height)).
| `fontColor` | `Color` | `'#666'` | Font color for scale title.
Expand Down
10 changes: 4 additions & 6 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,7 @@ var Scale = Element.extend({
var scaleLabelX, scaleLabelY, textAlign;

if (me.isHorizontal()) {
switch (scaleLabelAlign)
{
switch (scaleLabelAlign) {
case 'start':
scaleLabelX = me.left;
textAlign = 'left';
Expand All @@ -1234,14 +1233,13 @@ var Scale = Element.extend({
? me.left + halfLineHeight + scaleLabelPadding.top
: me.right - halfLineHeight - scaleLabelPadding.top;
var height = me.height;
switch (scaleLabelAlign)
{
switch (scaleLabelAlign) {
case 'start':
scaleLabelY = me.top + ( isLeft ? height : 0 );
scaleLabelY = me.top + (isLeft ? height : 0);
textAlign = isLeft ? 'left' : 'right';
break;
case 'end':
scaleLabelY = me.top + ( isLeft ? 0 : height );
scaleLabelY = me.top + (isLeft ? 0 : height);
textAlign = isLeft ? 'left' : 'right';
break;
default:
Expand Down