Skip to content
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

Fix missing cursor for ternary plot #7057

Merged
merged 9 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions draftlogs/7057_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix missing cursor for Ternary Plot[[#7057](https://github.com/plotly/plotly.js/pull/7057)],
with thanks to @Lexachoc for the contribution!
10 changes: 10 additions & 0 deletions src/plots/ternary/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var d3 = require('@plotly/d3');

var Ternary = require('./ternary');

var getSubplotCalcData = require('../../plots/get_data').getSubplotCalcData;
Expand Down Expand Up @@ -75,3 +77,11 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout)
}
}
};

exports.updateFx = function(gd) {
var fullLayout = gd._fullLayout;
var dragmode = fullLayout.dragmode;
var toplevel = d3.select(gd).selectAll('g.toplevel');

toplevel.style('cursor', dragmode === 'pan' ? 'move' : 'crosshair');
};
7 changes: 7 additions & 0 deletions src/plots/ternary/ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ proto.plot = function(ternaryCalcData, fullLayout) {

_this.updateLayers(ternaryLayout);
_this.adjustLayout(ternaryLayout, graphSize);
_this.updateFx(fullLayout.dragmode);
Plots.generalUpdatePerTraceModule(_this.graphDiv, _this, ternaryCalcData, ternaryLayout);
_this.layers.plotbg.select('path').call(Color.fill, ternaryLayout.bgcolor);
};
Expand Down Expand Up @@ -97,6 +98,12 @@ proto.makeFramework = function(fullLayout) {
Drawing.setClipUrl(_this.layers.grids, clipId, gd);
};

proto.updateFx = function(dragmode) {
var toplevel = this.plotContainer.selectAll('g.toplevel');

toplevel.style('cursor', dragmode === 'pan' ? 'move' : 'crosshair');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use _ternarylayer.

Suggested change
var toplevel = this.plotContainer.selectAll('g.toplevel');
toplevel.style('cursor', dragmode === 'pan' ? 'move' : 'crosshair');
var fullLayout = gd._fullLayout;
fullLayout._ternarylayer
.selectAll('g.toplevel')
.style('cursor', fullLayout.dragmode === 'pan' ? 'move' : 'crosshair');

Copy link
Contributor Author

@Lexachoc Lexachoc Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated again with your sugguestion.
Also, I moved the updateFx function from proto.plot to the function Ternary(options, fullLayout) function so that the updateFx function is only triggered once at initialization instead of being called every time the plot is zoomed/panned and resized. What do you think?

};

proto.updateLayers = function(ternaryLayout) {
var _this = this;
var layers = _this.layers;
Expand Down