Skip to content

Commit 805f79b

Browse files
committed
check that proper tick labels are generated for colorbar log type
1 parent 717d459 commit 805f79b

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎test/jasmine/tests/colorbar_test.js‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,44 @@ describe('Test colorbar:', function() {
550550
.then(done, done.fail);
551551
});
552552
});
553+
554+
describe('log ticks', function() {
555+
var gd;
556+
557+
beforeEach(function() {
558+
gd = createGraphDiv();
559+
});
560+
561+
afterEach(destroyGraphDiv);
562+
563+
it('should generate logarithmic ticks when type is log', function() {
564+
Plotly.newPlot(gd, [{
565+
type: 'heatmap',
566+
z: [[1, 10, 100], [10,100,1000]],
567+
cmin: 1,
568+
cmax: 1000,
569+
colorbar: {
570+
type: 'log',
571+
tickmode: 'auto'
572+
}
573+
}]);
574+
575+
// Extract the tick text elements
576+
var tickTexts = [];
577+
d3Select(gd).selectAll('.cbaxis text').each(function(t) {
578+
tickTexts.push(t.text);
579+
});
580+
581+
// The mock axis should have automatically generated exponents for 1, 10, 100, 1000
582+
expect(tickTexts).toContain('1');
583+
expect(tickTexts).toContain('2');
584+
expect(tickTexts).toContain('5');
585+
expect(tickTexts).toContain('10');
586+
expect(tickTexts).toContain('100');
587+
expect(tickTexts).toContain('1000');
588+
589+
// // Verify a linear tick like '500' was NOT generated
590+
expect(tickTexts).not.toContain('500');
591+
});
592+
});
553593
});

0 commit comments

Comments
 (0)