-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Pie colors fix & enhancements #2870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1801,14 +1801,6 @@ function mockBarPlot(dataWithoutTraceType, layout) { | |
supplyAllDefaults(gd); | ||
Plots.doCalcdata(gd); | ||
|
||
var plotinfo = { | ||
xaxis: gd._fullLayout.xaxis, | ||
yaxis: gd._fullLayout.yaxis | ||
}; | ||
|
||
// call Bar.crossTraceCalc | ||
Bar.crossTraceCalc(gd, plotinfo); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yep, I noticed that last week. This commit dfada6a helps, but there are more cases where |
||
|
||
return gd; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,50 @@ describe('Pie traces:', function() { | |
.catch(failTest) | ||
.then(done); | ||
}); | ||
|
||
function _checkSliceColors(colors) { | ||
return function() { | ||
d3.select(gd).selectAll('.slice path').each(function(d, i) { | ||
expect(this.style.fill.replace(/(\s|rgb\(|\))/g, '')).toBe(colors[i], i); | ||
}); | ||
}; | ||
} | ||
|
||
it('propagates explicit colors to the same labels in earlier OR later traces', function(done) { | ||
var data1 = [ | ||
{type: 'pie', values: [3, 2], marker: {colors: ['red', 'black']}, domain: {x: [0.5, 1]}}, | ||
{type: 'pie', values: [2, 5], domain: {x: [0, 0.5]}} | ||
]; | ||
var data2 = Lib.extendDeep([], [data1[1], data1[0]]); | ||
|
||
Plotly.newPlot(gd, data1) | ||
.then(_checkSliceColors(['255,0,0', '0,0,0', '0,0,0', '255,0,0'])) | ||
.then(function() { | ||
return Plotly.newPlot(gd, data2); | ||
}) | ||
.then(_checkSliceColors(['0,0,0', '255,0,0', '255,0,0', '0,0,0'])) | ||
.catch(failTest) | ||
.then(done); | ||
}); | ||
|
||
it('can use a separate pie colorway and disable extended colors', function(done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great tests! |
||
Plotly.newPlot(gd, [{type: 'pie', values: [7, 6, 5, 4, 3, 2, 1]}], {colorway: ['#777', '#F00']}) | ||
.then(_checkSliceColors(['119,119,119', '255,0,0', '170,170,170', '255,102,102', '68,68,68', '153,0,0', '119,119,119'])) | ||
.then(function() { | ||
return Plotly.relayout(gd, {extendpiecolors: false}); | ||
}) | ||
.then(_checkSliceColors(['119,119,119', '255,0,0', '119,119,119', '255,0,0', '119,119,119', '255,0,0', '119,119,119'])) | ||
.then(function() { | ||
return Plotly.relayout(gd, {piecolorway: ['#FF0', '#0F0', '#00F']}); | ||
}) | ||
.then(_checkSliceColors(['255,255,0', '0,255,0', '0,0,255', '255,255,0', '0,255,0', '0,0,255', '255,255,0'])) | ||
.then(function() { | ||
return Plotly.relayout(gd, {extendpiecolors: null}); | ||
}) | ||
.then(_checkSliceColors(['255,255,0', '0,255,0', '0,0,255', '255,255,102', '102,255,102', '102,102,255', '153,153,0'])) | ||
.catch(failTest) | ||
.then(done); | ||
}); | ||
}); | ||
|
||
describe('pie hovering', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't matter for CI, and has nothing to do with this PR, but this change makes this test pass on my Mac.