MCPcopy Create free account
hub / github.com/plotly/plotly.js / isPointOrBinSelected

Function isPointOrBinSelected

src/components/selections/select.js:875–892  ·  view source on GitHub ↗
(clickedPtInfo)

Source from the content-addressed store, hash-verified

873}
874
875function isPointOrBinSelected(clickedPtInfo) {
876 var trace = clickedPtInfo.searchInfo.cd[0].trace;
877 var ptNum = clickedPtInfo.pointNumber;
878 var ptNums = clickedPtInfo.pointNumbers;
879 var ptNumsSet = ptNums.length > 0;
880
881 // When pointsNumbers is set (e.g. histogram's binning),
882 // it is assumed that when the first point of
883 // a bin is selected, all others are as well
884 var ptNumToTest = ptNumsSet ? ptNums[0] : ptNum;
885
886 // TODO potential performance improvement
887 // Primarily we need this function to determine if a click adds
888 // or subtracts from a selection.
889 // In cases `trace.selectedpoints` is a huge array, indexOf
890 // might be slow. One remedy would be to introduce a hash somewhere.
891 return trace.selectedpoints ? trace.selectedpoints.indexOf(ptNumToTest) > -1 : false;
892}
893
894function isOnlyThisBinSelected(searchTraces, clickedPtInfo) {
895 var tracesWithSelectedPts = [];

Callers 1

selectOnClickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…