-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add midpoint attr to color scales #3549
Changes from all commits
d69f27c
e2745f8
b8dce0a
ba72887
23c1cf0
40a7510
ff67812
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"data": [{ | ||
"y": [1, 2, 1], | ||
"mode": "markers", | ||
"marker": { | ||
"size": 20, | ||
"color": [-1, 1, 10], | ||
"cmid": "0", | ||
"colorbar": { | ||
"len": 0.3, | ||
"y": "1", | ||
"yanchor": "top", | ||
"title": {"text": "marker.cmid=0", "side": "right"} | ||
} | ||
} | ||
}, { | ||
"type": "heatmap", | ||
"z": [[1,2], [2, 3]], | ||
"zmid": -1, | ||
"colorbar": { | ||
"len": 0.3, | ||
"y": "0.5", | ||
"yanchor": "middle", | ||
"title": {"text": "zmid=-1", "side": "right"} | ||
} | ||
}, { | ||
"type": "bar", | ||
"y": [0.5, 1, 0.5], | ||
"name": "marker.line.cmid=2", | ||
"hoverlabel": {"namelength": -1}, | ||
"marker": { | ||
"line": { | ||
"width": 2, | ||
"color": [-1, -1, -10], | ||
"cmid": 2 | ||
} | ||
} | ||
}], | ||
"layout": { | ||
"title": {"text": "Traces with set <b>cmid</b> / <b>zmid</b>"}, | ||
"showlegend": false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1195,6 +1195,77 @@ describe('Test plot api', function() { | |
.then(done); | ||
}); | ||
|
||
it('turns on cauto when cmid is edited', 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. this is an odd description... 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.
yes, it has to. If not, 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. by "not work" here I mean it wouldn't apply that new cmid value when 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. OK I see what you mean. |
||
function _assert(msg, exp) { | ||
return function() { | ||
var mk = gd._fullData[0].marker; | ||
for(var k in exp) { | ||
expect(mk[k]).toBe(exp[k], [msg, k].join(' - ')); | ||
} | ||
}; | ||
} | ||
|
||
function _restyle(arg) { | ||
return function() { return Plotly.restyle(gd, arg); }; | ||
} | ||
|
||
Plotly.plot(gd, [{ | ||
mode: 'markers', | ||
y: [1, 2, 1], | ||
marker: { color: [1, -1, 4] } | ||
}]) | ||
.then(_assert('base', { | ||
cauto: true, | ||
cmid: undefined, | ||
cmin: -1, | ||
cmax: 4 | ||
})) | ||
.then(_restyle({'marker.cmid': 0})) | ||
.then(_assert('set cmid=0', { | ||
cauto: true, | ||
cmid: 0, | ||
cmin: -4, | ||
cmax: 4 | ||
})) | ||
.then(_restyle({'marker.cmid': -2})) | ||
.then(_assert('set cmid=-2', { | ||
cauto: true, | ||
cmid: -2, | ||
cmin: -8, | ||
cmax: 4 | ||
})) | ||
.then(_restyle({'marker.cmid': 2})) | ||
.then(_assert('set cmid=2', { | ||
cauto: true, | ||
cmid: 2, | ||
cmin: -1, | ||
cmax: 5 | ||
})) | ||
.then(_restyle({'marker.cmin': 0})) | ||
.then(_assert('set cmin=0', { | ||
cauto: false, | ||
cmid: undefined, | ||
cmin: 0, | ||
cmax: 5 | ||
})) | ||
.then(_restyle({'marker.cmax': 10})) | ||
.then(_assert('set cmin=0 + cmax=10', { | ||
cauto: false, | ||
cmid: undefined, | ||
cmin: 0, | ||
cmax: 10 | ||
})) | ||
.then(_restyle({'marker.cauto': true, 'marker.cmid': null})) | ||
.then(_assert('back to cauto=true', { | ||
cauto: true, | ||
cmid: undefined, | ||
cmin: -1, | ||
cmax: 4 | ||
})) | ||
.catch(failTest) | ||
.then(done); | ||
}); | ||
|
||
it('turns off autobin when you edit bin specs', function(done) { | ||
// test retained (modified) for backward compat with new autobin logic | ||
var start0 = 0.2; | ||
|
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.
this line and the next used to always run, but now only conditionally... might this break anything? I'm not sure about the implication of not calling
coerce()
.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.
No tests are failing because of it.
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.
ok
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.
There is a test failure that mentions
coerce
: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.
Ah good eye.
Well
cmin
andcmax
have no effectplotly.js/src/components/colorscale/calc.js
Lines 31 to 37 in bb1239a
when
cauto
is true.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.
I'm easy. Like I said, I don't know the impact of calling
coerce
and ignoring the attr vs not callingcoerce
:)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.
Calling the behaviour correct and adapting the test in ff67812