Skip to content

Commit

Permalink
Allow highlights and locking highlight points for plots in compact mo…
Browse files Browse the repository at this point in the history
…de, but still disallow pan and zoom.
  • Loading branch information
shefalijoshi committed Jan 6, 2025
1 parent 5be103e commit 4ca617f
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/plugins/plot/MctPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,11 @@ export default {

this.canvas = this.$refs.chartContainer.querySelectorAll('canvas')[1];

if (!this.options.compact) {
this.listenTo(this.canvas, 'mousemove', this.trackMousePosition, this);
this.listenTo(this.canvas, 'mouseleave', this.untrackMousePosition, this);
this.listenTo(this.canvas, 'mousedown', this.onMouseDown, this);
this.listenTo(this.canvas, 'click', this.selectNearbyAnnotations, this);
this.listenTo(this.canvas, 'wheel', this.wheelZoom, this);
}
this.listenTo(this.canvas, 'mousemove', this.trackMousePosition, this);
this.listenTo(this.canvas, 'mouseleave', this.untrackMousePosition, this);
this.listenTo(this.canvas, 'mousedown', this.onMouseDown, this);
this.listenTo(this.canvas, 'click', this.selectNearbyAnnotations, this);
this.listenTo(this.canvas, 'wheel', this.wheelZoom, this);
},

marqueeAnnotations(annotationsToSelect) {
Expand Down Expand Up @@ -1115,19 +1113,21 @@ export default {
this.listenTo(window, 'mouseup', this.onMouseUp, this);
this.listenTo(window, 'mousemove', this.trackMousePosition, this);

// track frozen state on mouseDown to be read on mouseUp
const isFrozen =
this.config.xAxis.get('frozen') === true && this.config.yAxis.get('frozen') === true;
this.isFrozenOnMouseDown = isFrozen;
if (!this.options.compact) {
// track frozen state on mouseDown to be read on mouseUp
const isFrozen =
this.config.xAxis.get('frozen') === true && this.config.yAxis.get('frozen') === true;
this.isFrozenOnMouseDown = isFrozen;

if (event.altKey && !event.shiftKey) {
return this.startPan(event);
} else if (event.altKey && event.shiftKey) {
this.freeze();
if (event.altKey && !event.shiftKey) {
return this.startPan(event);

Check warning on line 1123 in src/plugins/plot/MctPlot.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plot/MctPlot.vue#L1123

Added line #L1123 was not covered by tests
} else if (event.altKey && event.shiftKey) {
this.freeze();

Check warning on line 1125 in src/plugins/plot/MctPlot.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plot/MctPlot.vue#L1125

Added line #L1125 was not covered by tests

return this.startMarquee(event, true);
} else {
return this.startMarquee(event, false);
return this.startMarquee(event, true);

Check warning on line 1127 in src/plugins/plot/MctPlot.vue

View check run for this annotation

Codecov / codecov/patch

src/plugins/plot/MctPlot.vue#L1127

Added line #L1127 was not covered by tests
} else {
return this.startMarquee(event, false);
}
}
},

Expand Down Expand Up @@ -1158,11 +1158,15 @@ export default {
},

isMouseClick() {
if (!this.marquee) {
// We may not have a marquee if we've disabled pan/zoom, but we still need to know if it's a mouse click for highlights and lock points.
if (!this.marquee && !this.positionOverPlot) {
return false;
}

const { start, end } = this.marquee;
const { start, end } = this.marquee ?? {
start: this.positionOverPlot,
end: this.positionOverPlot
};
const someYPositionOverPlot = start.y.some((y) => y);

return start.x === end.x && someYPositionOverPlot;
Expand Down

0 comments on commit 4ca617f

Please sign in to comment.