Skip to content

Per-trace axis extremes #2849

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

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
67db333
add axis.range under visible edits test
etpinard Jul 25, 2018
3e817f3
add findExtremes
etpinard Jul 25, 2018
1cd8482
add _extremes to all traces in calc
etpinard Jul 25, 2018
e9d3ca0
adapt getAutoRange and doAutoRange to trace _extremes
etpinard Jul 25, 2018
2966cf3
generalize concatExtremes for polar, splom and layout components
etpinard Jul 25, 2018
a9cf2e1
replace Axes.expand -> findExtremes in traces/
etpinard Jul 25, 2018
13cb0f0
replace Axex.expand -> findExtremes in annotations and shapes
etpinard Jul 25, 2018
d24eaef
replace Axes.expand -> findExtremes for ErrorBars
etpinard Jul 25, 2018
d9bb617
:hocho: ax._min / ax._max logic for rangeslider
etpinard Jul 25, 2018
9b02ac4
adapt enforceConstraints to new per trace/item _extremes
etpinard Jul 25, 2018
d407c90
adapt polar to new per trace/item _extremes
etpinard Jul 25, 2018
9ab0c2f
:hocho: obsolete comments about ax._min / ax._max
etpinard Jul 25, 2018
6e866c2
adapt gl2d to findExtremes
etpinard Jul 26, 2018
c45427b
:hocho: Axes.expand
etpinard Jul 26, 2018
e77cacc
adapt test for Axex.expand -> findExtremes change
etpinard Jul 26, 2018
ba3c903
adapt test to new getAutoRange API
etpinard Jul 26, 2018
424f4a6
sub fail -> failTest
etpinard Jul 26, 2018
4c250c3
setPositions even when recalc===false
etpinard Jul 26, 2018
5becba0
udpdate jsdoc for Axes.getAutoRange
etpinard Jul 26, 2018
66df51e
use ax.(_traceIndices, annIndices, shapeIndices)
etpinard Jul 27, 2018
d0699c0
fixups (from AJ's review)
etpinard Jul 27, 2018
f1cda60
add bar stack visible -> autorange test & move 'b' init to setPositions
etpinard Jul 27, 2018
9a78013
make annotations & shapes 'visible' -> 'plot' edit type
etpinard Jul 27, 2018
5cfee13
Revert "make annotations & shapes 'visible' -> 'plot' edit type"
etpinard Jul 30, 2018
62f1549
add fallback for _extremes during concat
etpinard Jul 30, 2018
aac11a2
collapse trace extremes before getAutorange
etpinard Jul 30, 2018
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
adapt test to new getAutoRange API
  • Loading branch information
etpinard committed Jul 26, 2018
commit ba3c903aaffe7615a80d54e4da452263fed3fe79
332 changes: 153 additions & 179 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1421,234 +1421,208 @@ describe('Test axes', function() {

describe('getAutoRange', function() {
var getAutoRange = Axes.getAutoRange;
var ax;
var gd, ax;

it('returns reasonable range without explicit rangemode or autorange', function() {
ax = {
_min: [
// add in an extrapad to verify that it gets used on _min
// with a _length of 100, extrapad increases pad by 5
{val: 1, pad: 15, extrapad: true},
{val: 3, pad: 0},
{val: 2, pad: 10}
],
_max: [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20},
],
function mockGd(min, max) {
return {
_fullData: [{
type: 'scatter',
visible: true,
xaxis: 'x',
_extremes: {
x: {min: min, max: max}
}
}],
_fullLayout: {}
};
}

function mockAx() {
return {
_id: 'x',
type: 'linear',
_length: 100
};
}

expect(getAutoRange(ax)).toEqual([-0.5, 7]);
it('returns reasonable range without explicit rangemode or autorange', function() {
gd = mockGd([
// add in an extrapad to verify that it gets used on _min
// with a _length of 100, extrapad increases pad by 5
{val: 1, pad: 15, extrapad: true},
{val: 3, pad: 0},
{val: 2, pad: 10}
], [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20}
]);
ax = mockAx();

expect(getAutoRange(gd, ax)).toEqual([-0.5, 7]);
});

it('reverses axes', function() {
ax = {
_min: [
{val: 1, pad: 20},
{val: 3, pad: 0},
{val: 2, pad: 10}
],
_max: [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20},
],
type: 'linear',
autorange: 'reversed',
rangemode: 'normal',
_length: 100
};
gd = mockGd([
{val: 1, pad: 20},
{val: 3, pad: 0},
{val: 2, pad: 10}
], [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20}
]);
ax = mockAx();
ax.autorange = 'reversed';
ax.rangemode = 'normarl';

expect(getAutoRange(ax)).toEqual([7, -0.5]);
expect(getAutoRange(gd, ax)).toEqual([7, -0.5]);
});

it('expands empty range', function() {
ax = {
_min: [
{val: 2, pad: 0}
],
_max: [
{val: 2, pad: 0}
],
type: 'linear',
rangemode: 'normal',
_length: 100
};
gd = mockGd([
{val: 2, pad: 0}
], [
{val: 2, pad: 0}
]);
ax = mockAx();
ax.rangemode = 'normal';

expect(getAutoRange(ax)).toEqual([1, 3]);
expect(getAutoRange(gd, ax)).toEqual([1, 3]);
});

it('returns a lower bound of 0 on rangemode tozero with positive points', function() {
ax = {
_min: [
{val: 1, pad: 20},
{val: 3, pad: 0},
{val: 2, pad: 10}
],
_max: [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20},
],
type: 'linear',
rangemode: 'tozero',
_length: 100
};
gd = mockGd([
{val: 1, pad: 20},
{val: 3, pad: 0},
{val: 2, pad: 10}
], [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20}
]);
ax = mockAx();
ax.rangemode = 'tozero';

expect(getAutoRange(ax)).toEqual([0, 7]);
expect(getAutoRange(gd, ax)).toEqual([0, 7]);
});

it('returns an upper bound of 0 on rangemode tozero with negative points', function() {
ax = {
_min: [
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
],
_max: [
{val: -5, pad: 20},
{val: -4, pad: 0},
{val: -6, pad: 10},
],
type: 'linear',
rangemode: 'tozero',
_length: 100
};
gd = mockGd([
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
], [
{val: -5, pad: 20},
{val: -4, pad: 0},
{val: -6, pad: 10},
]);
ax = mockAx();
ax.rangemode = 'tozero';

expect(getAutoRange(ax)).toEqual([-12.5, 0]);
expect(getAutoRange(gd, ax)).toEqual([-12.5, 0]);
});

it('returns a positive and negative range on rangemode tozero with positive and negative points', function() {
ax = {
_min: [
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
],
_max: [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20},
],
type: 'linear',
rangemode: 'tozero',
_length: 100
};
gd = mockGd([
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
], [
{val: 6, pad: 10},
{val: 7, pad: 0},
{val: 5, pad: 20}
]);
ax = mockAx();
ax.rangemode = 'tozero';

expect(getAutoRange(ax)).toEqual([-15, 10]);
expect(getAutoRange(gd, ax)).toEqual([-15, 10]);
});

it('reverses range after applying rangemode tozero', function() {
ax = {
_min: [
{val: 1, pad: 20},
{val: 3, pad: 0},
{val: 2, pad: 10}
],
_max: [
// add in an extrapad to verify that it gets used on _max
{val: 6, pad: 15, extrapad: true},
{val: 7, pad: 0},
{val: 5, pad: 10},
],
type: 'linear',
autorange: 'reversed',
rangemode: 'tozero',
_length: 100
};
gd = mockGd([
{val: 1, pad: 20},
{val: 3, pad: 0},
{val: 2, pad: 10}
], [
// add in an extrapad to verify that it gets used on _max
{val: 6, pad: 15, extrapad: true},
{val: 7, pad: 0},
{val: 5, pad: 10}
]);
ax = mockAx();
ax.autorange = 'reversed';
ax.rangemode = 'tozero';

expect(getAutoRange(ax)).toEqual([7.5, 0]);
expect(getAutoRange(gd, ax)).toEqual([7.5, 0]);
});

it('expands empty positive range to something including 0 with rangemode tozero', function() {
ax = {
_min: [
{val: 5, pad: 0}
],
_max: [
{val: 5, pad: 0}
],
type: 'linear',
rangemode: 'tozero',
_length: 100
};
gd = mockGd([
{val: 5, pad: 0}
], [
{val: 5, pad: 0}
]);
ax = mockAx();
ax.rangemode = 'tozero';

expect(getAutoRange(ax)).toEqual([0, 6]);
expect(getAutoRange(gd, ax)).toEqual([0, 6]);
});

it('expands empty negative range to something including 0 with rangemode tozero', function() {
ax = {
_min: [
{val: -5, pad: 0}
],
_max: [
{val: -5, pad: 0}
],
type: 'linear',
rangemode: 'tozero',
_length: 100
};
gd = mockGd([
{val: -5, pad: 0}
], [
{val: -5, pad: 0}
]);
ax = mockAx();
ax.rangemode = 'tozero';

expect(getAutoRange(ax)).toEqual([-6, 0]);
expect(getAutoRange(gd, ax)).toEqual([-6, 0]);
});

it('never returns a negative range when rangemode nonnegative is set with positive and negative points', function() {
ax = {
_min: [
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
],
_max: [
{val: 6, pad: 20},
{val: 7, pad: 0},
{val: 5, pad: 10},
],
type: 'linear',
rangemode: 'nonnegative',
_length: 100
};
gd = mockGd([
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
], [
{val: 6, pad: 20},
{val: 7, pad: 0},
{val: 5, pad: 10}
]);
ax = mockAx();
ax.rangemode = 'nonnegative';

expect(getAutoRange(ax)).toEqual([0, 7.5]);
expect(getAutoRange(gd, ax)).toEqual([0, 7.5]);
});

it('never returns a negative range when rangemode nonnegative is set with only negative points', function() {
ax = {
_min: [
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
],
_max: [
{val: -5, pad: 20},
{val: -4, pad: 0},
{val: -6, pad: 10},
],
type: 'linear',
rangemode: 'nonnegative',
_length: 100
};
gd = mockGd([
{val: -10, pad: 20},
{val: -8, pad: 0},
{val: -9, pad: 10}
], [
{val: -5, pad: 20},
{val: -4, pad: 0},
{val: -6, pad: 10}
]);
ax = mockAx();
ax.rangemode = 'nonnegative';

expect(getAutoRange(ax)).toEqual([0, 1]);
expect(getAutoRange(gd, ax)).toEqual([0, 1]);
});

it('expands empty range to something nonnegative with rangemode nonnegative', function() {
ax = {
_min: [
{val: -5, pad: 0}
],
_max: [
{val: -5, pad: 0}
],
type: 'linear',
rangemode: 'nonnegative',
_length: 100
};
gd = mockGd([
{val: -5, pad: 0}
], [
{val: -5, pad: 0}
]);
ax = mockAx();
ax.rangemode = 'nonnegative';

expect(getAutoRange(ax)).toEqual([0, 1]);
expect(getAutoRange(gd, ax)).toEqual([0, 1]);
});
});

Expand Down
Loading