Skip to content

Commit 840623d

Browse files
committed
set bar textfont.color editType to 'style', add react tests
1 parent 2c52586 commit 840623d

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/traces/bar/attributes.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var extendFlat = require('../../lib/extend').extendFlat;
1818
var textFontAttrs = fontAttrs({
1919
editType: 'calc',
2020
arrayOk: true,
21+
colorEditType: 'style',
2122
description: ''
2223
});
2324

test/jasmine/tests/bar_test.js

+34
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ describe('A bar plot', function() {
10831083
.catch(failTest)
10841084
.then(done);
10851085
});
1086+
10861087
it('should show bar texts (outside case)', function(done) {
10871088
var data = [{
10881089
y: [10, -20, 30],
@@ -1736,6 +1737,39 @@ describe('A bar plot', function() {
17361737
.catch(failTest)
17371738
.then(done);
17381739
});
1740+
1741+
it('should be able to react with new text colors', function(done) {
1742+
Plotly.react(gd, [{
1743+
type: 'bar',
1744+
y: [1, 2, 3],
1745+
text: ['A', 'B', 'C'],
1746+
textposition: 'inside'
1747+
}])
1748+
.then(assertTextFontColors(['rgb(255, 255, 255)', 'rgb(255, 255, 255)', 'rgb(255, 255, 255)']))
1749+
.then(function() {
1750+
gd.data[0].insidetextfont = {color: 'red'};
1751+
return Plotly.react(gd, gd.data);
1752+
})
1753+
.then(assertTextFontColors(['rgb(255, 0, 0)', 'rgb(255, 0, 0)', 'rgb(255, 0, 0)']))
1754+
.then(function() {
1755+
delete gd.data[0].insidetextfont.color;
1756+
gd.data[0].textfont = {color: 'blue'};
1757+
return Plotly.react(gd, gd.data);
1758+
})
1759+
.then(assertTextFontColors(['rgb(0, 0, 255)', 'rgb(0, 0, 255)', 'rgb(0, 0, 255)']))
1760+
.then(function() {
1761+
gd.data[0].textposition = 'outside';
1762+
return Plotly.react(gd, gd.data);
1763+
})
1764+
.then(assertTextFontColors(['rgb(0, 0, 255)', 'rgb(0, 0, 255)', 'rgb(0, 0, 255)']))
1765+
.then(function() {
1766+
gd.data[0].outsidetextfont = {color: 'red'};
1767+
return Plotly.react(gd, gd.data);
1768+
})
1769+
.then(assertTextFontColors(['rgb(255, 0, 0)', 'rgb(255, 0, 0)', 'rgb(255, 0, 0)']))
1770+
.catch(failTest)
1771+
.then(done);
1772+
});
17391773
});
17401774

17411775
describe('bar visibility toggling:', function() {

0 commit comments

Comments
 (0)