Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/traces/contour/colorbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

'use strict';

var extractOpts = require('../../components/colorscale').extractOpts;
var Colorscale = require('../../components/colorscale');
var makeColorMap = require('./make_color_map');
var endPlus = require('./end_plus');

Expand All @@ -20,8 +20,10 @@ function calc(gd, trace, opts) {
var colorMap = makeColorMap(trace, {isColorbar: true});

if(coloring === 'heatmap') {
var cOpts = extractOpts(trace);
opts._fillgradient = trace.colorscale;
var cOpts = Colorscale.extractOpts(trace);
opts._fillgradient = cOpts.reversescale ?
Colorscale.flipScale(cOpts.colorscale) :
cOpts.colorscale;
opts._zrange = [cOpts.min, cOpts.max];
} else if(coloring === 'fill') {
opts._fillcolor = colorMap;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions test/image/mocks/contour_heatmap_coloring_reversescale.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"data": [
{
"z": [
[ 10, 10.625, 12.5, 15.625, 20 ],
[ 5.625, 6.25, 8.125, 11.25, 15.625 ],
[ 2.5, 3.125, 5, 8.125, 12.5 ],
[ 0.625, 1.25, 3.125, 6.25, 10.625 ],
[ 0, 0.625, 2.5, 5.625, 10 ]
],
"x": [ -9, -6, -5, -3, -1 ],
"y": [ 0, 1, 4, 5, 7 ],
"type": "contour",
"contours": {
"coloring": "heatmap"
},
"reversescale": true,
"colorbar": {
"len": 0.5,
"y": 1,
"yanchor": "top",
"title": {"text": "trace colorscale", "side": "right"}
}
},
{
"z": [
[ 10, 10.625, 12.5, 15.625, 20 ],
[ 5.625, 6.25, 8.125, 11.25, 15.625 ],
[ 2.5, 3.125, 5, 8.125, 12.5 ],
[ 0.625, 1.25, 3.125, 6.25, 10.625 ],
[ 0, 0.625, 2.5, 5.625, 10 ]
],
"x": [ -9, -6, -5, -3, -1 ],
"y": [ 0, 1, 4, 5, 7 ],
"type": "contour",
"contours": {
"coloring": "heatmap"
},
"coloraxis": "coloraxis",
"xaxis": "x2",
"yaxis": "y2"
}
],
"layout": {
"grid": {"rows": 2, "columns": 1, "pattern": "independent"},
"title": {
"text": "Setting the X and Y Coordinates in a Contour Plot + reverse scale"
},
"coloraxis": {
"reversescale": true,
"colorbar": {
"len": 0.5,
"y": 0,
"yanchor": "bottom",
"title": {"text": "coloraxis colorscale", "side": "right"}
}
}
}
}