Skip to content

Commit cc871cd

Browse files
committed
bar: test marker.line.(width|color) and horizontal bar transitions
1 parent 495d036 commit cc871cd

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

Diff for: test/jasmine/assets/check_transitions.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ module.exports = function checkTransition(gd, mock, animateOpts, transitionOpts,
7272

7373
// Run all tasks
7474
return promiseSerial(p.concat(checkTests))
75+
.catch(function() {
76+
Date.now = now;
77+
})
7578
.then(function() {
7679
Date.now = now;
7780
});
@@ -83,9 +86,9 @@ module.exports = function checkTransition(gd, mock, animateOpts, transitionOpts,
8386
function assert(test) {
8487
var msg = 'at ' + test[0] + 'ms, selection ' + test[1] + ' has ' + test[3];
8588
var cur = [];
86-
Plotly.d3.selectAll(test[1]).each(function(d, i) {
89+
d3.selectAll(test[1]).each(function(d, i) {
8790
if(test[2] === 'style') cur[i] = this.style[test[3]];
88-
if(test[2] === 'attr') cur[i] = Plotly.d3.select(this).attr(test[3]);
91+
if(test[2] === 'attr') cur[i] = d3.select(this).attr(test[3]);
8992
});
9093
switch(test[3]) {
9194
case 'd':
@@ -103,7 +106,7 @@ function assert(test) {
103106
function assertAttr(A, B, cb, msg) {
104107
var a = cb(A);
105108
var b = cb(B);
106-
expect(a).withContext(msg + ' equal to ' + JSON.stringify(b)).toEqual(b);
109+
expect(a).withContext(msg + ' equal to ' + JSON.stringify(a)).toEqual(b);
107110
}
108111

109112
function round(str) {

Diff for: test/jasmine/tests/bar_test.js

+44-2
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,7 @@ describe('bar tweening', function() {
25872587
.then(done);
25882588
});
25892589

2590-
it('for bar height and and text position', function(done) {
2590+
it('for vertical bar height and text position', function(done) {
25912591
var tests = [
25922592
[0, '.point path', 'attr', 'd', ['M18,270V42H162V270Z', 'M198,270V222.5H342V270Z', 'M378,270V194H522V270Z']],
25932593
[0, 'text.bartext', 'attr', 'transform', ['translate(90 56)', 'translate(270 236.5)', 'translate(450 208)']],
@@ -2605,7 +2605,7 @@ describe('bar tweening', function() {
26052605
.then(done);
26062606
});
26072607

2608-
it('for bar width', function(done) {
2608+
it('for vertical bar width', function(done) {
26092609
var tests = [
26102610
[0, '.point path', 'attr', 'd', ['M54,270V13.5H486V270Z']],
26112611
[250, '.point path', 'attr', 'd', ['M94.5,270V13.5H445.5V270Z']],
@@ -2623,6 +2623,48 @@ describe('bar tweening', function() {
26232623
.then(done);
26242624
});
26252625

2626+
it('for horizontal bar length and text position', function(done) {
2627+
var mockCopy = Lib.extendDeep({}, mock);
2628+
mockCopy.data[0].orientation = 'h';
2629+
mockCopy.data[0].x = mock.data[0].y.slice();
2630+
mockCopy.data[0].y = mock.data[0].x.slice();
2631+
var tests = [
2632+
[0, '.point path', 'attr', 'd', ['M0,261V189H107V261Z', 'M0,171V99H513V171Z', 'M0,81V9H257V81Z']],
2633+
[0, 'text.bartext', 'attr', 'transform', ['translate(100 229)', 'translate(506 139)', 'translate(249 49)']],
2634+
[150, '.point path', 'attr', 'd', ['M0,261V189H171V261Z', 'M0,171V99H455V171Z', 'M0,81V9H276V81Z']],
2635+
[300, '.point path', 'attr', 'd', ['M0,261V189H235V261Z', 'M0,171V99H398V171Z', 'M0,81V9H295V81Z']],
2636+
[300, 'text.bartext', 'attr', 'transform', ['translate(228,229)', 'translate(391,139)', 'translate(287,49)']],
2637+
[450, '.point path', 'attr', 'd', ['M0,261V189H299V261Z', 'M0,171V99H340V171Z', 'M0,81V9H314V81Z']],
2638+
[600, '.point path', 'attr', 'd', ['M0,261V189H321V261Z', 'M0,171V99H321V171Z', 'M0,81V9H321V81Z']],
2639+
[600, 'text.bartext', 'attr', 'transform', ['translate(314 229)', 'translate(314 139)', 'translate(313 49)']]
2640+
];
2641+
var animateOpts = {data: [{x: [15, 15, 15]}]};
2642+
2643+
checkTransition(gd, mockCopy, animateOpts, transitionOpts, tests)
2644+
.catch(failTest)
2645+
.then(done);
2646+
});
2647+
2648+
it('for bar line width and color', function(done) {
2649+
var tests = [
2650+
[0, '.point path', 'style', 'stroke', ['', '', '']],
2651+
[0, '.point path', 'style', 'stroke-width', ['0px', '0px', '0px']],
2652+
[150, '.point path', 'style', 'stroke', ['rgb(77, 0, 0)', 'rgb(0, 77, 0)', 'rgb(0, 0, 77)']],
2653+
[150, '.point path', 'style', 'stroke-width', ['6px', '6px', '6px']],
2654+
[300, '.point path', 'style', 'stroke', ['rgb(153, 0, 0)', 'rgb(0, 153, 0)', 'rgb(0, 0, 153)']],
2655+
[300, '.point path', 'style', 'stroke-width', ['12px', '12px', '12px']],
2656+
[450, '.point path', 'style', 'stroke', ['rgb(230, 0, 0)', 'rgb(0, 230, 0)', 'rgb(0, 0, 230)']],
2657+
[450, '.point path', 'style', 'stroke-width', ['18px', '18px', '18px']],
2658+
[600, '.point path', 'style', 'stroke', ['rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)']],
2659+
[600, '.point path', 'style', 'stroke-width', ['20px', '20px', '20px']]
2660+
];
2661+
var animateOpts = {'data': [{'marker': {'line': {'width': 20, 'color': ['rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)']}}}]};
2662+
2663+
checkTransition(gd, mock, animateOpts, transitionOpts, tests)
2664+
.catch(failTest)
2665+
.then(done);
2666+
});
2667+
26262668
it('for error bars', function(done) {
26272669
var tests = [
26282670
[0, 'path.yerror', 'attr', 'd', ['M266,13.5h8m-4,0V99m-4,0h8']],

0 commit comments

Comments
 (0)