Skip to content

Commit ecffc49

Browse files
committed
Merge branch 'master' into pikul-proportional-ticks
2 parents a788ccc + 9e9da55 commit ecffc49

File tree

6 files changed

+82
-13
lines changed

6 files changed

+82
-13
lines changed

draftlogs/6829_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add argument to `arrayTicks()` to render major OR minor [[#6829](https://github.com/plotly/plotly.js/pull/6829)]

draftlogs/6830_fix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Fix scattergl rendering bug on M1 mac devices [[#6830](https://github.com/plotly/plotly.js/pull/6830)],
2+
with thanks to @justinjhendrick for the contribution!

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"regl": "npm:@plotly/regl@^2.1.2",
110110
"regl-error2d": "^2.0.12",
111111
"regl-line2d": "^3.1.2",
112-
"regl-scatter2d": "^3.2.9",
112+
"regl-scatter2d": "^3.3.1",
113113
"regl-splom": "^1.0.14",
114114
"strongly-connected-components": "^1.0.1",
115115
"superscript-text": "^1.0.0",

src/plots/cartesian/axes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,10 +1010,10 @@ axes.calcTicks = function calcTicks(ax, opts) {
10101010
// Original 'array' only code
10111011
if(major) {
10121012
tickVals = [];
1013-
ticksOut = arrayTicks(ax);
1013+
ticksOut = arrayTicks(ax, !isMinor);
10141014
} else {
10151015
minorTickVals = [];
1016-
minorTicks = arrayTicks(ax);
1016+
minorTicks = arrayTicks(ax, !isMinor);
10171017
}
10181018
continue;
10191019
}
@@ -1335,7 +1335,7 @@ function syncTicks(ax) {
13351335
return ticksOut;
13361336
}
13371337

1338-
function arrayTicks(ax) {
1338+
function arrayTicks(ax, majorOnly) {
13391339
var rng = Lib.simpleMap(ax.range, ax.r2l);
13401340
var exRng = expandRange(rng);
13411341
var tickMin = Math.min(exRng[0], exRng[1]);
@@ -1353,10 +1353,10 @@ function arrayTicks(ax) {
13531353

13541354
var ticksOut = [];
13551355
for(var isMinor = 0; isMinor <= 1; isMinor++) {
1356+
if((majorOnly !== undefined) && ((majorOnly && isMinor) || (majorOnly === false && !isMinor))) continue;
13561357
if(isMinor && !ax.minor) continue;
13571358
var vals = !isMinor ? ax.tickvals : ax.minor.tickvals;
13581359
var text = !isMinor ? ax.ticktext : [];
1359-
13601360
if(!vals) continue;
13611361

13621362

test/jasmine/tests/axes_test.js

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ var supplyDefaults = require('../assets/supply_defaults');
2828

2929
describe('Test axes', function() {
3030
'use strict';
31-
3231
describe('swap', function() {
3332
it('should swap most attributes and fix placeholder titles', function() {
3433
var gd = {
@@ -8217,3 +8216,70 @@ describe('shift tests', function() {
82178216
});
82188217
});
82198218
});
8219+
describe('test tickmode calculator', function() {
8220+
var gd;
8221+
8222+
beforeEach(function() {
8223+
gd = createGraphDiv();
8224+
});
8225+
8226+
afterEach(destroyGraphDiv);
8227+
8228+
function generateTickConfig() {
8229+
var standardConfig = {tickmode: 'array', ticks: 'inside', ticklen: 1, showticklabels: false};
8230+
8231+
// Number of ticks will be random
8232+
Lib.seedPseudoRandom();
8233+
var n = (Lib.pseudoRandom() * 99) + 1;
8234+
var tickVals = [];
8235+
for(var i = 0; i <= n; i++) {
8236+
tickVals.push(i);
8237+
}
8238+
standardConfig.tickvals = tickVals;
8239+
standardConfig.ticktext = tickVals;
8240+
return standardConfig;
8241+
}
8242+
var ticksOff = {tickmode: 'array', ticks: '', tickvals: [], ticktext: [], ticklen: 0, showticklabels: false};
8243+
8244+
function _assert(expLength) {
8245+
var ax = gd._fullLayout.xaxis;
8246+
8247+
// all positions
8248+
var positions =
8249+
ax._vals
8250+
.filter(function(d) { return d; })
8251+
.map(function(d) { return d.x; });
8252+
8253+
expect(positions.length).toEqual(expLength);
8254+
}
8255+
8256+
describe('arrayTicks', function() {
8257+
it('should return the specified correct number of major ticks and minor ticks', function(done) {
8258+
var xMajorConfig = ticksOff;
8259+
var xMinorConfig = ticksOff;
8260+
xMajorConfig = generateTickConfig();
8261+
xMinorConfig = generateTickConfig();
8262+
xMajorConfig.range = [0, 1000];
8263+
xMajorConfig.minor = xMinorConfig;
8264+
Plotly.newPlot(gd, {
8265+
data: [{
8266+
x: [0, 1],
8267+
y: [0, 1]
8268+
}],
8269+
layout: {
8270+
width: 400,
8271+
height: 400,
8272+
margin: {
8273+
t: 40,
8274+
b: 40,
8275+
l: 40,
8276+
r: 40
8277+
},
8278+
xaxis: xMajorConfig,
8279+
}
8280+
}).then(function() {
8281+
_assert(xMajorConfig.tickvals.length + xMinorConfig.tickvals.length);
8282+
}).then(done, done.fail);
8283+
});
8284+
});
8285+
});

0 commit comments

Comments
 (0)