8000 Introducing histogram* bingroup attributes by etpinard · Pull Request #3845 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Introducing histogram* bingroup attributes #3845

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 11 commits into from
May 21, 2019
Next Next commit
lint
  • Loading branch information
etpinard committed May 8, 2019
commit fd1083dbc14545a9cfc6d1ab0d6f9e5c09e72305
1 change: 0 additions & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) {
axes.autoTicks(dummyAx, size0);
}


var finalSize = dummyAx.dtick;
var binStart = axes.tickIncrement(
axes.tickFirst(dummyAx), finalSize, 'reverse', calendar);
Expand Down
1 change: 0 additions & 1 deletion src/plots/cartesian/clean_ticks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var isNumeric = require('fast-isnumeric');
Expand Down
2 changes: 1 addition & 1 deletion src/traces/bar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {

function handleGroupingDefaults(traceIn, traceOut, fullLayout, coerce) {
var orientation = traceOut.orientation;
// N.B. grouping is done across all trace trace types that support it
// N.B. grouping is done across all trace types that support it
var posAxId = traceOut[{v: 'x', h: 'y'}[orientation] + 'axis'];
var groupId = getAxisGroup(fullLayout, posAxId) + orientation;

Expand Down
2 changes: 0 additions & 2 deletions src/traces/heatmap/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var Registry = require('../../registry');
Expand All @@ -21,7 +20,6 @@ var interp2d = require('./interp2d');
var findEmpties = require('./find_empties');
var makeBoundArray = require('./make_bound_array');


module.exports = function calc(gd, trace) {
// prepare the raw data
// run makeCalcdata on x and y even for heatmaps, in case of category mappings
Expand Down
10 changes: 1 addition & 9 deletions src/traces/histogram/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var isNumeric = require('fast-isnumeric');
Expand All @@ -21,15 +20,9 @@ var doAvg = require('./average');
var getBinSpanLabelRound = require('./bin_label_vals');

module.exports = function calc(gd, trace) {
// ignore as much processing as possible (and including in autorange) if not visible
if(trace.visible !== true) return;

// depending on orientation, set position and size axes and data ranges
// note: this logic for choosing orientation is duplicated in graph_obj->setstyles
var pos = [];
var size = [];
var pa = Axes.getFromId(gd, trace.orientation === 'h' ?
(trace.yaxis || 'y') : (trace.xaxis || 'x'));
var pa = Axes.getFromId(gd, trace.orientation === 'h' ? trace.yaxis : trace.xaxis);
var mainData = trace.orientation === 'h' ? 'y' : 'x';
var counterData = {x: 'y', y: 'x'}[mainData];
var calendar = trace[mainData + 'calendar'];
Expand Down Expand Up @@ -143,7 +136,6 @@ module.exports = function calc(gd, trace) {
// after all normalization etc, now we can accumulate if desired
if(cumulativeSpec.enabled) cdf(size, cumulativeSpec.direction, cumulativeSpec.currentbin);


var seriesLen = Math.min(pos.length, size.length);
var cd = [];
var firstNonzero = 0;
Expand Down
12 changes: 5 additions & 7 deletions src/traces/histogram2d/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var Lib = require('../../lib');
Expand All @@ -17,7 +16,6 @@ var normFunctions = require('../histogram/norm_functions');
var doAvg = require('../histogram/average');
var getBinSpanLabelRound = require('../histogram/bin_label_vals');


module.exports = function calc(gd, trace) {
var xa = Axes.getFromId(gd, trace.xaxis || 'x');
var x = trace.x ? xa.makeCalcdata(trace, 'x') : [];
Expand All @@ -44,8 +42,8 @@ module.exports = function calc(gd, trace) {
var z = [];
var onecol = [];
var zerocol = [];
var nonuniformBinsX = (typeof(trace.xbins.size) === 'string');
var nonuniformBinsY = (typeof(trace.ybins.size) === 'string');
var nonuniformBinsX = typeof trace.xbins.size === 'string';
var nonuniformBinsY = typeof trace.ybins.size === 'string';
var xEdges = [];
var yEdges = [];
var xbins = nonuniformBinsX ? xEdges : trace.xbins;
Expand All @@ -55,9 +53,9 @@ module.exports = function calc(gd, trace) {
var inputPoints = [];
var norm = trace.histnorm;
var func = trace.histfunc;
var densitynorm = (norm.indexOf('density') !== -1);
var extremefunc = (func === 'max' || func === 'min');
var sizeinit = (extremefunc ? null : 0);
var densitynorm = norm.indexOf('density') !== -1;
var extremefunc = func === 'max' || func === 'min';
var sizeinit = extremefunc ? null : 0;
var binfunc = binFunctions.count;
var normfunc = normFunctions[norm];
var doavg = false;
Expand Down
2 changes: 0 additions & 2 deletions src/traces/histogram2d/cross_trace_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';


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

var BADNUM = require('../../constants/numerical').BADNUM;
Expand Down
4 changes: 1 addition & 3 deletions src/traces/histogram2d/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
if(traceOut.visible === false) return;

handleStyleDefaults(traceIn, traceOut, coerce, layout);
colorscaleDefaults(
traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}
);
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'});
coerce('hovertemplate');
};
2 changes: 1 addition & 1 deletion test/jasmine/tests/bar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('Bar.supplyDefaults', function() {
expect(traceOut.ycalendar).toBe('ethiopian');
});

it('should not include alignementgroup/offsetgroup when barmode is not *group*', function() {
it('should not include alignmentgroup/offsetgroup when barmode is not *group*', function() {
var gd = {
data: [{type: 'bar', y: [1], alignmentgroup: 'a', offsetgroup: '1'}],
layout: {barmode: 'group'}
Expand Down
10 changes: 4 additions & 6 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1297,19 +1297,17 @@ describe('Test plot api', function() {
])
.then(function() {
check(true, 'initial');
return Plotly.restyle(gd, 'xbins.start', start0, [0]);
})
.then(function() {
return Plotly.restyle(gd, {'xbins.end': end1, 'ybins.size': size1}, null, [1]);
})
.then(function() { return Plotly.restyle(gd, 'xbins.start', start0, [0]); })
.then(function() { return Plotly.restyle(gd, {'xbins.end': end1, 'ybins.size': size1}, null, [1]); })
.then(function() {
check(false, 'set start/end/size');
return Plotly.restyle(gd, {autobinx: true, autobiny: true});
})
.then(function() { return Plotly.restyle(gd, {autobinx: true, autobiny: true}); })
.then(function() {
check(true, 'reset');
return Queue.undo(gd);
})
.then(function() { return Queue.undo(gd); })
.then(function() {
check(false, 'undo');
})
Expand Down
0