Skip to content
Open
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
1 change: 1 addition & 0 deletions draftlogs/8176_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix a heatmap with a single `x` or `y` value on a category axis, which was drawn at twice its category index [[#8176](https://github.com/plotly/plotly.js/pull/8176)]
3 changes: 2 additions & 1 deletion src/traces/heatmap/make_bound_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks,
if(isHist) {
v0 = ax.r2c(v0In, 0, calendar);
} else {
if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) {
// on a category axis, z is already laid out on all the axis categories (clean_2d_array)
if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1 && ax.type !== 'category') {
v0 = arrayIn[0];
} else if(v0In === undefined) {
v0 = 0;
Expand Down
12 changes: 12 additions & 0 deletions test/jasmine/tests/heatmap_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,18 @@ describe('heatmap plot', function() {

afterEach(destroyGraphDiv);

it('places a one-column trace at its category on a shared category axis', function(done) {
Plotly.newPlot(gd, [
{type: 'heatmap', x: ['b', 'c'], y: ['x', 'y', 'z'], z: [[1, 4], [2, 5], [3, 6]]},
{type: 'heatmap', x: ['a'], y: ['x', 'y', 'z'], z: [[7], [8], [9]]}
]).then(function() {
// z of every trace is laid out on all the axis categories, so bricks start at 0
expect(gd.calcdata[1][0].x).toBeCloseToArray([-0.5, 0.5, 1.5, 2.5]);
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.5, 2.5]);
})
.then(done, done.fail);
});

it('should not draw traces that are off-screen', function(done) {
var mock = require('../../image/mocks/heatmap_multi-trace.json');
var mockCopy = Lib.extendDeep({}, mock);
Expand Down
Loading