Skip to content

Skip zeroline when negative sizes are present on positive base and vice versa #4714

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

Merged
merged 6 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions src/traces/bar/cross_trace_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ function setBaseAndTop(sa, sieve) {
var calcTrace = calcTraces[i];
var fullTrace = calcTrace[0].trace;
var pts = [];
var allBaseAboveZero = true;
var tozero = false;

for(var j = 0; j < calcTrace.length; j++) {
var bar = calcTrace[j];
Expand All @@ -512,13 +512,13 @@ function setBaseAndTop(sa, sieve) {
pts.push(top);
if(bar.hasB) pts.push(base);

if(!bar.hasB || !(bar.b > 0 && bar.s > 0)) {
allBaseAboveZero = false;
if(!bar.hasB || !bar.b) {
tozero = true;
}
}

fullTrace._extremes[sa._id] = Axes.findExtremes(sa, pts, {
tozero: !allBaseAboveZero,
tozero: tozero,
padded: true
});
}
Expand Down Expand Up @@ -667,7 +667,7 @@ function normalizeBars(sa, sieve, opts) {
var calcTrace = calcTraces[i];
var fullTrace = calcTrace[0].trace;
var pts = [];
var allBaseAboveZero = true;
var tozero = false;
var padded = false;

for(var j = 0; j < calcTrace.length; j++) {
Expand All @@ -690,14 +690,14 @@ function normalizeBars(sa, sieve, opts) {
padded = padded || needsPadding(base);
}

if(!bar.hasB || !(bar.b > 0 && bar.s > 0)) {
allBaseAboveZero = false;
if(!bar.hasB || !bar.b) {
tozero = true;
}
}
}

fullTrace._extremes[sa._id] = Axes.findExtremes(sa, pts, {
tozero: !allBaseAboveZero,
tozero: tozero,
padded: padded
});
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/bar-like_traces_tozero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/bar_attrs_group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/bar_attrs_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
164 changes: 164 additions & 0 deletions test/image/mocks/bar-like_traces_no-tozero.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"data": [
{
"xaxis": "x",
"yaxis": "y",
"type": "bar",
"orientation": "h",
"y": [
"A",
"B",
"C"
],
"x": [
1,
-1,
1
],
"text": [
"+1",
"-1",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": 10
},
{
"xaxis": "x2",
"yaxis": "y2",
"type": "bar",
"x": [
"E",
"F",
"G"
],
"y": [
1,
-1,
1
],
"text": [
"+1",
"-1",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": 10
},
{
"xaxis": "x3",
"yaxis": "y3",
"type": "waterfall",
"x": [
"E",
"F",
"G"
],
"y": [
1,
-2,
1
],
"text": [
"+1",
"-2",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": 10
},
{
"xaxis": "x4",
"yaxis": "y4",
"type": "waterfall",
"orientation": "h",
"y": [
"A",
"B",
"C"
],
"x": [
1,
-2,
1
],
"text": [
"+1",
"-2",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": 10
}
],
"layout": {
"width": 400,
"height": 400,
"template": {
"layout": {
"showlegend": false,
"title": {
"text": "non-zero autorange with<br>base and negative size"
},
"xaxis": {
"domain": [
0,
0.45
]
},
"yaxis": {
"domain": [
0,
0.45
]
},
"xaxis2": {
"anchor": "y2",
"domain": [
0.55,
1
]
},
"yaxis2": {
"anchor": "x2",
"domain": [
0.55,
1
]
},
"xaxis3": {
"anchor": "y3",
"domain": [
0,
0.45
]
},
"yaxis3": {
"anchor": "x3",
"domain": [
0.55,
1
]
},
"xaxis4": {
"anchor": "y4",
"domain": [
0.55,
1
]
},
"yaxis4": {
"anchor": "x4",
"domain": [
0,
0.45
]
}
}
}
}
}
164 changes: 164 additions & 0 deletions test/image/mocks/bar-like_traces_no-tozero_negative.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"data": [
{
"xaxis": "x",
"yaxis": "y",
"type": "bar",
"orientation": "h",
"y": [
"A",
"B",
"C"
],
"x": [
1,
-1,
1
],
"text": [
"+1",
"-1",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": [-10, -10, -10]
},
{
"xaxis": "x2",
"yaxis": "y2",
"type": "bar",
"x": [
"E",
"F",
"G"
],
"y": [
1,
-1,
1
],
"text": [
"+1",
"-1",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": [-10, -10, -10]
},
{
"xaxis": "x3",
"yaxis": "y3",
"type": "waterfall",
"x": [
"E",
"F",
"G"
],
"y": [
1,
-2,
1
],
"text": [
"+1",
"-2",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": -10
},
{
"xaxis": "x4",
"yaxis": "y4",
"type": "waterfall",
"orientation": "h",
"y": [
"A",
"B",
"C"
],
"x": [
1,
-2,
1
],
"text": [
"+1",
"-2",
"+1"
],
"textposition": "inside",
"insidetextanchor": "middle",
"base": -10
}
],
"layout": {
"width": 400,
"height": 400,
"template": {
"layout": {
"showlegend": false,
"title": {
"text": "non-zero autorange with<br>base and negative size"
},
"xaxis": {
"domain": [
0,
0.45
]
},
"yaxis": {
"domain": [
0,
0.45
]
},
"xaxis2": {
"anchor": "y2",
"domain": [
0.55,
1
]
},
"yaxis2": {
"anchor": "x2",
"domain": [
0.55,
1
]
},
"xaxis3": {
"anchor": "y3",
"domain": [
0,
0.45
]
},
"yaxis3": {
"anchor": "x3",
"domain": [
0.55,
1
]
},
"xaxis4": {
"anchor": "y4",
"domain": [
0.55,
1
]
},
"yaxis4": {
"anchor": "x4",
"domain": [
0,
0.45
]
}
}
}
}
}
Loading