-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fx component #1613
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
Merged
Merged
Fx component #1613
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ffde987
break up cartesian graph_interact.js:
etpinard 1d4930c
update Fx require statements
etpinard e609955
update hover constant require statements
etpinard 12954aa
sub Fx.init by (cartesian) initIterations
etpinard 27fb2d0
decrease max allowed circular deps to 13 :tada:
etpinard a96af57
mv fx attribute out of plots/ and into components/fx/
etpinard abcf1b0
register fx in core.js
etpinard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright 2012-2017, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Registry = require('../../registry'); | ||
|
||
module.exports = function click(gd, evt) { | ||
var annotationsDone = Registry.getComponentMethod('annotations', 'onClick')(gd, gd._hoverdata); | ||
|
||
function emitClick() { gd.emit('plotly_click', {points: gd._hoverdata, event: evt}); } | ||
|
||
if(gd._hoverdata && evt && evt.target) { | ||
if(annotationsDone && annotationsDone.then) { | ||
annotationsDone.then(emitClick); | ||
} | ||
else emitClick(); | ||
|
||
// why do we get a double event without this??? | ||
if(evt.stopImmediatePropagation) evt.stopImmediatePropagation(); | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright 2012-2017, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
// max pixels away from mouse to allow a point to highlight | ||
MAXDIST: 20, | ||
|
||
// hover labels for multiple horizontal bars get tilted by this angle | ||
YANGLE: 60, | ||
|
||
// size and display constants for hover text | ||
HOVERARROWSIZE: 6, // pixel size of hover arrows | ||
HOVERTEXTPAD: 3, // pixels padding around text | ||
HOVERFONTSIZE: 13, | ||
HOVERFONT: 'Arial, sans-serif', | ||
|
||
// minimum time (msec) between hover calls | ||
HOVERMINTIME: 50, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Copyright 2012-2017, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var constants = require('./constants'); | ||
|
||
// look for either subplot or xaxis and yaxis attributes | ||
exports.getSubplot = function getSubplot(trace) { | ||
return trace.subplot || (trace.xaxis + trace.yaxis) || trace.geo; | ||
}; | ||
|
||
// convenience functions for mapping all relevant axes | ||
exports.flat = function flat(subplots, v) { | ||
var out = []; | ||
for(var i = subplots.length; i > 0; i--) out.push(v); | ||
return out; | ||
}; | ||
|
||
exports.p2c = function p2c(axArray, v) { | ||
var out = []; | ||
for(var i = 0; i < axArray.length; i++) out.push(axArray[i].p2c(v)); | ||
return out; | ||
}; | ||
|
||
exports.getDistanceFunction = function getDistanceFunction(mode, dx, dy, dxy) { | ||
if(mode === 'closest') return dxy || quadrature(dx, dy); | ||
return mode === 'x' ? dx : dy; | ||
}; | ||
|
||
exports.getClosest = function getClosest(cd, distfn, pointData) { | ||
// do we already have a point number? (array mode only) | ||
if(pointData.index !== false) { | ||
if(pointData.index >= 0 && pointData.index < cd.length) { | ||
pointData.distance = 0; | ||
} | ||
else pointData.index = false; | ||
} | ||
else { | ||
// apply the distance function to each data point | ||
// this is the longest loop... if this bogs down, we may need | ||
// to create pre-sorted data (by x or y), not sure how to | ||
// do this for 'closest' | ||
for(var i = 0; i < cd.length; i++) { | ||
var newDistance = distfn(cd[i]); | ||
if(newDistance <= pointData.distance) { | ||
pointData.index = i; | ||
pointData.distance = newDistance; | ||
} | ||
} | ||
} | ||
return pointData; | ||
}; | ||
|
||
// for bar charts and others with finite-size objects: you must be inside | ||
// it to see its hover info, so distance is infinite outside. | ||
// But make distance inside be at least 1/4 MAXDIST, and a little bigger | ||
// for bigger bars, to prioritize scatter and smaller bars over big bars | ||
// | ||
// note that for closest mode, two inbox's will get added in quadrature | ||
// args are (signed) difference from the two opposite edges | ||
// count one edge as in, so that over continuous ranges you never get a gap | ||
exports.inbox = function inbox(v0, v1) { | ||
if(v0 * v1 < 0 || v0 === 0) { | ||
return constants.MAXDIST * (0.6 - 0.3 / Math.max(3, Math.abs(v0 - v1))); | ||
} | ||
return Infinity; | ||
}; | ||
|
||
function quadrature(dx, dy) { | ||
return function(di) { | ||
var x = dx(di), | ||
y = dy(di); | ||
return Math.sqrt(x * x + y * y); | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcjohnson can you think of anything else that might be better off in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, I think you got it all!