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

Bar & ErrorBar autorange fixes #3452

Merged
merged 5 commits into from
Jan 22, 2019
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
14 changes: 9 additions & 5 deletions src/components/errorbars/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var isNumeric = require('fast-isnumeric');

var Registry = require('../../registry');
var Axes = require('../../plots/cartesian/axes');
var Lib = require('../../lib');

var makeComputeError = require('./compute_error');


module.exports = function calc(gd) {
var calcdata = gd.calcdata;

Expand Down Expand Up @@ -73,8 +72,13 @@ function calcOneAxis(calcTrace, trace, axis, coord) {
}
}

var extremes = Axes.findExtremes(axis, vals, {padded: true});
var axId = axis._id;
trace._extremes[axId].min = trace._extremes[axId].min.concat(extremes.min);
trace._extremes[axId].max = trace._extremes[axId].max.concat(extremes.max);
var baseExtremes = trace._extremes[axId];
var extremes = Axes.findExtremes(
axis,
vals,
Lib.extendFlat({tozero: baseExtremes.opts.tozero}, {padded: true})
);
baseExtremes.min = baseExtremes.min.concat(extremes.min);
baseExtremes.max = baseExtremes.max.concat(extremes.max);
}
25 changes: 15 additions & 10 deletions src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ function doAutoRange(gd, ax) {
* - ax.d2l
* @param {array} data:
* array of numbers (i.e. already run though ax.d2c)
* @param {object} options:
* @param {object} opts:
* available keys are:
* vpad: (number or number array) pad values (data value +-vpad)
* ppad: (number or number array) pad pixels (pixel location +-ppad)
Expand All @@ -308,17 +308,18 @@ function doAutoRange(gd, ax) {
* - val {number}
* - pad {number}
* - extrappad {number}
* - opts {object}: a ref to the passed "options" object
*/
function findExtremes(ax, data, options) {
if(!options) options = {};
function findExtremes(ax, data, opts) {
if(!opts) opts = {};
if(!ax._m) ax.setScale();

var minArray = [];
var maxArray = [];

var len = data.length;
var extrapad = options.padded || false;
var tozero = options.tozero && (ax.type === 'linear' || ax.type === '-');
var extrapad = opts.padded || false;
var tozero = opts.tozero && (ax.type === 'linear' || ax.type === '-');
var isLog = ax.type === 'log';
var hasArrayOption = false;
var i, v, di, dmin, dmax, ppadiplus, ppadiminus, vmin, vmax;
Expand All @@ -335,11 +336,11 @@ function findExtremes(ax, data, options) {
}

var ppadplus = makePadAccessor((ax._m > 0 ?
options.ppadplus : options.ppadminus) || options.ppad || 0);
opts.ppadplus : opts.ppadminus) || opts.ppad || 0);
var ppadminus = makePadAccessor((ax._m > 0 ?
options.ppadminus : options.ppadplus) || options.ppad || 0);
var vpadplus = makePadAccessor(options.vpadplus || options.vpad);
var vpadminus = makePadAccessor(options.vpadminus || options.vpad);
opts.ppadminus : opts.ppadplus) || opts.ppad || 0);
var vpadplus = makePadAccessor(opts.vpadplus || opts.vpad);
var vpadminus = makePadAccessor(opts.vpadminus || opts.vpad);

if(!hasArrayOption) {
// with no arrays other than `data` we don't need to consider
Expand Down Expand Up @@ -403,7 +404,11 @@ function findExtremes(ax, data, options) {
for(i = 0; i < iMax; i++) addItem(i);
for(i = len - 1; i >= iMax; i--) addItem(i);

return {min: minArray, max: maxArray};
return {
min: minArray,
max: maxArray,
opts: opts
};
}

function collapseMinArray(array, newVal, newPad, opts) {
Expand Down
Loading