diff --git a/src/disagg/DisaggGraphView.js b/src/disagg/DisaggGraphView.js index a10f78351780b819197257ccf8f1a4e8ca271eca..25aa383bea47f02d99e10da8cc697b33d140d253 100644 --- a/src/disagg/DisaggGraphView.js +++ b/src/disagg/DisaggGraphView.js @@ -13,7 +13,9 @@ var Collection = require('../mvc/Collection'), var _DEFAULTS; -_DEFAULTS = {}; +_DEFAULTS = { + allowDrag: true, +}; var __calculateBounds; @@ -139,22 +141,28 @@ var DisaggGraphView = function (options) { y: 0, }; - d3.select(_this.d33d.el) - .on('mousedown', event => { - origin.x = event.clientX; - origin.y = event.clientY; - dragging = true; - }) - .on('mousemove', event => { - if (dragging) { - var dx = event.clientX - origin.x; - var dz = event.clientY - origin.y; - _this.setOrigin(280 - dx, -150, 180 + dz) - } + if (options.allowDrag) { + d3.select(_this.d33d.el) + .classed('cursor-move', true) + .on('mousedown', event => { + origin.x = event.clientX; + origin.y = event.clientY; + dragging = true; + }) + .on('mousemove', event => { + if (dragging) { + var dx = event.clientX - origin.x; + var dz = event.clientY - origin.y; + _this.setOrigin(280 - dx, -150, 180 + dz) + } + }) + .on('mouseup', () => { + dragging = false }) - .on('mouseup', () => { - dragging = false - }) + } else { + d3.select(_this.d33d.el) + .classed('cursor-move', false); + } }; /** diff --git a/styles/_D33dDisaggBin.scss b/styles/_D33dDisaggBin.scss index c6aefdd443269a3ad69bbdcd2e8f3c897ba853f2..8018d61245d0e0bb52dbe2961ef5a03f7a6ddc17 100644 --- a/styles/_D33dDisaggBin.scss +++ b/styles/_D33dDisaggBin.scss @@ -1,6 +1,8 @@ @import '_GraphVariables.scss'; .D33dDisaggBin { + cursor: default; + > g { > path { stroke: #666; diff --git a/styles/_D3View.scss b/styles/_D3View.scss index 6dcb806f60baa9970e5706f9b79e9eb91191a3aa..ec630811013b626704d1a4f81e82e146e2d8fd0c 100644 --- a/styles/_D3View.scss +++ b/styles/_D3View.scss @@ -17,7 +17,6 @@ } > svg { - cursor: move; fill: none; left: 0; position: absolute; @@ -27,6 +26,10 @@ width: 100%; } + &.cursor-move { + cursor: move; + } + /* text */ .plot-title, .tooltip-content > text { diff --git a/types/disagg/DisaggGraphViewOptions.d.ts b/types/disagg/DisaggGraphViewOptions.d.ts index 7cdf03bc03f38ec7baefe9593fcfb3dbf4097156..3d9e2364c78985730f1103b9ddff4972d2e2aca5 100644 --- a/types/disagg/DisaggGraphViewOptions.d.ts +++ b/types/disagg/DisaggGraphViewOptions.d.ts @@ -3,6 +3,10 @@ import {Disaggregation} from './Disaggregation'; export interface DisaggGraphViewOptions extends SelectedCollectionViewOptions<Disaggregation> { + /** + * Whether to allow drag and rotate of graph. + */ + allowDrag?: boolean; /** * Default null. * Plotting bounds.