Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Setcliponaxis: false by default for bar traces withtext andtextposition: 'auto' or'outside'#7558

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
emilykl wants to merge5 commits intomaster
base:master
Choose a base branch
Loading
fromcliponaxis-false-bars
Open
Show file tree
Hide file tree
Changes fromall commits
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
1 change: 1 addition & 0 deletionsdraftlogs/7558_fix.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
- Set `cliponaxis: false` by default for bar traces with `text` and `textposition: 'auto'` or `'outside'`, to prevent text clipping [#7558](https://github.com/plotly/plotly.js/pull/7558)
13 changes: 12 additions & 1 deletionsrc/traces/bar/defaults.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -148,7 +148,18 @@ function handleText(traceIn, traceOut, layout, coerce, textposition, opts) {
if(moduleHasSelected) coerce('selected.textfont.color');
if(moduleHasUnselected) coerce('unselected.textfont.color');
if(moduleHasConstrain) coerce('constraintext');
if(moduleHasCliponaxis) coerce('cliponaxis');
if(moduleHasCliponaxis) {
if(traceOut.text && ['auto', 'outside'].includes(textposition)) {
// When `textposition` is `'outside'` (or `auto`), bar labels outside
// the bar are very frequently clipped since text is not included
// in autorange calculations. So we set `cliponaxis` to `false` by default
// in that case to prevent clipping; otherwise we use the normal default
// for `cliponaxis`, which is `true`.
coerce('cliponaxis', false);
} else {
coerce('cliponaxis');
}
}
if(moduleHasTextangle) coerce('textangle');

coerce('texttemplate');
Expand Down
4 changes: 3 additions & 1 deletionsrc/traces/scatter/attributes.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -362,7 +362,9 @@ module.exports = {
'Determines whether or not markers and text nodes',
'are clipped about the subplot axes.',
'To show markers and text nodes above axis lines and tick labels,',
'make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.'
'make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.',
'Defaults to *true*, except for bar traces with `textposition` set to *auto* or *outside*',
'in which case the default is *false*.'
].join(' ')
},

Expand Down
Binary file modifiedtest/image/baselines/zz-pattern_bars-path.png
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletionstest/jasmine/tests/bar_test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,6 +217,65 @@ describe('Bar.supplyDefaults', function() {
expect(traceOut.insidetextfont.size).toBe(20);
});

it('should set cliponaxis to false when text has value and textposition is outside', function() {
traceIn = {
y: [1, 2, 3],
text: ['A', 'B', 'C'],
textposition: 'outside'
};
supplyDefaults(traceIn, traceOut, defaultColor, {});
expect(traceOut.cliponaxis).toBe(false);
});

it('should set cliponaxis to false when text has value and textposition is auto', function() {
traceIn = {
y: [1, 2, 3],
text: ['A', 'B', 'C'],
textposition: 'auto'
};
supplyDefaults(traceIn, traceOut, defaultColor, {});
expect(traceOut.cliponaxis).toBe(false);
});

it('should set cliponaxis to false when text has value and textposition is unspecified', function() {
traceIn = {
y: [1, 2, 3],
text: ['A', 'B', 'C'],
};
supplyDefaults(traceIn, traceOut, defaultColor, {});
expect(traceOut.cliponaxis).toBe(false);
});

it('should set cliponaxis to default (true) when text is not provided', function() {
traceIn = {
y: [1, 2, 3],
textposition: 'outside'
};
supplyDefaults(traceIn, traceOut, defaultColor, {});
expect(traceOut.cliponaxis).toBe(true);
});

it('should set cliponaxis to default (true) when textposition is not outside', function() {
traceIn = {
y: [1, 2, 3],
text: ['A', 'B', 'C'],
textposition: 'inside'
};
supplyDefaults(traceIn, traceOut, defaultColor, {});
expect(traceOut.cliponaxis).toBe(true);
});

it('should respect explicit cliponaxis setting even with text and outside position', function() {
traceIn = {
y: [1, 2, 3],
text: ['A', 'B', 'C'],
textposition: 'outside',
cliponaxis: true
};
supplyDefaults(traceIn, traceOut, defaultColor, {});
expect(traceOut.cliponaxis).toBe(true);
});

it('should inherit layout.calendar', function() {
traceIn = {
x: [1, 2, 3],
Expand Down
8 changes: 4 additions & 4 deletionstest/plot-schema.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58647,7 +58647,7 @@
"valType": "string"
},
"cliponaxis": {
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*. Defaults to *true*, except for bar traces with `textposition` set to *auto* or *outside* in which case the default is *false*.",
"dflt": true,
"editType": "plot",
"valType": "boolean"
Expand DownExpand Up@@ -74276,7 +74276,7 @@
"animatable": false,
"attributes": {
"cliponaxis": {
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*. Defaults to *true*, except for bar traces with `textposition` set to *auto* or *outside* in which case the default is *false*.",
"dflt": false,
"editType": "plot",
"valType": "boolean"
Expand DownExpand Up@@ -78753,7 +78753,7 @@
"animatable": false,
"attributes": {
"cliponaxis": {
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*. Defaults to *true*, except for bar traces with `textposition` set to *auto* or *outside* in which case the default is *false*.",
"dflt": false,
"editType": "plot",
"valType": "boolean"
Expand DownExpand Up@@ -81062,7 +81062,7 @@
"valType": "data_array"
},
"cliponaxis": {
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*.",
"description": "Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to *below traces*. Defaults to *true*, except for bar traces with `textposition` set to *auto* or *outside* in which case the default is *false*.",
"dflt": true,
"editType": "plot",
"valType": "boolean"
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp