From eba1629c0ba88be9c3863afcaf398c80d0996e0e Mon Sep 17 00:00:00 2001 From: alexcjohnson Date: Fri, 5 Feb 2021 21:57:50 -0500 Subject: [PATCH] fix #5474 heatmapgl with axis constraints --- src/plots/gl2d/scene2d.js | 5 +++-- test/jasmine/tests/heatmapgl_test.js | 32 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/plots/gl2d/scene2d.js b/src/plots/gl2d/scene2d.js index fac064f51db..67dea787fd8 100644 --- a/src/plots/gl2d/scene2d.js +++ b/src/plots/gl2d/scene2d.js @@ -401,9 +401,10 @@ proto.plot = function(fullData, calcData, fullLayout) { options.screenBox = [0, 0, width, height]; var mockGraphDiv = {_fullLayout: { - _axisConstraintGroups: this.graphDiv._fullLayout._axisConstraintGroups, + _axisConstraintGroups: fullLayout._axisConstraintGroups, xaxis: this.xaxis, - yaxis: this.yaxis + yaxis: this.yaxis, + _size: fullLayout._size }}; cleanAxisConstraints(mockGraphDiv, this.xaxis); diff --git a/test/jasmine/tests/heatmapgl_test.js b/test/jasmine/tests/heatmapgl_test.js index c4e7a5b7478..284390830e0 100644 --- a/test/jasmine/tests/heatmapgl_test.js +++ b/test/jasmine/tests/heatmapgl_test.js @@ -4,6 +4,9 @@ var Plotly = require('@lib/index'); var schema = Plotly.PlotSchema.get(); var attributeList = Object.getOwnPropertyNames(schema.traces.heatmapgl.attributes); +var createGraphDiv = require('../assets/create_graph_div'); +var destroyGraphDiv = require('../assets/destroy_graph_div'); + describe('heatmapgl supplyDefaults', function() { 'use strict'; @@ -97,3 +100,32 @@ describe('heatmapgl supplyDefaults', function() { }); }); }); + +describe('heatmapgl plotting', function() { + var gd; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(destroyGraphDiv); + + it('can do scaleanchor', function(done) { + var data = [{ + z: [[1, 2, 3], [4, 5, 6], [7, 8, 9]], + type: 'heatmapgl', + showscale: false + }]; + var layout = { + xaxis: {scaleanchor: 'y'}, + width: 500, + height: 300, + margin: {l: 50, r: 50, t: 50, b: 50} + }; + Plotly.newPlot(gd, data, layout) + .then(function() { + expect(layout.xaxis.range).toBeCloseToArray([-1, 3], 3); + }) + .then(done, done.fail); + }); +});