Skip to content

Commit

Permalink
Merge pull request #2 from plotly/master
Browse files Browse the repository at this point in the history
catch up
  • Loading branch information
ErwanMAS committed Sep 12, 2018
2 parents 1c52fa6 + 344a6c5 commit bdc94ce
Show file tree
Hide file tree
Showing 96 changed files with 2,637 additions and 825 deletions.
7 changes: 0 additions & 7 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ then simply run,
browserify index.js > bundle.js
```

to trim meta information (and thus save a few bytes), run:


```
browserify -t path/to/plotly.js/tasks/util/compress_attributes.js index.js > bundle.js
```

## Angular CLI

Currently Angular CLI uses Webpack under the hood to bundle and build your Angular application.
Expand Down
69 changes: 35 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
},
"browserify": {
"transform": [
"glslify"
"glslify",
"./tasks/compress_attributes.js"
]
},
"dependencies": {
"3d-view": "^2.0.0",
"@etpinard/gl-text": "^1.1.6",
"@plotly/d3-sankey": "^0.5.0",
"alpha-shape": "^1.0.0",
"array-range": "^1.0.1",
Expand Down Expand Up @@ -85,7 +85,8 @@
"gl-spikes2d": "^1.0.1",
"gl-streamtube3d": "^1.0.0",
"gl-surface3d": "^1.3.5",
"glslify": "^6.2.1",
"gl-text": "^1.1.6",
"glslify": "^6.3.1",
"has-hover": "^1.0.1",
"has-passive-events": "^1.0.0",
"mapbox-gl": "0.45.0",
Expand All @@ -101,9 +102,9 @@
"polybooljs": "^1.2.0",
"regl": "^1.3.7",
"regl-error2d": "^2.0.5",
"regl-line2d": "^3.0.9",
"regl-line2d": "^3.0.11",
"regl-scatter2d": "^3.0.6",
"regl-splom": "^1.0.3",
"regl-splom": "^1.0.4",
"right-now": "^1.0.0",
"robust-orientation": "^1.1.3",
"sane-topojson": "^2.0.0",
Expand Down
34 changes: 33 additions & 1 deletion src/components/fx/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@ fontAttrs.family.dflt = constants.HOVERFONT;
fontAttrs.size.dflt = constants.HOVERFONTSIZE;

module.exports = {
clickmode: {
valType: 'flaglist',
role: 'info',
flags: ['event', 'select'],
dflt: 'event',
editType: 'plot',
extras: ['none'],
description: [
'Determines the mode of single click interactions.',
'*event* is the default value and emits the `plotly_click`',
'event. In addition this mode emits the `plotly_selected` event',
'in drag modes *lasso* and *select*, but with no event data attached',
'(kept for compatibility reasons).',
'The *select* flag enables selecting single',
'data points via click. This mode also supports persistent selections,',
'meaning that pressing Shift while clicking, adds to / subtracts from an',
'existing selection. *select* with `hovermode`: *x* can be confusing, consider',
'explicitly setting `hovermode`: *closest* when using this feature.',
'Selection events are sent accordingly as long as *event* flag is set as well.',
'When the *event* flag is missing, `plotly_click` and `plotly_selected`',
'events are not fired.'
].join(' ')
},
dragmode: {
valType: 'enumerated',
role: 'info',
Expand All @@ -36,7 +59,16 @@ module.exports = {
role: 'info',
values: ['x', 'y', 'closest', false],
editType: 'modebar',
description: 'Determines the mode of hover interactions.'
description: [
'Determines the mode of hover interactions.',
'If `clickmode` includes the *select* flag,',
'`hovermode` defaults to *closest*.',
'If `clickmode` lacks the *select* flag,',
'it defaults to *x* or *y* (depending on the trace\'s',
'`orientation` value) for plots based on',
'cartesian coordinates. For anything else the default',
'value is *closest*.',
].join(' ')
},
hoverdistance: {
valType: 'integer',
Expand Down
14 changes: 10 additions & 4 deletions src/components/fx/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt);
}

var clickmode = coerce('clickmode');

var dragMode = coerce('dragmode');
if(dragMode === 'select') coerce('selectdirection');

var hovermodeDflt;
if(layoutOut._has('cartesian')) {
// flag for 'horizontal' plots:
// determines the state of the mode bar 'compare' hovermode button
layoutOut._isHoriz = isHoriz(fullData);
hovermodeDflt = layoutOut._isHoriz ? 'y' : 'x';
if(clickmode.indexOf('select') > -1) {
hovermodeDflt = 'closest';
} else {
// flag for 'horizontal' plots:
// determines the state of the mode bar 'compare' hovermode button
layoutOut._isHoriz = isHoriz(fullData);
hovermodeDflt = layoutOut._isHoriz ? 'y' : 'x';
}
}
else hovermodeDflt = 'closest';

Expand Down
4 changes: 3 additions & 1 deletion src/components/legend/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ module.exports = function style(s, gd) {

var pts = ptgroup.selectAll('path.scatterpts')
.data(showMarkers ? dMod : []);
pts.enter().append('path').classed('scatterpts', true)
// make sure marker is on the bottom, in case it enters after text
pts.enter().insert('path', ':first-child')
.classed('scatterpts', true)
.attr('transform', 'translate(20,0)');
pts.exit().remove();
pts.call(Drawing.pointStyle, tMod, gd);
Expand Down
46 changes: 0 additions & 46 deletions src/lib/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ var polygon = module.exports = {};
* returns boolean: is pt inside the polygon (including on its edges)
*/
polygon.tester = function tester(ptsIn) {
if(Array.isArray(ptsIn[0][0])) return polygon.multitester(ptsIn);

var pts = ptsIn.slice(),
xmin = pts[0][0],
xmax = xmin,
Expand Down Expand Up @@ -174,50 +172,6 @@ polygon.tester = function tester(ptsIn) {
};
};

/**
* Test multiple polygons
*/
polygon.multitester = function multitester(list) {
var testers = [],
xmin = list[0][0][0],
xmax = xmin,
ymin = list[0][0][1],
ymax = ymin;

for(var i = 0; i < list.length; i++) {
var tester = polygon.tester(list[i]);
tester.subtract = list[i].subtract;
testers.push(tester);
xmin = Math.min(xmin, tester.xmin);
xmax = Math.max(xmax, tester.xmax);
ymin = Math.min(ymin, tester.ymin);
ymax = Math.max(ymax, tester.ymax);
}

function contains(pt, arg) {
var yes = false;
for(var i = 0; i < testers.length; i++) {
if(testers[i].contains(pt, arg)) {
// if contained by subtract polygon - exclude the point
yes = testers[i].subtract === false;
}
}

return yes;
}

return {
xmin: xmin,
xmax: xmax,
ymin: ymin,
ymax: ymax,
pts: [],
contains: contains,
isRect: false,
degenerate: false
};
};

/**
* Test if a segment of a points array is bent or straight
*
Expand Down
11 changes: 11 additions & 0 deletions src/lib/prepare_regl.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ module.exports = function prepareRegl(gd, extensions) {
} catch(e) {
success = false;
}

if(success) {
this.addEventListener('webglcontextlost', function(event) {
if(gd && gd.emit) {
gd.emit('plotly_webglcontextlost', {
event: event,
layer: d.key
});
}
}, false);
}
});

if(!success) {
Expand Down
29 changes: 27 additions & 2 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var doTicksSingle = require('./axes').doTicksSingle;
var getFromId = require('./axis_ids').getFromId;
var prepSelect = require('./select').prepSelect;
var clearSelect = require('./select').clearSelect;
var selectOnClick = require('./select').selectOnClick;
var scaleZoom = require('./scale_zoom');

var constants = require('./constants');
Expand Down Expand Up @@ -148,7 +149,11 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
};

dragOptions.prepFn = function(e, startX, startY) {
var dragModePrev = dragOptions.dragmode;
var dragModeNow = gd._fullLayout.dragmode;
if(dragModeNow !== dragModePrev) {
dragOptions.dragmode = dragModeNow;
}

recomputeAxisLists();

Expand Down Expand Up @@ -178,7 +183,19 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
prepSelect(e, startX, startY, dragOptions, dragModeNow);
} else {
dragOptions.clickFn = clickFn;
clearAndResetSelect();
if(isSelectOrLasso(dragModePrev)) {
// TODO Fix potential bug
// Note: clearing / resetting selection state only happens, when user
// triggers at least one interaction in pan/zoom mode. Otherwise, the
// select/lasso outlines are deleted (in plots.js.cleanPlot) but the selection
// cache isn't cleared. So when the user switches back to select/lasso and
// 'adds to a selection' with Shift, the "old", seemingly removed outlines
// are redrawn again because the selection cache still holds their coordinates.
// However, this isn't easily solved, since plots.js would need
// to have a reference to the dragOptions object (which holds the
// selection cache).
clearAndResetSelect();
}

if(!allFixedRanges) {
if(dragModeNow === 'zoom') {
Expand Down Expand Up @@ -207,12 +224,20 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
}

function clickFn(numClicks, evt) {
var clickmode = gd._fullLayout.clickmode;

removeZoombox(gd);

if(numClicks === 2 && !singleEnd) doubleClick();

if(isMainDrag) {
Fx.click(gd, evt, plotinfo.id);
if(clickmode.indexOf('select') > -1) {
selectOnClick(evt, gd, xaxes, yaxes, plotinfo.id, dragOptions);
}

if(clickmode.indexOf('event') > -1) {
Fx.click(gd, evt, plotinfo.id);
}
}
else if(numClicks === 1 && singleEnd) {
var ax = ns ? ya0 : xa0,
Expand Down
Loading

0 comments on commit bdc94ce

Please sign in to comment.