Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c52586

Browse files
committed
fix pie text color restyles
1 parent ceb119f commit 2c52586

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/traces/pie/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var extendFlat = require('../../lib/extend').extendFlat;
1818
var textFontAttrs = fontAttrs({
1919
editType: 'calc',
2020
arrayOk: true,
21-
colorEditType: 'style',
21+
colorEditType: 'plot',
2222
description: 'Sets the font used for `textinfo`.'
2323
});
2424

test/jasmine/tests/pie_test.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,62 @@ describe('Pie traces', function() {
691691
.then(done);
692692
});
693693
});
694+
695+
it('should be able to restyle title color', function(done) {
696+
function _assert(msg, exp) {
697+
var title = d3.select('.titletext > text').node();
698+
expect(title.style.fill).toBe(exp.color, msg);
699+
}
700+
701+
Plotly.plot(gd, [{
702+
type: 'pie',
703+
values: [1, 2, 3],
704+
title: 'yo',
705+
titlefont: {color: 'blue'}
706+
}])
707+
.then(function() {
708+
_assert('base', {color: 'rgb(0, 0, 255)'});
709+
return Plotly.restyle(gd, 'titlefont.color', 'red');
710+
})
711+
.then(function() {
712+
_assert('base', {color: 'rgb(255, 0, 0)'});
713+
})
714+
.catch(failTest)
715+
.then(done);
716+
});
717+
718+
it('should be able to react with new text colors', function(done) {
719+
Plotly.plot(gd, [{
720+
type: 'pie',
721+
values: [1, 2, 3],
722+
text: ['A', 'B', 'C'],
723+
textposition: 'inside'
724+
}])
725+
.then(_checkFontColors(['rgb(255, 255, 255)', 'rgb(68, 68, 68)', 'rgb(255, 255, 255)']))
726+
.then(function() {
727+
gd.data[0].insidetextfont = {color: 'red'};
728+
return Plotly.react(gd, gd.data);
729+
})
730+
.then(_checkFontColors(['rgb(255, 0, 0)', 'rgb(255, 0, 0)', 'rgb(255, 0, 0)']))
731+
.then(function() {
732+
delete gd.data[0].insidetextfont.color;
733+
gd.data[0].textfont = {color: 'blue'};
734+
return Plotly.react(gd, gd.data);
735+
})
736+
.then(_checkFontColors(['rgb(0, 0, 255)', 'rgb(0, 0, 255)', 'rgb(0, 0, 255)']))
737+
.then(function() {
738+
gd.data[0].textposition = 'outside';
739+
return Plotly.react(gd, gd.data);
740+
})
741+
.then(_checkFontColors(['rgb(0, 0, 255)', 'rgb(0, 0, 255)', 'rgb(0, 0, 255)']))
742+
.then(function() {
743+
gd.data[0].outsidetextfont = {color: 'red'};
744+
return Plotly.react(gd, gd.data);
745+
})
746+
.then(_checkFontColors(['rgb(255, 0, 0)', 'rgb(255, 0, 0)', 'rgb(255, 0, 0)']))
747+
.catch(failTest)
748+
.then(done);
749+
});
694750
});
695751

696752
describe('pie hovering', function() {

0 commit comments

Comments
 (0)